Kali-style shell on top of omz; p10k fallback via KALI_PROMPT (#612)
Port of Kali's stock kali-zsh-config as ~/.config/zsh/kali-comforts.sh: twoline prompt, menu-select + case-insensitive completion, keybindings, color aliases, syntax-highlight palette. Loaded last; omz untouched. Details + UAT: https://projects.knownelement.com/issues/612#note-3343
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
###################################
|
||||
# ~/.config/zsh/kali-comforts.sh — chezmoi-managed
|
||||
# Kali Linux default zsh experience (kali-zsh-config) layered on
|
||||
# oh-my-zsh: options, keybindings, completions, the twoline prompt,
|
||||
# color aliases and the Kali syntax-highlight palette.
|
||||
# Prompt toggle: KALI_PROMPT=0 in ~/.zshrc restores powerlevel10k.
|
||||
###################################
|
||||
|
||||
#####################################################################
|
||||
# Options (Kali stock)
|
||||
#####################################################################
|
||||
|
||||
setopt autocd # change directory just by typing its name
|
||||
setopt interactivecomments # allow comments in interactive shells
|
||||
setopt magicequalsubst # filename expansion for x=expr arguments
|
||||
setopt nonomatch # unmatched glob passes through, no error
|
||||
setopt notify # report background job status immediately
|
||||
setopt numericglobsort # sort filenames numerically when sensible
|
||||
setopt promptsubst # enable substitutions in the prompt
|
||||
setopt hist_ignore_space # commands starting with space skip history
|
||||
|
||||
WORDCHARS=${WORDCHARS//\/} # '/' is not part of a word
|
||||
PROMPT_EOL_MARK="" # hide the EOL '%'
|
||||
|
||||
#####################################################################
|
||||
# Keybindings (Kali stock) — coexist with vi-insert mode
|
||||
#####################################################################
|
||||
|
||||
bindkey ' ' magic-space # history expansion on space
|
||||
bindkey '^[[3;5~' kill-word # ctrl + del
|
||||
bindkey '^[[3~' delete-char # del
|
||||
bindkey '^[[1;5C' forward-word # ctrl + right
|
||||
bindkey '^[[1;5D' backward-word # ctrl + left
|
||||
bindkey '^[[5~' beginning-of-buffer-or-history # page up
|
||||
bindkey '^[[6~' end-of-buffer-or-history # page down
|
||||
bindkey '^[[H' beginning-of-line # home
|
||||
bindkey '^[[F' end-of-line # end
|
||||
bindkey '^[[Z' undo # shift + tab
|
||||
|
||||
#####################################################################
|
||||
# Completion (Kali stock zstyles) — menu select + case-insensitive
|
||||
#####################################################################
|
||||
|
||||
zstyle ':completion:*:*:*:*:*' menu select
|
||||
zstyle ':completion:*' auto-description 'specify: %d'
|
||||
zstyle ':completion:*' completer _expand _complete
|
||||
zstyle ':completion:*' format 'Completing %d'
|
||||
zstyle ':completion:*' group-name ''
|
||||
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
|
||||
zstyle ':completion:*' rehash true
|
||||
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
|
||||
zstyle ':completion:*' use-compctl false
|
||||
zstyle ':completion:*' verbose true
|
||||
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
|
||||
|
||||
#####################################################################
|
||||
# Prompt — the Kali twoline: root gets the skull, users get ㉿,
|
||||
# right side shows last exit status and background jobs.
|
||||
# Alt-P flips twoline/oneline (Kali binds ^P; Alt-P keeps vi ^P).
|
||||
#####################################################################
|
||||
|
||||
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
||||
debian_chroot=$(cat /etc/debian_chroot)
|
||||
fi
|
||||
|
||||
VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
PROMPT_ALTERNATIVE=${PROMPT_ALTERNATIVE:-twoline}
|
||||
NEWLINE_BEFORE_PROMPT=yes
|
||||
|
||||
configure_prompt() {
|
||||
prompt_symbol=㉿
|
||||
[ "$EUID" -eq 0 ] && prompt_symbol=💀
|
||||
case "$PROMPT_ALTERNATIVE" in
|
||||
twoline)
|
||||
PROMPT=$'%F{%(#.blue.green)}┌──${debian_chroot:+($debian_chroot)─}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))─}(%B%F{%(#.red.blue)}%n$prompt_symbol%m%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\n└─%B%(#.%F{red}#.%F{blue}$)%b%F{reset} '
|
||||
RPROMPT=$'%(?.. %? %F{red}%B⨯%b%F{reset})%(1j. %j %F{yellow}%B⚙%b%F{reset}.)'
|
||||
;;
|
||||
oneline)
|
||||
PROMPT=$'${debian_chroot:+($debian_chroot)}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))}%B%F{%(#.red.blue)}%n@%m%b%F{reset}:%B%F{%(#.blue.green)}%~%b%F{reset}%(#.#.$) '
|
||||
RPROMPT=
|
||||
;;
|
||||
esac
|
||||
}
|
||||
configure_prompt
|
||||
|
||||
toggle_oneline_prompt() {
|
||||
if [ "$PROMPT_ALTERNATIVE" = oneline ]; then
|
||||
PROMPT_ALTERNATIVE=twoline
|
||||
else
|
||||
PROMPT_ALTERNATIVE=oneline
|
||||
fi
|
||||
configure_prompt
|
||||
zle reset-prompt
|
||||
}
|
||||
zle -N toggle_oneline_prompt
|
||||
bindkey '^[p' toggle_oneline_prompt
|
||||
|
||||
# blank line between prompts (skips the very first one)
|
||||
precmd() {
|
||||
if [ "$NEWLINE_BEFORE_PROMPT" = yes ]; then
|
||||
if [ -z "$_NEW_LINE_BEFORE_PROMPT" ]; then
|
||||
_NEW_LINE_BEFORE_PROMPT=1
|
||||
else
|
||||
print ""
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
# Colors: dircolors, color aliases, colored less/man (Kali stock)
|
||||
#####################################################################
|
||||
|
||||
if [ -x /usr/bin/dircolors ]; then
|
||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||
|
||||
alias dir='dir --color=auto'
|
||||
alias vdir='vdir --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
alias diff='diff --color=auto'
|
||||
alias ip='ip --color=auto'
|
||||
|
||||
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
|
||||
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
|
||||
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
|
||||
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
|
||||
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
|
||||
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
|
||||
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
|
||||
|
||||
# take advantage of $LS_COLORS for completion as well
|
||||
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
# Kali syntax-highlight palette (only when the plugin is loaded)
|
||||
#####################################################################
|
||||
|
||||
if [[ -n "${ZSH_HIGHLIGHT_VERSION:-}" ]]; then
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
|
||||
ZSH_HIGHLIGHT_STYLES[default]=none
|
||||
ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=red,bold
|
||||
ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=cyan,bold
|
||||
ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=green,underline
|
||||
ZSH_HIGHLIGHT_STYLES[global-alias]=fg=magenta
|
||||
ZSH_HIGHLIGHT_STYLES[precommand]=fg=green,underline
|
||||
ZSH_HIGHLIGHT_STYLES[commandseparator]=fg=blue,bold
|
||||
ZSH_HIGHLIGHT_STYLES[autodirectory]=fg=green,underline
|
||||
ZSH_HIGHLIGHT_STYLES[path]=underline
|
||||
ZSH_HIGHLIGHT_STYLES[path_pathseparator]=
|
||||
ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]=
|
||||
ZSH_HIGHLIGHT_STYLES[globbing]=fg=blue,bold
|
||||
ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=blue,bold
|
||||
ZSH_HIGHLIGHT_STYLES[command-substitution]=none
|
||||
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]=fg=magenta
|
||||
ZSH_HIGHLIGHT_STYLES[process-substitution]=none
|
||||
ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]=fg=magenta
|
||||
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=magenta
|
||||
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=magenta
|
||||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none
|
||||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]=fg=blue,bold
|
||||
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=yellow
|
||||
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=yellow
|
||||
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=yellow
|
||||
ZSH_HIGHLIGHT_STYLES[rc-quote]=fg=magenta
|
||||
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=magenta
|
||||
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=magenta
|
||||
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=fg=magenta
|
||||
ZSH_HIGHLIGHT_STYLES[assign]=none
|
||||
ZSH_HIGHLIGHT_STYLES[redirection]=fg=blue,bold
|
||||
ZSH_HIGHLIGHT_STYLES[comment]=fg=black,bold
|
||||
ZSH_HIGHLIGHT_STYLES[named-fd]=none
|
||||
ZSH_HIGHLIGHT_STYLES[numeric-fd]=none
|
||||
ZSH_HIGHLIGHT_STYLES[arg0]=fg=green
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=fg=blue,bold
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=fg=green,bold
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-3]=fg=magenta,bold
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-4]=fg=yellow,bold
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-5]=fg=cyan,bold
|
||||
ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]=standout
|
||||
fi
|
||||
Reference in New Issue
Block a user