truncate git branch in prompt

This commit is contained in:
xunuwu 2025-01-23 09:32:33 +01:00
parent c28dccd2b1
commit dc74bbeb78
Signed by: xun
SSH key fingerprint: SHA256:Uot/1WoAjWAeqLOHA5vYy4phhVydsH7jCPmBjaPZfgI

View file

@ -62,12 +62,16 @@
} }
autoload -Uz vcs_info autoload -Uz vcs_info
precmd_vcs_info() { vcs_info } precmd_vcs_info() {
vcs_info
export vcs_info_msg_0_="''${vcs_info_msg_0_:0:20}''${vcs_info_msg_0_[21]:+...}" # truncate the branch name
}
precmd_functions+=( precmd_vcs_info precmd_timer ) precmd_functions+=( precmd_vcs_info precmd_timer )
zstyle ':vcs_info:git:*' formats ' %b ' zstyle ':vcs_info:git:*' formats ' %b '
setopt prompt_subst setopt prompt_subst
PROMPT='%F{blue}[%F{magenta}%n%F{blue}@%F{magenta}%M%F{blue}] %~%f %F{green}$vcs_info_msg_0_%f%(?..%F{red}| %? )%#%f ' PROMPT='%F{blue}[%F{magenta}%n%F{blue}@%F{magenta}%M%F{blue}] %~%f %F{green}''${vcs_info_msg_0_}%f%(?..%F{red}| %? )%#%f '
''; '';
}; };
} }