From 6801901f3c53399dd34f3f980d03aca569a75ace Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 25 Oct 2013 15:53:27 -0700 Subject: [PATCH] Get prompt repo name on chpwd --- zsh/func/prompt_loquacious_setup | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/zsh/func/prompt_loquacious_setup b/zsh/func/prompt_loquacious_setup index 540e7c7..a1c95dc 100644 --- a/zsh/func/prompt_loquacious_setup +++ b/zsh/func/prompt_loquacious_setup @@ -31,6 +31,7 @@ function prompt_loquacious_setup autoload -Uz vcs_info autoload -U add-zsh-hook + add-zsh-hook chpwd set_repo_name add-zsh-hook precmd set_xterm_title add-zsh-hook precmd print_newline add-zsh-hook precmd set_prompt_info @@ -41,10 +42,12 @@ function prompt_loquacious_setup prompt_opts=(cr subst percent) # Set up vcs_info - zstyle ':vcs_info:git:loquacious:*' formats \ - '%F{cyan}%r%f(%F{blue}%b%f)' + zstyle ':vcs_info:git:loquacious_chpwd:*' formats \ + '%F{cyan}%r%f' + zstyle ':vcs_info:git:loquacious_precmd:*' formats \ + '(%F{blue}%b%f)' - PS1='${PS1_NAME}${PS1_HOST}${PS1_CWD}${PS1_REPO}${PS1_ZLE_MODE} + PS1='${PS1_NAME}${PS1_HOST}${PS1_CWD}${PS1_REPO}${PS1_BRANCH}${PS1_ZLE_MODE} $PS1_LINE' zle -N zle-keymap-select on_keymap_select @@ -75,6 +78,17 @@ function print_newline } +function set_repo_name +{ + vcs_info loquacious_chpwd + if [[ -n "${vcs_info_msg_0_}" ]]; then + PS1_REPO="on ${vcs_info_msg_0_}" + else + PS1_REPO="" + fi +} + + function set_prompt_info { PS1_HISTORY="`prompt_colorize -b -f 'green' '%h'`" @@ -89,11 +103,11 @@ function set_prompt_info # Get git repo information, if it exists. See setup function for # configuration details. - vcs_info loquacious + vcs_info loquacious_precmd if [[ -n "$vcs_info_msg_0_" ]]; then - PS1_REPO="on $vcs_info_msg_0_ " + PS1_BRANCH="${vcs_info_msg_0_}" else - PS1_REPO="" + PS1_BRANCH="" fi # Show background jobs, if any.