-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzsh-git-acp.plugin.zsh
268 lines (204 loc) · 11.4 KB
/
zsh-git-acp.plugin.zsh
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
0="${${0:#$ZSH_ARGZERO}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# util fns
fpath+=("${0:h}/autoload")
autoload -Uz "${0:h}/autoload/"*(.:t)
ZPWR_DEV_BRANCH="devBranch"
ZPWR_MAIN_BRANCH="master"
#{{{ MARK:alias
#**************************************************************
alias gbuom='git branch -u origin/$(zsh-gacp-mainBranch)'
alias gbuod='git branch -u origin/$(zsh-gacp-devBranch)'
alias gu='git rm --cached -r'
alias gaf='git add --force'
alias gpfsup='git push --force --set-upstream origin $(git symbolic-ref --short HEAD)'
alias gbu='git branch -u'
alias gcd='git checkout $(zsh-gacp-devBranch)'
alias gbuum='git branch -u upstream/$(zsh-gacp-mainBranch upstream)'
alias gbuud='git branch -u upstream/$(zsh-gacp-devBranch upstream)'
alias glgf='git log --stat --format=fuller'
alias gsa='git rev-list --all | xargs git grep -C 5'
alias gmc='git merge --continue'
alias gme='git merge --edit'
alias gmod='git merge origin/$(zsh-gacp-devBranch)'
alias gmom='git merge origin/$(zsh-gacp-mainBranch)'
alias gmud='git merge upstream/$(zsh-gacp-devBranch upstream)'
alias gmum='git merge upstream/$(zsh-gacp-mainBranch upstream)'
alias gdom='git diff -w origin/$(zsh-gacp-mainBranch)'
alias gdod='git diff -w origin/$(zsh-gacp-devBranch)'
alias gdum='git diff -w upstream/$(zsh-gacp-mainBranch upstream)'
alias gdud='git diff -w upstream/$(zsh-gacp-devBranch upstream)'
alias gcm='git checkout $(zsh-gacp-mainBranch)'
alias gcd='git checkout $(zsh-gacp-devBranch)'
alias gcof='git checkout -f'
alias gcom='git checkout $(zsh-gacp-mainBranch)'
alias gcoom='git checkout origin/$(zsh-gacp-mainBranch)'
alias gcofom='git checkout -f origin/$(zsh-gacp-mainBranch)'
alias gcood='git checkout origin/$(zsh-gacp-devBranch)'
alias gcod='git checkout $(zsh-gacp-devBranch)'
alias gcofod='git checkout -f origin/$(zsh-gacp-devBranch)'
alias gcoum='git checkout upstream/$(zsh-gacp-mainBranch upstream)'
alias gcofum='git checkout -f upstream/$(zsh-gacp-mainBranch upstream)'
alias gcoud='git checkout upstream/$(zsh-gacp-devBranch upstream)'
alias gcofud='git checkout -f upstream/$(zsh-gacp-devBranch upstream)'
alias glu='git pull upstream'
alias glr='git pull --rebase'
alias glrf='git pull --rebase --force'
alias glhm='_m=$(zsh-gacp-mainBranch); git pull heroku $_m:$_m; unset _m'
alias glfhm='_m=$(zsh-gacp-mainBranch); git pull -f heroku $_m:$_m; unset _m'
alias glrhm='_m=$(zsh-gacp-mainBranch); git pull --rebase heroku $_m:$_m; unset _m'
alias glom='_m=$(zsh-gacp-mainBranch); git pull origin $_m:$_m; unset _m'
alias glrom='_m=$(zsh-gacp-mainBranch); git pull --rebase origin $_m:$_m; unset _m'
alias glum='_m=$(zsh-gacp-mainBranch upstream); git pull upstream $_m:$_m; unset _m'
alias glrum='_m=$(zsh-gacp-mainBranch upstream); git pull --rebase upstream $_m:$_m; unset _m'
alias glod='_d=$(zsh-gacp-devBranch); git pull origin $_d:$_d; unset _d'
alias glrod='_d=$(zsh-gacp-devBranch); git pull --rebase origin $_d:$_d; unset _d'
alias glud='_d=$(zsh-gacp-devBranch upstream); git pull upstream $_d:$_d; unset _d'
alias glrud='_d=$(zsh-gacp-devBranch upstream); git pull --rebase upstream $_d:$_d; unset _d'
alias glomd='git pull origin $(zsh-gacp-mainBranch):$(zsh-gacp-devBranch)'
alias gludm='git pull upstream $(zsh-gacp-devBranch upstream):$(zsh-gacp-mainBranch upstream)'
alias glromd='git pull --rebase origin $(zsh-gacp-mainBranch):$(zsh-gacp-devBranch)'
alias glrudm='git pull --rebase upstream $(zsh-gacp-devBranch upstream):$(zsh-gacp-mainBranch upstream)'
alias glodm='git pull origin $(zsh-gacp-devBranch):$(zsh-gacp-mainBranch)'
alias glumd='git pull upstream $(zsh-gacp-mainBranch upstream):$(zsh-gacp-devBranch upstream)'
alias glrodm='git pull --rebase origin $(zsh-gacp-devBranch):$(zsh-gacp-mainBranch)'
alias glrumd='git pull --rebase upstream $(zsh-gacp-mainBranch upstream):$(zsh-gacp-devBranch upstream)'
alias grr='git remote remove'
alias gre='git remote rename'
alias grao='git remote add origin'
alias grau='git remote add upstream'
alias gpa='git push --all'
alias gpo='git push origin'
alias gpoa='git push origin --all'
alias gpfoa='git push --force origin --all'
alias gpu='git push upstream'
alias gpom='_m=$(zsh-gacp-mainBranch); git push origin $_m:$_m; unset _m'
alias gpod='_d=$(zsh-gacp-devBranch); git push origin $_d:$_d; unset _d'
alias gpomd='git push origin $(zsh-gacp-mainBranch):$(zsh-gacp-devBranch)'
alias gpodm='git push origin $(zsh-gacp-devBranch):$(zsh-gacp-mainBranch)'
alias gpum='_m=$(zsh-gacp-mainBranch upstream); git push upstream $_m:$_m; unset _m'
alias gpud='_d=$(zsh-gacp-devBranch upstream); git push upstream $_d:$_d; unset _d'
alias gpumd='git push upstream $(zsh-gacp-mainBranch upstream):$(zsh-gacp-devBranch)'
alias gpudm='git push upstream $(zsh-gacp-devBranch upstream):$(zsh-gacp-mainBranch)'
alias gphm='_m=$(zsh-gacp-mainBranch); git push heroku $_m:$_m; unset _m'
alias gpfhm='_m=$(zsh-gacp-mainBranch); git push --force heroku $_m:$_m; unset _m'
alias gpfha='git push --force heroku --all'
alias gpot='git push origin --tags'
alias gpfot='git push --force origin --tags'
alias gput='git push upstream --tags'
alias gpfut='git push --force upstream --tags'
alias glfo='git pull --force origin'
alias glrfo='git pull --rebase --force origin'
alias glfu='git pull --force upstream'
alias glrfu='git pull --rebase --force upstream'
alias glfom='_m=$(zsh-gacp-mainBranch); git pull --force origin $_m:$_m; unset _m'
alias glrfom='_m=$(zsh-gacp-mainBranch); git pull --rebase --force origin $_m:$_m; unset _m'
alias glfum='_m=$(zsh-gacp-mainBranch upstream); git pull --force upstream $_m:$_m; unset _m'
alias glrfum='_m=$(zsh-gacp-mainBranch upstream); git pull --rebase --force upstream $_m:$_m; unset _m'
alias glfod='_d=$(zsh-gacp-devBranch); git pull --force origin $_d:$_d; unset _d'
alias glfud='_d=$(zsh-gacp-devBranch upstream); git pull --force upstream $_d:$_d; unset _d'
alias glrfod='_d=$(zsh-gacp-devBranch); git pull --rebase --force origin $_d:$_d; unset _d'
alias glrfud='_d=$(zsh-gacp-devBranch upstream); git pull --rebase --force upstream $_d:$_d; unset _d'
alias glfomd='git pull --force origin $(zsh-gacp-mainBranch):$(zsh-gacp-devBranch)'
alias glfudm='git pull --force upstream $(zsh-gacp-devBranch upstream):$(zsh-gacp-mainBranch upstream)'
alias glrfomd='git pull --rebase --force origin $(zsh-gacp-mainBranch):$(zsh-gacp-devBranch)'
alias glrfudm='git pull --rebase --force upstream $(zsh-gacp-devBranch upstream):$(zsh-gacp-mainBranch)'
alias glfodm='git pull --force origin $(zsh-gacp-devBranch):$(zsh-gacp-mainBranch)'
alias glfumd='git pull --force upstream $(zsh-gacp-mainBranch upstream):$(zsh-gacp-devBranch)'
alias glrfodm='git pull --rebase --force origin $(zsh-gacp-devBranch):$(zsh-gacp-mainBranch)'
alias glrfumd='git pull --rebase --force upstream $(zsh-gacp-mainBranch upstream):$(zsh-gacp-devBranch)'
alias gpfo='git push --force origin'
alias gpfu='git push --force upstream'
alias gpfom='_m=$(zsh-gacp-mainBranch); git push --force origin $_m:$_m; unset _m'
alias gpfod='_d=$(zsh-gacp-devBranch); git push --force origin $_d:$_d; unset _d'
alias gpfum='_m=$(zsh-gacp-mainBranch upstream); git push --force upstream $_m:$_m; unset _m'
alias gpfud='_d=$(zsh-gacp-devBranch upstream); git push --force upstream $_d:$_d; unset _d'
alias gpfomd='git push --force origin $(zsh-gacp-mainBranch):$(zsh-gacp-devBranch)'
alias gpfodm='git push --force origin $(zsh-gacp-devBranch):$(zsh-gacp-mainBranch)'
alias gpfumd='git push --force upstream $(zsh-gacp-mainBranch upstream):$(zsh-gacp-devBranch upstream)'
alias gpfudm='git push --force upstream $(zsh-gacp-devBranch upstream):$(zsh-gacp-mainBranch upstream)'
alias gpuat='git push upstream --all && git push upstream --tags'
alias gpfoat='git push -f origin --all && git push -f origin --tags'
alias gpfuat='git push -f upstream --all && git push -f origin --tags'
alias grom='git reset --hard origin/$(zsh-gacp-mainBranch)'
alias grum='git reset --hard upstream/$(zsh-gacp-mainBranch upstream)'
alias grod='git reset --hard origin/$(zsh-gacp-devBranch)'
alias grud='git reset --hard upstream/$(zsh-gacp-devBranch upstream)'
alias gfo='git fetch origin'
alias gfu='git fetch upstream'
alias gfod='git fetch origin $(zsh-gacp-devBranch)'
alias gfud='git fetch upstream $(zsh-gacp-devBranch upstream)'
alias gfom='git fetch origin $(zsh-gacp-mainBranch)'
alias gfum='git fetch upstream $(zsh-gacp-mainBranch upstream)'
alias gffo='git fetch --force origin'
alias gffu='git fetch --force upstream'
alias gffod='git fetch --force origin $(zsh-gacp-devBranch)'
alias gffud='git fetch --force upstream $(zsh-gacp-devBranch upstream)'
alias gffom='git fetch --force origin $(zsh-gacp-mainBranch)'
alias gffum='git fetch --force upstream $(zsh-gacp-mainBranch upstream)'
alias gj='git pull --rebase --autostash -v'
alias gs="git difftool -y -x 'printf \"\\x1b[1;4m\$REMOTE\\x1b[0m\\x0a\";sdiff --expand-tabs -w '\$COLUMNS "
alias grhs='git reset --soft'
alias grhm='git reset --mixed'
alias gpf='git push --force'
alias gdh='git diff -w HEAD'
alias bk='git clean -dff && git reset --hard HEAD && git clean -dff'
alias bki='git clean -dffx && git reset --hard HEAD && git clean -dffx'
alias glf='git pull --force'
alias gla='git pull --all'
alias glat='git pull --all --tags'
alias glt='git pull --tags'
alias glot='git pull origin --tags'
alias glfot='git pull --force origin --tags'
alias glut='git pull upstream --tags'
alias glfut='git pull --force upstream --tags'
alias glfa='git pull --force --all'
alias glfat='git pull --force --all --tags'
alias glft='git pull --force --tags'
alias gld='git log --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --stat -p '
alias glaa='git log --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --stat -p --all'
alias glz='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --stat -p'
alias glzz='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --stat -p --all'
alias gacp="git add . && git commit -m '' && git push"
alias gac="git add . && git commit -m ''"
alias gbv='git branch -a -vv'
alias allRebase='git rebase -i $(git rev-list --max-parents=0 HEAD)'
alias gt='git tag'
alias gfa='git fetch --all --prune --tags'
alias gffa='git fetch -f --all --prune --tags'
#}}}***********************************************************
#{{{ MARK:git fn
#**************************************************************
(( $+functions[zpwrExists] )) ||
zpwrExists(){
#alternative is command -v
type "$1" >/devBranch/null 2>&1
}
(( $+functions[zpwrIsGitDir] )) ||
zpwrIsGitDir(){
command git rev-parse --git-dir 2> /devBranch/null 1>&2
}
(( $+functions[zpwrLoggErr] )) ||
zpwrLoggErr(){
test -z "$1" && zpwrLoggErr "need arg" >&2 && return 1
{
printf "ERROR: $@"
} >&2
}
(( $+functions[zpwrLoggNotGit] )) ||
zpwrLoggNotGit() {
zpwrLoggErr "$(pwd) is not a git dir"
}
#}}}***********************************************************
#{{{ MARK:ZLE keybind
#**************************************************************
zle -N zsh-gacp-CheckDiff
zle -N zsh-gacp-NoCheck
setopt noflowcontrol
bindkey -M viins '^S' zsh-gacp-NoCheck
bindkey -M vicmd '^S' zsh-gacp-NoCheck
bindkey -M emacs '^S' zsh-gacp-NoCheck
bindkey -M viins '^F^S' zsh-gacp-CheckDiff
bindkey -M vicmd '^F^S' zsh-gacp-CheckDiff
bindkey -M emacs '^F^S' zsh-gacp-CheckDiff
#}}}***********************************************************