-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdot_gitconfig.tmpl
More file actions
281 lines (246 loc) · 10.5 KB
/
Copy pathdot_gitconfig.tmpl
File metadata and controls
281 lines (246 loc) · 10.5 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
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
; vim: set ft=gitconfig:
{{ $agent := and (hasKey . "agent") .agent -}}
{{ if $agent -}}
[user]
name = {{ .fullname }}
email = {{ .email }}
; An SSH key used only for commit signing. It is registered in GitHub
; as a "Signing Key" (not an "Authentication Key") so it cannot be used
; to push, pull, or log in. Generated by run_once_370_configure_agent.sh
signingkey = ~/.ssh/agent_signing_key.pub
[github]
user = {{ .github_username }}
; This machine reaches repos across several GitHub orgs. A fine-grained PAT
; belongs to a single org, so a per-org credential helper hands git the right
; token based on the repo path (github.com/<org>/...). No manual token
; switching. Tokens live in ~/.config/gh-org-tokens (mode 600, not in this
; repo). useHttpPath makes git pass the path so the helper can see the org.
; The empty helper line first clears any inherited helper so ours is the only
; one consulted for github.com. See ~/.local/bin/git-credential-gh-org.
[credential "https://github.com"]
helper =
helper = "!~/.local/bin/git-credential-gh-org"
useHttpPath = true
; SSH is not authenticated on this machine: the only key here is a commit
; signing key, which GitHub refuses for fetch and push. So rewrite every SSH
; form of a github.com remote to HTTPS, where the helper above supplies a
; token. This matters for remotes we do not control: a dependency pinned to
; git+ssh://git@github.com/... (pip, uv, poetry, go get) would otherwise fail
; with "Permission denied (publickey)". Git applies the rewrite before it
; connects, so those tools need no change.
[url "https://github.com/"]
insteadOf = ssh://git@github.com/
insteadOf = git@github.com:
insteadOf = git://github.com/
{{ else if not .shared_machine -}}
[user]
name = {{ .fullname }}
email = {{ .email }}
signingkey = {{ .gpg_fingerprint }}
[github]
user = {{ .github_username }}
{{- end }}
; The file below can contain conditional includes that customizes the [user]
; stanza according to the current path. For example, it might contain:
;
; [includeIf "gitdir:~/src/github.com/company-name/"]
; path = ~/.gitconfig-company-name
;
; The above means: if the current repo is a child of ~/src/../company-name,
; include ~/.gitconfig-company-name. In turn, the file ~/.gitconfig-company-name
; might contain:
;
; [user]
; email = myemailaddress@company-name.com
; signingKey = <gpg-signing-key-associated-with-company-email>
;
; For more info on what the file can contain, see https://git-scm.com/docs/git-config
;
; NOTE: The file below is ensured present by run_000_ensure_files.sh.tmpl
[include]
path = ~/.gitconfig.local
[core]
whitespace = trailing-space,space-before-tab
excludesfile = ~/.gitignore_global
editor = ~/bin/nvim
pager = delta
# https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more
attributesfile = ~/.gitattributes
[user]
# Avoid trying to guess defaults for user.name and user.email
# https://git-scm.com/docs/git-config#Documentation/git-config.txt-useruseConfigOnly
useConfigOnly = true
[init]
templatedir = ~/.git-template
defaultBranch = main
[commit]
gpgsign = true
[tag]
gpgsign = true
[push]
default = upstream
useForceIfIncludes = true
[pull]
ff = only
[apply]
whitespace = strip
[pager]
color = true
[status]
color = true
[rebase]
autoStash = true
[gpg]
{{- if $agent }}
format = ssh
{{- else if eq .chezmoi.os "linux" }}
program = gpg2
{{- else if eq .chezmoi.os "darwin" }}
program = gpg
{{- end }}
[color]
ui = auto
branch = auto
diff = auto
status = auto
[color "branch"]
current = green reverse
local = green
remote = red
[color "diff"]
meta = yellow
frag = magenta
old = red
new = green
[color "status"]
added = yellow
changed = green
untracked = cyan
[alias]
cs = commit --signoff
# Aliases used by other aliases below
# From https://github.com/fcsonline/dotfiles/blob/7211d48fb06eec96a415063cf07df240096bc9bf/git/gitconfig#L32-L33
recent = !git for-each-ref --sort=-committerdate --format='%(refname:short)' | head -n 100
util-fixit = "!f() { git commit --fixup=$1 && git add . && git stash >/dev/null && GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash $1~1 && git stash pop >/dev/null; }; f"
# From https://github.com/fcsonline/dotfiles/blob/7211d48fb06eec96a415063cf07df240096bc9bf/git/gitconfig#L32-L33
co = !BRANCH=`git recent | fzf` && git checkout ${BRANCH}
# From https://github.com/fcsonline/dotfiles/blob/7211d48fb06eec96a415063cf07df240096bc9bf/git/gitconfig#L32-L33
fixup = !HASH=`git log --pretty=oneline | head -n 100 | fzf` && git util-fixit `echo ${HASH} | awk '{ print $1 }'`
# Fuzzy cherry pick
chp = !HASH=`git log --all --pretty=oneline --color | head -n 100 | fzf --ansi ` && git cherry-pick `echo ${HASH} | awk '{ print $1 }'`
abort-cherry-pick = cherry-pick --abort
fa = fetch --all
far = fetch --all --recurse-submodules
unstage = reset HEAD --
undo = reset --soft HEAD^ # Undo the last commit and put it back in the index
rh = reset --hard # Clear all changes in workspace and index
tree = log --graph --oneline --decorate --color --format='%C(auto)%h %C(green)%as%C(auto) %C("#666666")%an%C(auto)%d %s%C(reset)'
t = tree
ta = t --all
ti = t --format='%C(auto)%h %C(green)%ai%C(auto)%d %C("#666666")%an%C(auto)%d %s%C(reset)' # Tree, using ISO8601 format
tai = ti --all
tr = t --format='%C(auto)%h %C(green)%ar%C(auto)%d %C("#666666")%an%C(auto)%d %s%C(reset)' # Tree, using relative times
tar = tr --all
ts = t --source --format='%C(auto)%h %C(green)%as%C(auto) %C("#666666")%an%C(auto)%d %s %C("#666666")[%S] %C(reset)'
tas = ts --all
# Branch stats
stats = log --decorate --color --format='%n%C(auto)%h %C(green)%ai%C(auto) %C("#666666")%an%C(auto)%d %s%C(reset)' --compact-summary
s = stats
sa = stats --all
# fzf goodness! From https://medium.com/hackernoon/be-125-more-efficient-with-git-60556a1ce971
checkout-fzf = !BRANCH=`git recent | fzf` && git checkout ${BRANCH}
add-fzf = !FILES=`git status -s | awk '{ print $2 }' | fzf -x -m` && git add --all ${FILES}
fix-fzf = !HASH=`git log --pretty=oneline | head -n 100 | fzf` && git util-fixit `echo ${HASH} | awk '{ print $1 }'`
show-fzf = !HASH=`git log --pretty=oneline | head -n 100 | fzf` && git show `echo ${HASH} | awk '{ print $1 }'`
log-fzf = !HASH=`git log --pretty=oneline | head -n 100 | fzf` && echo ${HASH} | awk '{ print $1 }' | xargs echo -n | pbcopy
rebase-fzf = !HASH=`git log --pretty=oneline | head -n 100 | fzf` && git rebase -i `echo ${HASH} | awk '{ print $1 }'`^
vim-fzf = !FILES=`git status -s | awk '{ print $2 }' | fzf -x -m` && vim -O ${FILES}
grep-fzf = !sh -c 'FILES=`git grep -l -A 0 -B 0 $1 $2 | fzf -x -m` && vim -O `echo ${FILES} | cut -d':' -f1 | xargs`' -
vimlog-fzf = !HASH=`git log --pretty=oneline | head -n 50 | fzf` && HASHZ=`echo ${HASH} | awk '{ print $1 }'` && FILES=`git show --diff-filter=d --pretty='format:' --name-only $HASHZ | grep -v -e '^$' | fzf -x -m` && vim -O ${FILES}
reset-fzf = !HASH=`git log --pretty=oneline | head -n 50 | fzf` && git reset --soft `echo ${HASH} | awk '{ print $1 }'`^
[interactive]
# https://git-scm.com/docs/git-config#Documentation/git-config.txt-interactivediffFilter
diffFilter = delta --color-only
# git-delta https://github.com/dandavison/delta
# See: delta --help | less -R
[delta]
navigate = true # use n and N to move between diff sections
side-by-side = false
blame-code-style = syntax
dark = true
syntax-theme = "Visual Studio Dark+"
hyperlinks = true
features = line-numbers decorations highlight-moved-code
[delta "line-numbers"]
line-numbers = true
line-numbers-left-format = "{nm:>4}┊"
line-numbers-left-style = "#666666"
line-numbers-right-format = "{np:>4}│"
line-numbers-right-style = "#666666"
[delta "decorations"]
# Named ANSI colors (yellow, white) render through the terminal's own
# 16-color palette, which differs between a plain shell and Neovim's
# built-in :terminal (Neovim maps them to the colorscheme's
# g:terminal_color_* — kanagawa-dragon here). Using explicit hex keeps
# the theme identical everywhere. These hex values are kanagawa-dragon's
# yellow (#c4b28a) and white (#C8C093).
file-style = "#c4b28a"
file-decoration-style = dim "#c4b28a" ol ul
file-added-label = [add]
file-copied-label = [cop]
file-modified-label = [mod]
file-removed-label = [del]
file-renamed-label = [ren]
hunk-header-decoration-style = none
hunk-header-style = dim syntax
hunk-label = ""
minus-style = dim "#C8C093" "#321313"
plus-style = syntax "#132E13"
zero-style = dim syntax
[delta "highlight-moved-code"]
# Adjust zebra style for moved lines. In order for this
# to work, delta.features above must enable this section
# and diff.colorMoved must be set to zebra.
#
# Adapted from https://github.com/chtenb/delta/blob/master/themes.gitconfig
map-styles = \
bold purple => dim "#C8C093" "#3A142D", \
bold blue => dim "#C8C093" "#491939", \
bold cyan => syntax "#002A2A", \
bold yellow => syntax "#0A3939"
[diff]
# Use zebra style coloring for moved code. This is needed
# so that [delta "highlight-moved-code"] will have an effect.
#
# See: https://dandavison.github.io/delta/color-moved-support.html
colorMoved = zebra
# from: https://medium.com/@angielohqh/git-merging-with-3-way-vimdiff-5c59d9c62268
[difftool "vimdiff"]
cmd = vimdiff \"$LOCAL\" \"$REMOTE\"
# from: https://gist.github.com/tekin/12500956bd56784728e490d8cef9cb81
[diff "rspec"]
xfuncname = "^[ \t]*((RSpec|describe|context|it|before|after|around|feature|scenario|background)[ \t].*)$"
[diff "ini"]
xfuncname = "^\\[.*\\]$"
[diff "gherkin"]
xfuncname = "^ +(Scenario( Outline)?:.*)$"
[diff "no-hunk-header"]
xfuncname = "^91C4624E-2EE4-4AE5-9E0D-6C02AE8E9701$"
[merge]
tool = neovim
[mergetool]
keepBackup = false
# from: https://medium.com/@angielohqh/git-merging-with-3-way-vimdiff-5c59d9c62268
[mergetool "vimdiff"]
cmd = vimdiff \"$LOCAL\" \"$MERGED\" \"$REMOTE\"
[mergetool "neovim"]
cmd = nvim -d \"$LOCAL\" \"$MERGED\" \"$REMOTE\"
[filter "media"]
required = true
clean = git media clean %f
smudge = git media smudge %f
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true