-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgitconfig.sh
More file actions
executable file
·91 lines (73 loc) · 2.62 KB
/
gitconfig.sh
File metadata and controls
executable file
·91 lines (73 loc) · 2.62 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
#!/usr/bin/env bash
set -e
# shellcheck source=./functions.sh
source functions.sh
echo "🔨 rebuilding ~/.gitconfig.local"
rm -f ~/.gitconfig.local
rm -f ~/.gitconfig.d/1password
mkdir -p ~/.gitconfig.d
if [ -d ~/workspace ]; then
echo " → enabling maintenance for repositories"
for git_dir in $HOME/workspace/*/.git; do
repo_dir=$(dirname "$git_dir")
git config --file ~/.gitconfig.local --add maintenance.repo "$repo_dir"
done
fi
if command_available delta; then
echo " → enabling delta for pager"
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/delta
fi
if command_available gh; then
echo " → enabling gh credential helper"
gh_path=$(which gh)
for remote in https://github.com https://gist.github.com; do
git config --file ~/.gitconfig.local "credential.$remote.helper" "!$gh_path auth git-credential"
done
fi
if running_macos; then
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/macos
fi
signing=false
case "$DOTPICKLES_ROLE" in
personal)
echo " → using personal identify for git"
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/personal-identity
if running_macos && test -d '/Applications/1Password.app/'; then
echo " → enabling 1password ssh key signing"
signing=true
op_ensure_signed_in
git config --file ~/.gitconfig.local gpg.ssh.program "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"
signing_key=$(op item list --tags 'ssh signing','home' --format=json | op item get - --fields 'public key')
if [[ -n "$signing_key" ]]; then
git config --file ~/.gitconfig.local user.signingkey "$signing_key"
else
echo "uh oh, couldn't find an SSH key in 1password to use" >&2
exit 1
fi
fi
;;
work)
echo " → using work identify for git"
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/work-identity
echo " → enabling work ssh key signing"
signing=true
if [ -f "$HOME/.ssh/id_ed25519.pub" ]; then
git config --file ~/.gitconfig.local user.signingkey "$HOME/.ssh/id_ed25519.pub"
fi
;;
*)
echo "Unexpected role: $DOTPICKLES_ROLE"
exit 1
;;
esac
if [ "$signing" = true ]; then
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/signing
fi
if fzf_available; then
echo " → enabling fzf specific settings"
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/fzf
fi
if command_available git-duet; then
echo " → enabling git-duet specific settings"
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/duet
fi