-
Notifications
You must be signed in to change notification settings - Fork 0
/
prompt_xeago_setup
53 lines (44 loc) · 1.28 KB
/
prompt_xeago_setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
prompt_xeago_setup () {
export VIRTUAL_ENV_DISABLE_PROMPT=1 # disallow virtualenv from updating prompt
PROMPT=''
PROMPT+='%(?..%S)'
if [[ -n $SSH_CONNECTION || $UID -eq 0 ]]; then
PROMPT+='%F{white}%n%F{magenta}@%F{yellow}%m%f:'
fi
PROMPT+='%F{cyan}${${(%):-%c}//\//%B%F{204\}/%b%F{cyan\}}%f'
PROMPT+='%(!.%{%F{magenta}%}#.%{%F{red}%}$)%f%s '
prompt_opts=(cr subst percent)
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git*' formats "%f %b"
zstyle ':vcs_info:git*' actionformats "%F{red}%a%f %b"
PR_GIT_UPDATE=1
function zsh_git_prompt_precmd {
if [[ -n "$PR_GIT_UPDATE" ]] ; then
vcs_info
PR_GIT_UPDATE=
fi
}
precmd_functions+=('zsh_git_prompt_precmd')
function zsh_git_prompt_chpwd {
PR_GIT_UPDATE=1
}
function print_cwd_chpwd {
print -P %F{cyan}${${(%):-%~}//\//%B%F{204}/%b%F{cyan}}%f
}
alias pwd=print_cwd_chpwd
chpwd_functions+=('zsh_git_prompt_chpwd' 'print_cwd_chpwd')
function zsh_git_prompt_preexec {
case "$(history $HISTCMD)" in
*git*)
PR_GIT_UPDATE=1
;;
*gh*)
PR_GIT_UPDATE=1
;;
esac
}
preexec_functions+=('zsh_git_prompt_preexec')
RPROMPT='${vcs_info_msg_0_} ${VIRTUAL_ENV:t} %(?..%?)'
}
prompt_xeago_setup "$@"