forked from johngrib/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitconfig
284 lines (280 loc) · 11.5 KB
/
.gitconfig
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
; include file sample
;
; file : ~/.gitconfig
; [user]
; name = John Grib
; email = johngrib82@gmail.com
; signingkey = 1234ABCDE
; [commit]
; gpgsign = true
; [include]
; path = ~/dotfiles/.gitconfig
[alias]
alias-basic = "!#----------------------------------------------------------;\n\
git alias | head -7"
ci = commit
co = checkout
sw = switch
re = restore
s = status -s
assume = update-index --assume-unchanged
assumed = "!git ls-files -v | grep ^h | cut -c 3-"
unassume = update-index --no-assume-unchanged
alias-log = "!#----------------------------------------------------------;\n\
git alias | egrep 'log|commit-'"
commit-select = "!# Select a commit hash from log graph.;\n\
git l \
| fzf -m --ansi --layout=reverse --preview=\"echo {} | sed 's/^[*| ]*//g' | cut -d' ' -f1 | xargs git show --color=always \" \
| sed 's/^[*| ]*//g' | cut -d' ' -f1"
c-s = "!git commit-select"
commit-copy = "!# Select & copy a commit hash from log graph.;\n\
git commit-select | tr -d '\n' | pbcopy && echo Copied: `pbpaste`;"
c-c = "!git commit-copy"
l = "log \
--color --graph --decorate \
--date=format:'%Y-%m-%d' \
--abbrev-commit \
--pretty=format:'%C(red)%h%C(auto)%d %s %C(green)(%cr)%C(bold blue) %an'"
ld = "log \
--color --graph --decorate \
--date=format:'%Y-%m-%d %H:%M:%S' \
--abbrev-commit \
--pretty=format:'%C(red)%h%C(auto)%d %s %C(green)(%ad)%C(bold blue) %an'"
ll = "log \
--color --graph --decorate \
--date=format:'%Y-%m-%d' \
--abbrev-commit \
--pretty=format:'%C(red)%H%C(auto)%d %s %C(green)(%cr)%C(bold blue) %an'"
lld = "log \
--color --graph --decorate \
--date=format:'%Y-%m-%d %H:%M:%S' \
--abbrev-commit \
--pretty=format:'%C(red)%H%C(auto)%d %s %C(green)(%ad)%C(bold blue) %an'"
lh = "!# Show log graph | head \n\
f() { \
if [ $# = 0 ]; then \
git l | head -25; \
else \
git l | head -$1; \
fi; \
echo ''; \
}; f"
ranking = "!# List commit counts of contributors;\n\
git shortlog -sn"
alias-branch = "!#----------------------------------------------------------;\n\
git alias | egrep '[bB]ranch'"
b0 = "!# Print current branch.;\n\
git branch | awk '/^\\*/{print $2}'"
back = "!# Back up current branch.;\n\
echo created new branch: backup-`git b0`;\
git branch backup-`git b0`"
bb = "!# Branch tools. Type 'git bb help'.;\n\
f() { \n\
if [ $# = 0 ]; then \
git branch-select | xargs git checkout; \
elif [ $1 = 'help' ]; then \
echo 'git bb : Select and checkout branch'; \
echo 'git bb c, clean : Clean all merged branches'; \
echo 'git bb d, D : Delete seleted branches(D: force)'; \
echo 'git bb l, list : List branches excluding the current branch'; \
echo 'git bb m, merged : List merged branches excluding the current and master branches'; \
elif [ $1 = 'd' -o $1 = 'D' ]; then \
git branch -$1 $(git bb list | fzf -m | awk '{print $2}'); \
elif [ $1 = 'clean' -o $1 = 'c' ]; then \
git branch-clean; \
elif [ $1 = 'list' -o $1 = 'l' ]; then \
git branch-list; \
elif [ $1 = 'merged' -o $1 = 'm' ]; then \
git branch-merged; \
elif [ $1 = 'select' -o $1 = 's' ]; then \
git branch-select; \
else \
git bb help; \
fi; \
}; f"
branch-clean = "!# Search and delete merged branches.;\n\
curr_hash=`git show -s | head -1 | cut -d ' ' -f2`; \
for branch in `find .git/refs -type f | fzf --ansi -m --preview=\"cat {} | xargs git l\"` ; do \
hash=`cat $branch`; \
if [ $hash = $curr_hash ]; then \
continue; \
fi; \
git ll | egrep $hash -C 1; \
read -p \"Delete $branch? [y|n] \" -r; \
REPLY=${REPLY:-"n"}; \
if [ $REPLY = \"y\" ]; then \
rm $branch; \
echo \"\\033[32m$branch \\033[0mhas been\\033[31m deleted\\033[0m.\n\"; \
fi; \
done"
b-c = "!git branch-clean"
branch-list = "!# List the branches.;\n\
git for-each-ref --sort=-committerdate refs/heads --format='%(HEAD) %(refname:strip=2) | %(committerdate:relative) | %(authorname)' \
| column -ts'|' \
| sed 's/^ /./'"
b-l = "!git branch-list"
branch-list-all = "!# List all branches.;\n\
for branch in `git branch -r --merged | grep -v HEAD`; do echo `git show --format=\"%ci ; %cr ; %an ;\" $branch | head -n 1` $branch; done | sort -r | column -ts';'"
b-la = "!git branch-list-all"
branch-select = "!# Select a branch.;\n\
f() { \
_height=$(stty size | awk '{print $1}');\
git branch-list | fzf --preview \"git l {2} | head -n $_height\" | awk '{print $2}'; \
}; f"
b-s = "!git branch-select"
ch = "!# Branch tools. Same with bb.;\n\
git bb $1"
sync = "!# Sync with a branch with the same name in the remote repo.;\n\
remote=$( \
{ \
git remote -v | egrep '^(origin|upstream)\\s'; \
git remote -v | egrep -v '^(origin|upstream)\\s' | sort; \
} \
| awk '{print $1, $2}' | uniq \
| column -t \
| fzf | awk '{print $1}' \
); \
if ! [ -z $remote ]; then \
git fetch $remote && git reset --hard $remote/`git b0`; \
fi"
update = "!# Synchronize the contents of local files with the repository;\n\
remote=$( \
{ \
git remote -v | egrep '^(origin|upstream)\\s'; \
git remote -v | egrep -v '^(origin|upstream)\\s' | sort; \
} \
| awk '{print $1, $2}' | uniq \
| column -t \
| fzf | awk '{print $1}' \
); \
git stash; git pull --rebase $remote `git b0`; git stash pop;"
alias-stage = "!#----------------------------------------------------------;\n\
git alias | egrep '(add|diff|stage)' -i"
a = "!# Select files and Add them.;\n\
git diff-select | xargs git add"
a-c = "!# Add, Commit.;\n\
git a; git commit"
diff-info = "!# Print diff report.;\n\
fileA=/tmp/git-s-$(uuidgen); \
fileB=/tmp/git-diff-$(uuidgen); \
git s | awk '{print $2,$1}' > $fileA; \
git diff --numstat | awk '{print $3,$1,$2}' > $fileB; \
join -t' ' -a 1 $fileA $fileB | awk '{print $2, \"(+\"$3 \",-\"$4\")\", $1}' | sed 's/(+,-)/./; s/^\\([^?]\\) *\\./\\1 STAGED/' | column -t -s' ' ; \
rm -f $fileA $fileB; \
"
diff-select = "!# Select changed files to add them.;\n\
f() { \
git diff-info \
| egrep -v '[^?] *STAGED ' \
| fzf -m --header \"$(git diff --shortstat)\" --preview \
\"if [[ {1} == '??' ]]; then bat {3}; else git diff --color=always {3}; fi\" \
| awk '{print $3}'; \
}; f"
diff-unselect = "!# Select staged files to unstage them.;\n\
f() { \
git diff-info \
| egrep '[^?] *STAGED ' \
| fzf -m --header \"$(git diff --shortstat)\" --preview \
\"if [[ {1} == '??' ]]; then pygmentize {3}; else git diff --color=always --cached {3}; fi\" \
| awk '{print $3}'; \
}; f"
unstage = "!# Select staged files and Unstage them.;\n\
git diff-unselect | xargs git reset HEAD"
alias-stash = "!#----------------------------------------------------------;\n\
git alias | grep stash"
stash-apply = "!# Select a stash item and Apply it.;\n\
git stash-op apply"
s-a = "!git stash-apply"
stash-drop= "!# Select the stash items and Drop them.;\n\
for sid in $(git stash-select -m) ; do \
git stash drop $sid; \
done;"
s-d = "!git stash-drop"
stash-list = "!# List stash items.;\n\
git stash list --pretty=format:\"%C(red)%gd%C(reset) %C(green)(%cr) %C(reset)%s\""
s-l = "!git stash-list"
stash-pop= "!# Select a stash item and Pop it.;\n\
git stash-op pop"
s-p = "!git stash-pop"
stash-save = "!# Save changes into the stash stack.;\n \
git diff-info; \
read -p \"save message: \" msg; \
git stash save \"$msg\""
s-s = "!git stash-save"
stash-select = "!# Select stash item(s).;\n\
f() { \
git stash-list \
| fzf --ansi $1 --preview \"git stash show -p {1} --color=always\" \
| cut -d' ' -f1; \
}; f"
stash-op = "!#A private stash tool.;\nf() { git stash-select | xargs git stash $1; }; f"
tag-refresh = "!# Re reference tag.;\n \
f() { \
_height=$(stty size | awk '{print $1}');\
tag_name=`git tag | fzf --preview=\"git l {1} | head -n $_height\" `; \
echo $tag_name; \
git tag -d $tag_name; \
git tag $tag_name; \
}; f"
alias-alias = "!#----------------------------------------------------------;\n\
git alias | grep alias"
alias = "!# Prints all aliases.;\n\
git config --list | egrep '^alias.+' | sed -e 's/^alias\\.//' | sed -e 's/^[^=]*=/\\'$'\\033[31m&\\033[(B\\033[m/' | column -t -s'=' | sed 's/!#* *//; s/;$//' | cut -c1-85"
alias-doctor = "!# Check the dependency tools.;\n\
f() { \
if [ $(which pygmentize | wc -l) -lt 1 ]; then \
echo 'Not found : Pygments(pygmentize)'; \
echo ' see : http://pygments.org/'; \
echo ' install : pip3 install Pygments'; \
echo '';\
fi; \
if [ $(which fzf | wc -l) -lt 1 ]; then \
echo 'Not found : fzf'; \
echo ' see : https://github.com/junegunn/fzf#installation'; \
echo ' install(Mac) : brew install fzf'; \
echo ' install(git) : git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf'; \
echo ' ~/.fzf/install'; \
echo '';\
fi; \
}; f"
knot = "!# Merge two commits with 1 depth.;\n\
f() { \
if [ $(git status --short | egrep -v '^\\?' | wc -l) -gt 0 ]; then \
echo '변경사항을 먼저 정리해 주세요.';\
return; \
fi; \
_branch=`git b0`; \
_current=backup-`uuidgen`; \
_knot1=`uuidgen`; \
_knot2=`uuidgen`; \
git tag $_current; \
git switch -c $_knot2 $2; \
git switch -c $_knot1 $1; \
git merge $2 --no-ff; \
git switch $_branch; \
git rebase -i -r $_knot1; \
git branch -D $_knot1; \
git branch -D $_knot2; \
read -p \"Delete backup tag $_current ? [y|n] \" -r; \
REPLY=${REPLY:-"n"}; \
if [ $REPLY = \"y\" ]; then \
git tag -d $_current; \
fi; \
}; f"
[core]
excludesfile = /Users/johngrib/.gitignore_global
editor = /usr/local/bin/nvim
autocrlf = input
precomposeunicode = true
quotepath = false
[diff]
tool = vimdiff
wsErrorHighlight = all
[difftool "vimdiff"]
path = /usr/local/bin/vim
[merge]
tool = meld
trustExitCode = true
[mergetool "vimdiff"]
path = /usr/local/bin/vim
trustExitCode = true