aboutsummaryrefslogtreecommitdiff
path: root/.config/shell/git-prompts/kj_sh604.zsh
diff options
context:
space:
mode:
authorkj_sh6042025-12-28 23:26:34 -0500
committerkj_sh6042025-12-28 23:26:34 -0500
commitcc352d70fa1018cdcc3dea2982762e0d3d475eb5 (patch)
treece81089868adfcce02e3fe115e929eceb9fd23d1 /.config/shell/git-prompts/kj_sh604.zsh
parentf3b379dcdde48b80dc59664616157d4e38f6c447 (diff)
refactor: consolidate changes to git-prompts/kj_sh604.zsh
Diffstat (limited to '.config/shell/git-prompts/kj_sh604.zsh')
-rw-r--r--.config/shell/git-prompts/kj_sh604.zsh45
1 files changed, 44 insertions, 1 deletions
diff --git a/.config/shell/git-prompts/kj_sh604.zsh b/.config/shell/git-prompts/kj_sh604.zsh
index efdf4af..8cdb9e0 100644
--- a/.config/shell/git-prompts/kj_sh604.zsh
+++ b/.config/shell/git-prompts/kj_sh604.zsh
@@ -18,4 +18,47 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[blue]%}U"
ZSH_THEME_GIT_PROMPT_STASHED="%{$fg[blue]%}☐"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓"
-PROMPT=$'%F{cyan}%~%f %F{242}$(gitprompt)%f%(12V.%F{242}%12v%f .)%(?.%F{white}.%F{white})%%%f '
+__fish_pwd() {
+ local pwd="${PWD/#$HOME/~}"
+
+ if [[ "$pwd" == "~" ]]; then
+ echo "~"
+ return
+ fi
+
+ local -a parts
+
+ parts=("${(@s:/:)pwd}")
+
+ if [[ -z "${parts[1]}" ]]; then
+ parts=("${parts[@]:1}")
+ local prefix="/"
+ else
+ local prefix=""
+ fi
+
+ if (( ${#parts[@]} <= 1 )); then
+ echo "${prefix}${parts[1]}"
+ return
+ fi
+
+ local result=""
+ local i
+
+ for (( i=1; i < ${#parts[@]}; i++ )); do
+ local part="${parts[$i]}"
+ if [[ "$part" == "~" ]]; then
+ result+="~/"
+ elif [[ "$part" == .* ]]; then
+ result+="${part:0:2}/"
+ else
+ result+="${part:0:1}/"
+ fi
+ done
+
+ result+="${parts[-1]}"
+
+ echo "${prefix}${result}"
+}
+
+PROMPT=$'%F{cyan}$(__fish_pwd)%f %F{242}$(gitprompt)%f%(12V.%F{242}%12v%f .)%(?.%F{white}.%F{white})%%%f '