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:
2026-09-01 12:38:00 -05:00
parent b28f38d4c0
commit 1b386f1b40
3 changed files with 213 additions and 10 deletions
+9 -5
View File
@@ -9,11 +9,15 @@ accounts: `reachableceo` and `reachableceo-offstage`.
## What's managed
- `~/.zshrc` — oh-my-zsh + powerlevel10k + autosuggestions /
syntax-highlighting / completions, vi mode, fzf, history prefs
- `~/.config/zsh/` — aliases.sh, variables.sh (personal snippets)
- `~/.p10k.zsh` — lean theme, compatible glyphs (run `p10k configure`
on a nerd-font terminal to upgrade)
- `~/.zshrc` — oh-my-zsh + autosuggestions / syntax-highlighting /
completions, vi mode, fzf, history prefs
- `~/.config/zsh/kali-comforts.sh` — the Kali Linux default shell feel:
twoline `┌──(user㉿host)-[dir]` prompt (root gets 💀), menu-select +
case-insensitive completion, Kali keybindings/color aliases/palette.
Loaded last; `KALI_PROMPT=0` in `~/.zshrc` restores powerlevel10k
- `~/.config/zsh/aliases.sh`, `variables.sh` — personal snippets
- `~/.p10k.zsh` — fallback theme, compatible glyphs (run `p10k
configure` on a nerd-font terminal to upgrade)
- `~/.tmux.conf` — Ctrl-a prefix, mouse, vi copy mode
- `~/.vimrc`, `~/.gitconfig` (template: hooksPath + tea helper render
only for `reachableceo`)
+18 -3
View File
@@ -2,19 +2,29 @@
# Home base: ultix-streaming (VM 5111). Minimal interactive footprint
# anywhere else; heavy lifting happens in containers.
#
# Layers: oh-my-zsh + powerlevel10k, fzf, vi mode, ~/.config/zsh/* snippets.
# Layers: oh-my-zsh + Kali-style prompt/completions (kali-comforts.sh),
# fzf, vi mode, ~/.config/zsh/* snippets. powerlevel10k stays installed
# as the fallback prompt (KALI_PROMPT=0).
#####################################################################
# oh-my-zsh
#####################################################################
export ZSH="$HOME/.oh-my-zsh"
# Prompt: Kali twoline by default (kali-comforts.sh applies it last).
# KALI_PROMPT=0 flips back to powerlevel10k.
KALI_PROMPT=${KALI_PROMPT:-1}
if [[ "$KALI_PROMPT" == 1 ]]; then
ZSH_THEME=""
else
ZSH_THEME="powerlevel10k/powerlevel10k"
fi
# externals in .chezmoiexternal.toml own updates
zstyle ':omz:update' mode disabled
ENABLE_CORRECTION="true"
# Kali ships command correction OFF — the nagging outweighs the saves
DISABLE_UNTRACKED_FILES_DIRTY="true"
HIST_STAMPS="yyyy-mm-dd"
@@ -33,8 +43,10 @@ plugins=(
source $ZSH/oh-my-zsh.sh
# powerlevel10k (run `p10k configure` any time for the fancy wizard)
# powerlevel10k loads only when it's the active prompt
if [[ "$KALI_PROMPT" != 1 ]]; then
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
fi
#####################################################################
# Creature comforts
@@ -113,3 +125,6 @@ fi
[[ -r "$HOME/.config/zsh/variables.sh" ]] && source "$HOME/.config/zsh/variables.sh"
[[ -r "$HOME/.config/zsh/aliases.sh" ]] && source "$HOME/.config/zsh/aliases.sh"
# Kali-style prompt + completions (loaded last so its settings win)
[[ -r "$HOME/.config/zsh/kali-comforts.sh" ]] && source "$HOME/.config/zsh/kali-comforts.sh"
+184
View File
@@ -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