-
Notifications
You must be signed in to change notification settings - Fork 0
/
tigrc
354 lines (296 loc) · 12.8 KB
/
tigrc
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# ref:
# https://qiita.com/sfus/items/063797a1dd8fdc7d032f
# https://github.com/jonas/tig/wiki/Bindings
# Generic {{{
# vim-like g binding, 'gp' for git grep
bind generic g none
bind generic gp view-grep
bind generic gg move-first-line
bind generic G move-last-line
# scroll right easily
bind generic <C-H> scroll-left
bind generic <C-L> scroll-right
# redraw, refresh, source tigrc
bind generic <C-R> refresh
bind generic R :source ~/.tigrc
bind generic <Esc>l screen-redraw
# override page content view
bind generic p none
# clipboard
bind generic xx +sh -c "echo -n %(commit) | head -c7 | xsel -ib && echo Commit Clipped!"
bind generic xc +sh -c "echo -n %(commit) | xsel -ib && echo Full Commit Clipped!"
bind generic xt +sh -c "echo -n %(text) | xsel -ib && echo Text Clipped!"
bind generic xT +sh -c "git cat-file -p %(commit) | sed 1,5d | xsel -ib && echo commit message Clipped"
bind generic xrb +sh -c "echo -n %(branch) | xsel -ib && echo Branch Clipped!"
bind generic xrB +sh -c "echo -n %(remote):%(branch) | xsel -ib && echo Remote Branch Clipped!"
bind generic xrt +sh -c "echo -n %(tag) | xsel -ib && echo tag Clipped"
bind generic xf +sh -c "echo -n %(file) | xsel -ib && echo File Clipped"
bind generic xb +sh -c "echo -n %(blob) | head -c7 | xsel -ib && echo Blob Clipped"
bind main xb +sh -c "echo -n %(branch) | xsel -ib && echo Branch Clipped"
bind generic xB +sh -c "echo -n %(blob) | xsel -ib && echo Full Blob Clipped"
## Remote
bind generic Uv +sh -c "git remote -v | grep %(remote)"
bind generic UV >sh -c "git remote -vv | tig"
bind generic UA @git remote add "%(prompt New Github remote name: )" [email protected]:"%(prompt User/Repo: )"
bind generic Ua @git remote add "%(prompt New remote name: )" "%(prompt Remote url: )"
bind generic Ur @git remote rename "%(prompt Rename which remote?: )" "%(prompt Enter new remote name: )"
bind generic U! @git remote remove "%(prompt Remove which remote?: )"
bind generic US @git remote set-url "%(prompt Set url for which remote?: )" [email protected]:"%(prompt User/Repo: )"
bind generic Us @git remote set-url "%(prompt Set url for which remote?: )" "%(prompt New url: )"
bind generic Uf ?git fetch "%(prompt Fetch from which remote?: )"
bind generic UU ?git remote update --prune
bind generic Ut ?sh -c "git pull %(remote) --tags --force"
bind generic UT ?sh -c "git pull %(prompt Which remote? ) --tags --force"
bind generic Uprf ?git fetch "%(prompt Fetch from which remote? )" pull/"%(prompt PR number: )"/head:pr
bind generic UP !git swapProtocol
# toggle case sensitive for search
bind generic w :toggle ignore-case
# see reflog, reset refernece
bind generic gl ?git checkout HEAD@{"%(prompt Enter HEAD@{} number: )"}
bind generic gL ?git reset --hard HEAD@{"%(prompt Enter HEAD@{} number: )"}
bind reflog c ?git checkout %(commit)
# highlight diff without +/-
# set diff-show-signs = false
# set diff_column_highlight = ALL
#set diff-highlight = true
# misc settings
set ignore-case = true
set line-graphics = utf-8
set refresh-mode = auto
# }}}
# View: Main {{{
set main-view = \
date:relative \
author:abbreviated \
id \
commit-title:graph=v2,refs=true
# override graph toggling
bind main G move-last-line
bind main ` :toggle commit-title-graph
bind main F none
bind generic <C-T> :toggle commit-title-refs
# edit tigrc
bind main e >sh -c "$EDITOR ~/.tigrc && source ~/.tigrc"
# move
bind main <C-J> :move-next-merge
bind main <C-K> :move-prev-merge
bind main gh :goto HEAD
bind main ; :goto %(commit)^2 # go to second parent
bind main 1 +sh -c "git rev-list --all --children | \
grep '^%(commit)' | \
awk '{print $2}') | \
xsel -ib && echo first children" # useless now
bind main J @sh -c 'BRANCH=$(git branch --show-current) && git checkout %(commit) && git branch --force $BRANCH %(commit) && git checkout $BRANCH'
# branch
bind main b none
bind main bn @git branch "%(prompt Enter branch name: )" %(commit)
bind main bN @git branch %(branch) --track %(remote)/%(branch)
bind main bu +sh -c 'git branch --set-upstream-to="%(prompt Set remote: )"/%(branch) %(branch) || echo Fails'
bind main bU +sh -c 'git branch --set-upstream-to="%(prompt Set remote/branch: )" %(branch) || echo Fails'
bind main bc @git checkout -b "%(prompt Checkout at new branch: )" %(commit)
bind generic bd @git branch -d "%(prompt Delete branch: )"
bind main bbd @git branch -d %(branch)
bind generic bD ?>git branch -D "%(prompt Delete branch anyway: )"
bind main bbD ?>git branch -D %(branch)
bind main brd ?git branch -rd %(remote)/%(branch)
bind main bv +sh -c "git branch -vv | grep %(branch)"
bind main bV >sh -c "git branch -vv | tig"
bind main bm @git branch -m %(branch) "%(prompt New branch name: )"
bind main bM @git branch --force "%(prompt Move which branch to here? )" %(commit)
bind main c @sh -c "git branch --points-at=%(commit) | \
sed -n '/^*/ {n;p}' | \
{ cat; echo %(commit); } | \
head -1 | \
xargs git checkout"
bind main bo >tig %(branch)
bind main bO >tig "%(prompt Enter branch: )"
bind main ba >tig --all
bind main bR !git reorder
# commit
bind main a !>git commit --amend --allow-empty
bind main E >git commit --allow-empty -m "%(prompt Empty commit, enter message: )"
# merge
bind main m ?@git merge %(commit)
bind main M ?@git merge %(branch) --no-ff
bind main gm ?@git merge %(remote)/%(branch) # merge with current remote
bind main gM ?@git merge %(remote)/%(branch) --no-ff # merge-no-ff with current remote
bind main gs ?@git merge %(branch) --squash
# push
bind main p none # override default pager binding
bind main pp ?bash -c 'git push || git remote update --prune'
bind main pP ?git push -u %(remote) %(branch):%(branch)
bind main pr ?git push -u '%(prompt Which remote? )' %(branch):%(branch)
bind main pfr ?git push -u '%(prompt Force push to which remote? )' %(branch):%(branch) -f
bind main pR ?git push -u %(remote) %(branch):%(branch)
bind main pc ?git push -u '%(prompt Which remote? )' %(commit):%(branch)
bind main pF ?git push --force
bind main pd ?git push %(remote) :%(branch)
bind generic pD ?git push '%(prompt Delete from which remote? )' :'%(prompt Which reference? )'
# fetch
bind main <C-F> ?git fetch %(remote)
bind main gf ?git fetch '%(prompt Which remote? )' # Go to Fetch a specific remote
bind main gF ?git fetch '%(prompt Which remote? )' '%(prompt Which branch? )'
bind main pu !git pull '%(prompt Pull from witch remote? )' %(branch)
bind main pU ?git pull --rebase
# reset/rebase/revert
bind main uu ?git reset %(commit) --soft
bind main uh ?git reset %(commit) --hard
bind main uS ?sh -c "git reset %(commit) && git stash push -m 'deprecated from reset'" # reset and stash the changes
bind main B !?git rebase -i %(commit)
bind main bbi !?git rebase -i --root
bind main gb !?git rebase --onto '%(prompt Rebase onto which branch? )' %(commit) %(repo:head)
bind main gB !?git rebase --rebase-merges -i %(commit)
bind main ! ?git revert %(commit)
# tag
bind generic Tn @git tag "%(prompt New tag, please enter tag name: )" %(commit)
bind generic TN !git tag "%(prompt Annotated tag, please enter the name: )" %(commit) -a
bind generic TSN !git tag "%(prompt Signed Annotated tag, please enter the name: )" %(commit) -s
bind generic Tm @sh -c 'git tag -d %(tag) && git tag "%(Rename tag to? )" %(commit)'
bind generic TM @sh -c 'git cat-file -p %(tag) |\
sed -n \'6,$p\' |\
(git tag -d %(tag) && git tag "%(prompt Rename tag into? )" -a -F -) > /dev/null'
bind generic Tc !sh -c 'git tag %(tag) %(tag)^{} -f -m \"$(git tag %(tag) -n10)\" -e'
bind generic Tl !sh -c 'git ls-remote --tags %(remote) | grep %(tag)'
bind generic Ts >tig show %(tag)
bind generic Td @git tag -d "%(prompt Delete which tag? )"
bind generic Tpr ?git push "%(prompt Push to which Remote? )" %(tag)
bind generic Tpd ?git push %(remote) :%(tag)
bind generic TpD ?git push "%(prompt Which remote? )" -d %(tag)
bind generic TTd @git tag -d %(tag)
bind generic pt ?git push --tags
bind generic pT ?git push %(remote) %(tag)
# search in history
bind main S none
bind main Sl >sh -c 'git log --pretty=raw -G "%(prompt Lines contains: )" | tig --pretty=raw'
bind main Sf >sh -c 'git log --pretty=raw -- "*%(prompt Filename: )*" --pretty=raw | tig --pretty=raw'
# submodule
bind main Zu ?>git submodule update
bind main Zi ?>git submodule init
# show diff based on revision
bind main . >sh -c "git diff --patch-with-stat %(commit) | tig show"
bind main > >sh -c "git diff --patch-with-stat %(commit) --no-prefix -U1000 | tig show"
# make patches
bind main PP ?>git format-patch %(commit)
bind main P1 ?>git format-patch -1 %(commit)
# Hub
bind main i @hub browse -- commit/%(commit)
bind main I >sh -c "hub issue | tig"
# Misc
## Statistics
bind main gc >sh -c 'cloc --git %(commit) | tig'
# note
#bind generic gnn !git notes edit %(commit)
#bind generic gnr !git notes remove %(commit)
# }}}
# blame view {{{
bind blame m >tig --follow -- %(file)
bind blame . >sh -c "git diff --patch-with-stat %(ref) -- %(file) | tig"
bind blame > >sh -c "git diff --patch-with-stat %(ref) --no-prefix -U1000i -- %(file) | tig"
set blame-view = author:abbreviated date:relative id:yes,color line-number:yes text
# }}}
# blob view {{{
bind blob m >tig --follow -- %(file)
# }}}
# status view {{{
bind status j :/^[MCADRUT?]
bind status k :?^[MCADRUT?]
# use vscode to edit a file
bind status E !>code %(file)
# update index
bind status A @git add .
bind status R @git reset
bind status gu @git update-index --assume-unchanged %(file) # ignore file
bind status gn @sh -c "git ls-files -v | grep '^h ' | cut -d' ' -f2 | \
xargs git update-index --no-assume-unchanged" # resume ignored files
# stash
bind status s ?>git stash
bind status S @git stash push -m "%(prompt Enter stash name: )"
bind status gs !git stash --keep-index
bind status gS !git stashstaged
bind status <C-S> >sh -c 'git stash && git stash apply stash@{0}'
# quick commit
bind status c @git commit -m "%(prompt Enter commit message: )"
bind status a !>git commit --amend --allow-empty
bind status p ?>sh -c "git commit -m 'Update' && git push" # quick push
bind status d ?>rm %(file)
bind status D ?>git clean -df
# solve conflict
bind status M none
bind status Mo @git checkout --ours -- %(file)
bind status U ?>git reset --hard
bind status gc @git clean --force
bind status Ba @git rebase --abort
bind status Bc @git rebase --continue
bind status Ma @git merge --abort
bind status Mc @git merge --continue
bind status <F4> !sh -c "git difftool -y \"$(git rev-parse --show-toplevel)/%(file)\""
# apply patch file
bind status <C-O> ?git am %(file)
# }}}
# stash view {{{
bind stash a ?git stash apply %(stash)
bind stash d ?>git stash drop %(stash)
bind stash p ?>git stash pop %(stash)
bind stash i +git rev-parse %(stash)
# rename a stash
bind stash n @sh -c "git stash drop %(stash) | \
awk '{print $3}' | \
tr -d '()' | \
xargs git stash store -m '%(prompt Enter stash name: )'"
# }}}
# stage view {{{
bind stage <C-J> :/^@@
bind stage <C-K> :?^@@
bind stage <Esc>j :/^diff --(git|cc)
bind stage <Esc>k :?^diff --(git|cc)
# }}}
# tree view {{{
set tree-view = author:abbreviated date:relative mode file-size:units id:no file-name
bind tree l enter
bind tree h back
bind tree t +git cat-file -p %(commit)
bind tree d ?rm %(file)
bind tree m >tig --follow -- %(file)
bind tree xt +sh -c "git rev-parse %(commit)^{tree} | xsel -ib -o | awk '{print \"Tree Clipped\", $1}'"
bind tree c NONE
bind tree cp +sh -c "git cat-file -p %(blob) >%(file) && echo File copied to %(file)"
bind tree . >sh -c "git diff --patch-with-stat %(ref) -- %(file) | tig"
# }}}
# refs view {{{
bind refs b none
bind refs r none
bind refs C none
bind refs c @git checkout %(ref)
bind refs <Esc>f ?git fetch --all
bind refs <C-F> ?git fetch %(remote)
bind refs F ?git fetch %(remote) %(ref)
bind refs pr ?git push '%(prompt Push to which remote? )' %(ref):%(ref)
bind refs pd ?git push %(remote) :%(ref)
bind refs pD ?git push '%(prompt Delete from which remote? )' :%(ref)
bind refs rd ?git branch --remotes -D %(remote)/%(ref)
bind refs . >sh -c "git diff --patch-with-stat %(branch) | tig"
bind refs > >sh -c "git diff --patch-with-stat %(branch) --prefix -U1000 | tig"
# get the remotes contains given tag
bind refs r none
bind refs rr !sh -c "git remote | xargs -I{} sh -c 'echo {} $(git ls-remote {} %(ref))' | grep -E ' ' | cut -d' ' -f1"
# }}}
# log view {{{
bind log <C-J> :/^commit
bind log <C-K> :?^commit
# }}}
# diff view {{{
bind diff <C-J> :/^@@
bind diff <C-K> :?^@@
bind diff <Esc>j :/^diff --(git|cc)
bind diff <Esc>k :?^diff --(git|cc)
bind diff m >tig -- %(file)
bind diff u @git checkout %(commit)^ -- %(file)
# }}}
# help view {{{
# edit tigrc
bind help e >sh -c "$EDITOR ~/.tigrc"
# }}}
# color {{{
color diff-chunk white magenta
color cursor black green bold
# }}}