steeef.zsh-theme
2816 bytes
1# prompt style and colors based on Steve Losh's Prose theme:
2# https://github.com/sjl/oh-my-zsh/blob/master/themes/prose.zsh-theme
3#
4# vcs_info modifications from Bart Trojanowski's zsh prompt:
5# http://www.jukie.net/bart/blog/pimping-out-zsh-prompt
6#
7# git untracked files modification from Brian Carper:
8# https://briancarper.net/blog/570/git-info-in-your-zsh-prompt
9
10export VIRTUAL_ENV_DISABLE_PROMPT=1
11
12function virtualenv_info {
13 [ $VIRTUAL_ENV ] && echo '('%F{blue}`basename $VIRTUAL_ENV`%f') '
14}
15PR_GIT_UPDATE=1
16
17setopt prompt_subst
18
19autoload -U add-zsh-hook
20autoload -Uz vcs_info
21
22#use extended color palette if available
23if [[ $terminfo[colors] -ge 256 ]]; then
24 turquoise="%F{81}"
25 orange="%F{166}"
26 purple="%F{135}"
27 hotpink="%F{161}"
28 limegreen="%F{118}"
29else
30 turquoise="%F{cyan}"
31 orange="%F{yellow}"
32 purple="%F{magenta}"
33 hotpink="%F{red}"
34 limegreen="%F{green}"
35fi
36
37# enable VCS systems you use
38zstyle ':vcs_info:*' enable git svn
39
40# check-for-changes can be really slow.
41# you should disable it, if you work with large repositories
42zstyle ':vcs_info:*:prompt:*' check-for-changes true
43
44# set formats
45# %b - branchname
46# %u - unstagedstr (see below)
47# %c - stagedstr (see below)
48# %a - action (e.g. rebase-i)
49# %R - repository path
50# %S - path in the repository
51PR_RST="%f"
52FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})"
53FMT_ACTION="(%{$limegreen%}%a${PR_RST})"
54FMT_UNSTAGED="%{$orange%}โ"
55FMT_STAGED="%{$limegreen%}โ"
56
57zstyle ':vcs_info:*:prompt:*' unstagedstr "${FMT_UNSTAGED}"
58zstyle ':vcs_info:*:prompt:*' stagedstr "${FMT_STAGED}"
59zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH}${FMT_ACTION}"
60zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
61zstyle ':vcs_info:*:prompt:*' nvcsformats ""
62
63
64function steeef_preexec {
65 case "$2" in
66 *git*)
67 PR_GIT_UPDATE=1
68 ;;
69 *hub*)
70 PR_GIT_UPDATE=1
71 ;;
72 *svn*)
73 PR_GIT_UPDATE=1
74 ;;
75 esac
76}
77add-zsh-hook preexec steeef_preexec
78
79function steeef_chpwd {
80 PR_GIT_UPDATE=1
81}
82add-zsh-hook chpwd steeef_chpwd
83
84function steeef_precmd {
85 if [[ -n "$PR_GIT_UPDATE" ]] ; then
86 # check for untracked files or updated submodules, since vcs_info doesn't
87 if git ls-files --other --exclude-standard 2> /dev/null | grep -q "."; then
88 PR_GIT_UPDATE=1
89 FMT_BRANCH="(%{$turquoise%}%b%u%c%{$hotpink%}โ${PR_RST})"
90 else
91 FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})"
92 fi
93 zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH} "
94
95 vcs_info 'prompt'
96 PR_GIT_UPDATE=
97 fi
98}
99add-zsh-hook precmd steeef_precmd
100
101PROMPT=$'
102%{$purple%}%n${PR_RST} at %{$orange%}%m${PR_RST} in %{$limegreen%}%~${PR_RST} $vcs_info_msg_0_$(virtualenv_info)
103$ '