diff options
| author | kj_sh604 | 2025-12-28 23:23:02 -0500 |
|---|---|---|
| committer | kj_sh604 | 2025-12-28 23:23:02 -0500 |
| commit | f3b379dcdde48b80dc59664616157d4e38f6c447 (patch) | |
| tree | 8a95a9bd23643fbb5a720b74567034506640101e | |
| parent | c7272187cb46046dfe32fec63254013b161c65ea (diff) | |
refactor: better fish-style pwd for zsh
| -rw-r--r-- | .config/shell/git-prompts/kj_sh604-with-attempt-at-fish-style-pwd.zsh | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/.config/shell/git-prompts/kj_sh604-with-attempt-at-fish-style-pwd.zsh b/.config/shell/git-prompts/kj_sh604-with-attempt-at-fish-style-pwd.zsh index 8584150..d704782 100644 --- a/.config/shell/git-prompts/kj_sh604-with-attempt-at-fish-style-pwd.zsh +++ b/.config/shell/git-prompts/kj_sh604-with-attempt-at-fish-style-pwd.zsh | |||
| @@ -18,4 +18,47 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[blue]%}U" | |||
| 18 | ZSH_THEME_GIT_PROMPT_STASHED="%{$fg[blue]%}☐" | 18 | ZSH_THEME_GIT_PROMPT_STASHED="%{$fg[blue]%}☐" |
| 19 | ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓" | 19 | ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓" |
| 20 | 20 | ||
| 21 | PROMPT=$'%F{cyan}${${${:-$(printf "/%.1s" ${(s./.)PWD:h})/${PWD:t}}/\\/\\///}//\\%/%%}%f %F{242}$(gitprompt)%f%(12V.%F{242}%12v%f .)%(?.%F{white}.%F{white})%%%f ' | 21 | __fish_pwd() { |
| 22 | local pwd="${PWD/#$HOME/~}" | ||
| 23 | |||
| 24 | if [[ "$pwd" == "~" ]]; then | ||
| 25 | echo "~" | ||
| 26 | return | ||
| 27 | fi | ||
| 28 | |||
| 29 | local -a parts | ||
| 30 | |||
| 31 | parts=("${(@s:/:)pwd}") | ||
| 32 | |||
| 33 | if [[ -z "${parts[1]}" ]]; then | ||
| 34 | parts=("${parts[@]:1}") | ||
| 35 | local prefix="/" | ||
| 36 | else | ||
| 37 | local prefix="" | ||
| 38 | fi | ||
| 39 | |||
| 40 | if (( ${#parts[@]} <= 1 )); then | ||
| 41 | echo "${prefix}${parts[1]}" | ||
| 42 | return | ||
| 43 | fi | ||
| 44 | |||
| 45 | local result="" | ||
| 46 | local i | ||
| 47 | |||
| 48 | for (( i=1; i < ${#parts[@]}; i++ )); do | ||
| 49 | local part="${parts[$i]}" | ||
| 50 | if [[ "$part" == "~" ]]; then | ||
| 51 | result+="~/" | ||
| 52 | elif [[ "$part" == .* ]]; then | ||
| 53 | result+="${part:0:2}/" | ||
| 54 | else | ||
| 55 | result+="${part:0:1}/" | ||
| 56 | fi | ||
| 57 | done | ||
| 58 | |||
| 59 | result+="${parts[-1]}" | ||
| 60 | |||
| 61 | echo "${prefix}${result}" | ||
| 62 | } | ||
| 63 | |||
| 64 | PROMPT=$'%F{cyan}$(__fish_pwd)%f %F{242}$(gitprompt)%f%(12V.%F{242}%12v%f .)%(?.%F{white}.%F{white})%%%f ' \ No newline at end of file | ||
