feat: add Kali terminal-look module

This commit is contained in:
edemilov committed 2026-08-30 17:19:21 +03:00
1 parent f6b2d929f2
commit 73edf11a23
3 files changed
+102

No files matched your search

+28
View File
@@ -11,6 +11,7 @@ LOCAL_BIN="${LOCAL_BIN:-$HOME/.local/bin}"
DOTEVO_RAW_BASE="${DOTEVO_RAW_BASE:-https://git.edemilov.ru/edemilov/dotevo/raw/branch/master}"
OMZ_DIR="${OMZ_DIR:-$HOME/.oh-my-zsh}"
ZSH_CUSTOM_DIR="${ZSH_CUSTOM_DIR:-$HOME/.dotevo-zsh-custom}"
ASSETS_DIR="${ASSETS_DIR:-$HOME/.dotevo}"
check_arch() {
command -v pacman >/dev/null 2>&1
@@ -415,6 +416,33 @@ apply_terminal_look_p10k() {
write_zshrc_p10k "$HOME/.zshrc"
}
write_zshrc_kali() {
local dest="$1"
cat > "$dest" <<'EOF'
source "$HOME/.dotevo/kali-prompt.zsh"
source "$HOME/.dotevo-zsh-custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh"
source "$HOME/.dotevo-zsh-custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
source "$HOME/.dotevo-zsh-custom/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh"
if command -v fzf >/dev/null 2>&1; then
eval "$(fzf --zsh)"
fi
EOF
}
apply_terminal_look_kali() {
clone_or_update_repo "https://github.com/zsh-users/zsh-autosuggestions.git" "$ZSH_CUSTOM_DIR/plugins/zsh-autosuggestions"
clone_or_update_repo "https://github.com/zsh-users/zsh-syntax-highlighting.git" "$ZSH_CUSTOM_DIR/plugins/zsh-syntax-highlighting"
clone_or_update_repo "https://github.com/zsh-users/zsh-history-substring-search.git" "$ZSH_CUSTOM_DIR/plugins/zsh-history-substring-search"
mkdir -p "$ASSETS_DIR"
backup_if_exists "$ASSETS_DIR/kali-prompt.zsh"
cp "$REPO_DIR/terminal/kali/prompt.zsh" "$ASSETS_DIR/kali-prompt.zsh"
backup_if_exists "$HOME/.zshrc"
write_zshrc_kali "$HOME/.zshrc"
}
# Implemented fully in Task 8 -- stubbed here so main()'s dispatch is
# complete and testable before the terminal-look module exists.
apply_terminal_look() {
+11
View File
@@ -0,0 +1,11 @@
# Kali-style prompt -- matches Kali Linux's real default box prompt from
# /etc/zsh/zshrc (the kali-defaults package). No framework, no theme
# file, just zsh's own prompt escapes and the `colors` module.
autoload -Uz colors && colors
setopt prompt_subst
PROMPT='%F{%(#.blue.green)}┌──(%B%F{%(#.red.blue)}%n@%m%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]
└─%B%(#.%F{red}#.%F{blue}$)%b%F{reset} '
RPROMPT='%(?..%F{red}[%?]%f)'
autoload -Uz compinit && compinit
+63
View File
@@ -645,3 +645,66 @@ EOF
rm -rf "$tmp_home" "$stub_bin"
}
@test "terminal/kali/prompt.zsh is syntactically valid zsh" {
[ -f "${BATS_TEST_DIRNAME}/../terminal/kali/prompt.zsh" ]
if command -v zsh >/dev/null 2>&1; then
zsh -n "${BATS_TEST_DIRNAME}/../terminal/kali/prompt.zsh"
fi
}
@test "write_zshrc_kali sources prompt.zsh and the plugin scripts directly, no oh-my-zsh" {
source "${BATS_TEST_DIRNAME}/../install.sh"
local tmp_home
tmp_home="$(mktemp -d)"
ASSETS_DIR="$tmp_home/.dotevo" ZSH_CUSTOM_DIR="$tmp_home/.dotevo-zsh-custom" \
write_zshrc_kali "$tmp_home/.zshrc"
grep -q 'source .*\.dotevo/kali-prompt.zsh' "$tmp_home/.zshrc"
grep -q 'source .*zsh-autosuggestions/zsh-autosuggestions.zsh' "$tmp_home/.zshrc"
grep -q 'source .*zsh-syntax-highlighting/zsh-syntax-highlighting.zsh' "$tmp_home/.zshrc"
grep -q 'source .*zsh-history-substring-search/zsh-history-substring-search.zsh' "$tmp_home/.zshrc"
grep -qv 'oh-my-zsh' "$tmp_home/.zshrc"
grep -q 'fzf --zsh' "$tmp_home/.zshrc"
if command -v zsh >/dev/null 2>&1; then
zsh -n "$tmp_home/.zshrc"
fi
rm -rf "$tmp_home"
}
@test "apply_terminal_look_kali clones only the three plugin repos, not oh-my-zsh" {
source "${BATS_TEST_DIRNAME}/../install.sh"
local tmp_home stub_bin
tmp_home="$(mktemp -d)"
stub_bin="$(mktemp -d)"
cat > "$stub_bin/git" <<EOF
#!/usr/bin/env bash
echo "git \$*" >> "$tmp_home/log"
if [[ "\$1" == "clone" ]]; then mkdir -p "\${@: -1}/.git"; fi
exit 0
EOF
chmod +x "$stub_bin/git"
HOME="$tmp_home" \
CONFIG_HOME="$tmp_home/.config" \
REPO_DIR="${BATS_TEST_DIRNAME}/.." \
ASSETS_DIR="$tmp_home/.dotevo" \
ZSH_CUSTOM_DIR="$tmp_home/.dotevo-zsh-custom" \
PATH="$stub_bin:$PATH" \
apply_terminal_look_kali
grep -q "zsh-users/zsh-autosuggestions" "$tmp_home/log"
grep -q "zsh-users/zsh-syntax-highlighting" "$tmp_home/log"
grep -q "zsh-users/zsh-history-substring-search" "$tmp_home/log"
! grep -q "ohmyzsh" "$tmp_home/log"
! grep -q "powerlevel10k" "$tmp_home/log"
[ -f "$tmp_home/.dotevo/kali-prompt.zsh" ]
grep -q 'Kali-style prompt' "$tmp_home/.dotevo/kali-prompt.zsh"
[[ "$(cat "$tmp_home/.zshrc")" == *"kali-prompt.zsh"* ]]
rm -rf "$tmp_home" "$stub_bin"
}