diff options
author | Marc Cornellà <marc.cornella@live.com> | 2021-03-13 13:51:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-13 13:51:26 +0100 |
commit | 3bb5e97762ee764170cffa6cfd1d179a1ba92ff3 (patch) | |
tree | 24ce0c7f6374490d4367d8ba2408ef923d7b70d5 /themes/gentoo.zsh-theme | |
parent | 0ab87c26c17171ae6162ff379a0c704fa57dff2e (diff) | |
download | zsh-3bb5e97762ee764170cffa6cfd1d179a1ba92ff3.tar.gz zsh-3bb5e97762ee764170cffa6cfd1d179a1ba92ff3.tar.bz2 zsh-3bb5e97762ee764170cffa6cfd1d179a1ba92ff3.zip |
feat(gentoo)!: use `vcs_info` to support other VCSs (#9440)
* prettify vcs infomation using `vcs_info`
* Show symbol when there are untracked files in git
Co-authored-by: freeyoung <ourbaozi@qq.com>
Diffstat (limited to 'themes/gentoo.zsh-theme')
-rw-r--r-- | themes/gentoo.zsh-theme | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/themes/gentoo.zsh-theme b/themes/gentoo.zsh-theme index 5f2427c7a..ae3274022 100644 --- a/themes/gentoo.zsh-theme +++ b/themes/gentoo.zsh-theme @@ -1,8 +1,28 @@ -function prompt_char { - if [ $UID -eq 0 ]; then echo "#"; else echo $; fi +autoload -Uz colors && colors + +autoload -Uz vcs_info +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:*' unstagedstr '%F{red}*' # display this when there are unstaged changes +zstyle ':vcs_info:*' stagedstr '%F{yellow}+' # display this when there are staged changes +zstyle ':vcs_info:*' actionformats '%F{5}(%F{2}%b%F{3}|%F{1}%a%c%u%m%F{5})%f ' +zstyle ':vcs_info:*' formats '%F{5}(%F{2}%b%c%u%m%F{5})%f ' +zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' +zstyle ':vcs_info:*' enable git cvs svn +zstyle ':vcs_info:git*+set-message:*' hooks untracked-git + ++vi-untracked-git() { + if command git status --porcelain 2>/dev/null | command grep -q '??'; then + hook_com[misc]='%F{red}?' + else + hook_com[misc]='' + fi +} + +gentoo_precmd() { + vcs_info } -PROMPT='%(!.%{$fg_bold[red]%}.%{$fg_bold[green]%}%n@)%m %{$fg_bold[blue]%}%(!.%1~.%~) $(git_prompt_info)$(prompt_char)%{$reset_color%} ' +autoload -U add-zsh-hook +add-zsh-hook precmd gentoo_precmd -ZSH_THEME_GIT_PROMPT_PREFIX="(" -ZSH_THEME_GIT_PROMPT_SUFFIX=") " +PROMPT='%(!.%B%F{red}.%B%F{green}%n@)%m %F{blue}%(!.%1~.%~) ${vcs_info_msg_0_}%(!.#.$)%{$reset_color%} ' |