Get prompt repo name on chpwd
This commit is contained in:
parent
5fe08235fe
commit
6801901f3c
1 changed files with 20 additions and 6 deletions
|
@ -31,6 +31,7 @@ function prompt_loquacious_setup
|
||||||
autoload -Uz vcs_info
|
autoload -Uz vcs_info
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
|
|
||||||
|
add-zsh-hook chpwd set_repo_name
|
||||||
add-zsh-hook precmd set_xterm_title
|
add-zsh-hook precmd set_xterm_title
|
||||||
add-zsh-hook precmd print_newline
|
add-zsh-hook precmd print_newline
|
||||||
add-zsh-hook precmd set_prompt_info
|
add-zsh-hook precmd set_prompt_info
|
||||||
|
@ -41,10 +42,12 @@ function prompt_loquacious_setup
|
||||||
prompt_opts=(cr subst percent)
|
prompt_opts=(cr subst percent)
|
||||||
|
|
||||||
# Set up vcs_info
|
# Set up vcs_info
|
||||||
zstyle ':vcs_info:git:loquacious:*' formats \
|
zstyle ':vcs_info:git:loquacious_chpwd:*' formats \
|
||||||
'%F{cyan}%r%f(%F{blue}%b%f)'
|
'%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'
|
$PS1_LINE'
|
||||||
|
|
||||||
zle -N zle-keymap-select on_keymap_select
|
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
|
function set_prompt_info
|
||||||
{
|
{
|
||||||
PS1_HISTORY="`prompt_colorize -b -f 'green' '%h'`"
|
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
|
# Get git repo information, if it exists. See setup function for
|
||||||
# configuration details.
|
# configuration details.
|
||||||
vcs_info loquacious
|
vcs_info loquacious_precmd
|
||||||
if [[ -n "$vcs_info_msg_0_" ]]; then
|
if [[ -n "$vcs_info_msg_0_" ]]; then
|
||||||
PS1_REPO="on $vcs_info_msg_0_ "
|
PS1_BRANCH="${vcs_info_msg_0_}"
|
||||||
else
|
else
|
||||||
PS1_REPO=""
|
PS1_BRANCH=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Show background jobs, if any.
|
# Show background jobs, if any.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue