-
Notifications
You must be signed in to change notification settings - Fork 5
/
gitconfig.sh
executable file
·71 lines (53 loc) · 2.08 KB
/
gitconfig.sh
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
#!/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
op_ensure_signed_in
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 running_macos; then
echo " → enabling running_macos specific settings"
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/running_macos
if test -d '/Applications/1Password.app/'; then
echo " → enabling 1password ssh key signing"
op_ensure_signed_in
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/1password
git config --file ~/.gitconfig.d/1password gpg.format ssh
git config --file ~/.gitconfig.d/1password gpg.ssh.program "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"
git config --file ~/.gitconfig.d/1password commit.gpgsign true
signing_key=$(op item list --tags 'ssh signing','work' --format=json | op item get - --fields 'public key')
if [[ -n "$signing_key" ]]; then
git config --file ~/.gitconfig.d/1password user.signingkey "$signing_key"
else
echo "uh oh, couldn't find an SSH key in 1password to use" >&2
exit 1
fi
fi
fi
if fzf_available; then
echo " → enabling fzf specific settings"
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/fzf
fi
code=$(vscode_command)
if [ -n "${code}" ]; then
echo " → enabling vscode specific settings"
if running_macos; then
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/vscode-macos
else
git config --file ~/.gitconfig.local mergetool.code.cmd "${code}"
fi
git config --file ~/.gitconfig.local --add include.path ~/.gitconfig.d/vscode
fi