-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompt_nailyk_setup
80 lines (61 loc) · 2.04 KB
/
prompt_nailyk_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/zsh
prompt_nailyk_help () {
cat <<'EOF'
This prompt is color-scheme-able. You can invoke it thus:
prompt nailyk [<color1>]
where the color is for the right-hand prompt.
This prompt was stolen from Colin Walters <[email protected]>,
who gives credit to Michel Daenzer <[email protected]>.
EOF
}
prompt_nailyk_setup () {
if [[ "$(whoami)" == "root" ]]; then
c1='red'
else
c1='cyan' #username
fi
if [ -z "$c2" ]; then
c2='green' #hostname
fi
c3='green' #path
c4='red' #error
autoload -Uz vcs_info
#zstyle ':vcs_info:*' actionformats \
# '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
#zstyle ':vcs_info:*' formats \
# '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
# https://stackoverflow.com/questions/1128496/to-get-a-prompt-which-indicates-git-branch-in-zsh/12935606#12935606
# git untracked files
zstyle ':vcs_info:*' stagedstr 'M'
zstyle ':vcs_info:*' unstagedstr 'M'
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
zstyle ':vcs_info:*' enable git
+vi-git-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
[[ $(git ls-files --other --directory --exclude-standard | sed q | wc -l | tr -d ' ') == 1 ]] ; then
hook_com[unstaged]+='%F{1}??%f'
fi
}
zstyle ':vcs_info:*' actionformats \
'%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:*' formats \
'%F{5}[%F{2}%b%F{5}]%f %F{2}%c%F{3}%u%f'
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
zstyle ':vcs_info:*' enable git cvs svn
if [[ "$TERM" != "dumb" ]]; then
export PROMPT="%F{$c1}%n%f@%F{$c2}%m%f %(?,%F{green}%B:%)%b,%F{yellow}%? %F{$c4}%B:(%b)%f%F{white}%B %# %b%f"
export RPROMPT=$'$(vcs_info_wrapper)'"%F{${1:-$c3}}%~%f"
else
export PROMPT="%(?..[%?] )%n@%m:%~> "
fi
prompt_opts=(cr percent)
}
vcs_info_wrapper() {
vcs_info
if [ -n "$vcs_info_msg_0_" ]; then
echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del"
fi
}
#RPROMPT=$'$(vcs_info_wrapper)'
prompt_nailyk_setup "$@"