-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.mytheme.zsh
More file actions
104 lines (98 loc) · 3.06 KB
/
Copy path.mytheme.zsh
File metadata and controls
104 lines (98 loc) · 3.06 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
zstyle ':vcs_info:*' max-exports 3
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*+*:*' debug false
zstyle ':vcs_info:git*+set-message:*' hooks git-remotebranch git-st
zstyle ':vcs_info:git:*' formats '%m' '%6.6i' '%b'
zstyle ':vcs_info:git:*' stagedstr "↑"
zstyle ':vcs_info:git:*' unstagedstr "↓"
+vi-git-remotebranch() {
local remote
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
--symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]] ; then
hook_com[branch]="${hook_com[branch]} [${remote}]"
fi
}
+vi-git-st() {
local ahead behind
local tracked stashed
local -a gitstatus
ahead=$(git rev-list @{upstream}..HEAD 2>/dev/null | wc -l)
(($ahead)) && gitstatus+=( "%F{40}↑$ahead%f" )
behind=$(git rev-list HEAD..@{upstream} 2>/dev/null | wc -l)
(($behind)) && gitstatus+=( "%F{160}↓$behind%f" )
stashed=$(git stash list 2>/dev/null | wc -l)
(( $stashed )) && gitstatus+=( "%{%F{244}%}#${stashed}%{%f%}" )
tracked=$(git status --porcelain | grep '^.. ' | wc -l)
(( $tracked )) && gitstatus+=( "%{%F{52}%}?${tracked}%{%f%}" )
# && hook_com[staged]+='S'
gitstatus+=( "" )
hook_com[misc]+=${(j: :)gitstatus}
}
_update_vcs_info_msg() {
local -a messages
local prom
local vcs_info_bold
local cbranch
local ccommit
local -a stats
local -a stash
LANG=en_US.UTF-8 vcs_info
vcs_info_bold=false
cbranch=238
ccommit=236
case $vcs_info_msg_0_ in
*'↑'*'↓'*)
cbranch=yellow
vcs_info_bold=true ;;
*'↑'*)
cbranch=green ;;
*'↓'*)
vcs_info_bold=true
cbranch=red ;;
*'#'*)
ccommit=245 ;;
*'?'*)
ccommit=52 ;;
*'#'*'?'*)
ccommit=25 ;;
esac
if [[ -z ${vcs_info_msg_2_} ]]; then
prom="%T"
PROMPT="%~# "
else
local temp
temp=${vcs_info_msg_0_}
for ((n=0;n<5;n++)); do
if [[ ${(j: :)stats} == *${temp%% *}* || ${(j: :)stash} == *${temp%% *}* ]] ; then
break
else
if [[ $n -lt 2 ]]; then
i+=1
stats+=$(echo "${temp%% *}")
else
stash+=$(echo "${temp%% *}")
fi
temp="${temp#* }"
fi
done
if $vcs_info_bold; then
prom="${stash} %F{$ccommit}${vcs_info_msg_1_}%f %B%F{$cbranch}${vcs_info_msg_2_}%f%b"
else
prom="${stash} %F{$ccommit}${vcs_info_msg_1_}%f %F{$cbranch}${vcs_info_msg_2_}%f"
fi
PROMPT="%~${(j::)stats}# "
fi
RPROMPT="$prom"
# echo $prom
}
add-zsh-hook precmd _update_vcs_info_msg
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
bindkey "^[[H" beginning-of-line # Home key
bindkey "^[[F" end-of-line # End key
bindkey "^[[3~" delete-char # Delete key
bindkey "^[[5~" history-beginning-search-backward # PageUp, older history completion
bindkey "^[[6~" history-beginning-search-forward # PageDown, later history completion