From b39af9764913e28a8bf2bcac5e18d94d1667521c Mon Sep 17 00:00:00 2001 From: darkelfe14728 Date: Thu, 30 May 2019 14:57:08 +0200 Subject: [PATCH] zsh - add git branch in prompt --- zsh/zshrc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/zsh/zshrc b/zsh/zshrc index 3100f17..ff8d01e 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -57,8 +57,26 @@ done # USER part # Interface de demande +setopt prompt_subst +autoload -Uz vcs_info +zstyle ':vcs_info:*' actionformats \ + '[%b%]%f ' +zstyle ':vcs_info:*' formats \ + '[%b]%f ' +zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' + +zstyle ':vcs_info:*' enable git + +# or use pre_cmd, see man zshcontrib +vcs_info_wrapper() { + vcs_info + if [ -n "$vcs_info_msg_0_" ]; then + echo "%{$fg[blue]%}${vcs_info_msg_0_}%{$reset_color%}" + fi +} + autoload -U colors && colors -PROMPT="%{${fg_bold[red]}%}%n%{${fg[blue]}%}@%{${fg[green]}%}%m %{${fg[magenta]}%}%~ %{${fg_bold[yellow]}%}%#%{${reset_color}%} " +PROMPT=$'%{${fg_bold[red]}%}%n%{${fg[blue]}%}@%{${fg[green]}%}%m %{${fg[magenta]}%}%~ $(vcs_info_wrapper)%{${fg_bold[yellow]}%}%#%{${reset_color}%} ' # Variables export MOZILLA_FIVE_HOME=/usr/lib/mozilla