-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·156 lines (130 loc) · 4.63 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·156 lines (130 loc) · 4.63 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
#!/bin/zsh
set -euo pipefail
cd "$(dirname "$0")"
# setup variables
EMAIL="mjburghoffer@gmail.com"
SSH_KEY="$HOME/.ssh/github_personal" # key for github ssh auth
VERIFIER_KEY="$HOME/.ssh/git_verifier" # key for git signed commits
# macOS settings
echo "Set up macOS settings"
defaults write -g KeyRepeat -int 1
defaults write -g InitialKeyRepeat -int 15
# install xcode command line tools (needed by brew)
XCODE_SELECT_STATUS=0
xcode-select -p > /dev/null 2>&1 || XCODE_SELECT_STATUS=$?
if [[ $XCODE_SELECT_STATUS != 0 ]]; then
echo "Installing Xcode command line tools"
xcode-select --install > /dev/null 2>&1 || true
fi
# install + set up brew
BREWPATH=""
ARCH=$(arch)
if [ "$ARCH" = "arm64" ]; then
BREWPATH="/opt/homebrew/bin/brew"
else
BREWPATH="/usr/local/bin/brew"
fi
if [ ! -f "$BREWPATH" ]; then
echo "Installing brew because '$BREWPATH' does not exist"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
echo "Set up brew shellenv"
eval "$("$BREWPATH" shellenv)"
# install stuff
brew update --quiet
brew install git-delta git zsh sheldon fzf jq openssl starship neovim fd mise uv gh
brew install --cask zed font-jetbrains-mono-nerd-font
# initialize sheldon
echo "Installing Sheldon"
mkdir -p "$HOME/.config/sheldon"
rsync -u ./sheldon/plugins.toml "$HOME/.config/sheldon/plugins.toml"
sheldon lock
# mise runtime versions
echo "Set up mise"
mkdir -p "$HOME/.config/mise"
rsync -u ./mise/config.toml "$HOME/.config/mise/config.toml"
(cd "$HOME" && mise install)
# profile files
echo "Set up zprofile"
rsync -u ./zprofile.zsh "$HOME/.zprofile"
echo "Set up zshrc"
rsync -u ./zshrc.zsh "$HOME/.zshrc"
echo "Set up editor helper"
mkdir -p "$HOME/.zsh_utils"
rsync -u ./editor.zsh "$HOME/.zsh_utils/editor.zsh"
# starship stuff
echo "Set up starship"
mkdir -p "$HOME/.starship/cache"
rsync -u ./starship.toml "$HOME/.starship/"
# iterm stuff - make sure to import into iterm
echo "Set up iterm config"
mkdir -p "$HOME/.iterm2"
rsync -u ./com.googlecode.iterm2.plist "$HOME/.iterm2/"
# ssh keys — use existing keys if present, otherwise generate them
ensure_ssh_key() {
local keypath="$1"
if [ -f "$keypath" ] && [ -f "$keypath.pub" ]; then
echo "Using existing SSH key at $keypath"
else
echo "Generating ed25519 SSH key at $keypath"
mkdir -p "$HOME/.ssh"
chmod 700 "$HOME/.ssh"
ssh-keygen -t ed25519 -C "$EMAIL" -f "$keypath" -N ''
fi
}
ensure_ssh_key "$SSH_KEY"
ensure_ssh_key "$VERIFIER_KEY"
# ssh config — route github.com auth through the personal key
echo "Set up ssh config"
SSH_CONFIG="$HOME/.ssh/config"
touch "$SSH_CONFIG"
chmod 600 "$SSH_CONFIG"
if ! grep -qE '^[[:space:]]*Host[[:space:]]+github\.com([[:space:]]|$)' "$SSH_CONFIG"; then
cat >> "$SSH_CONFIG" <<EOF
Host github.com
HostName github.com
User git
IdentityFile $SSH_KEY
IdentitiesOnly yes
AddKeysToAgent yes
UseKeychain yes
EOF
fi
# allowed signers (lets git verify your own signed commits locally)
echo "Set up git allowed signers"
mkdir -p "$HOME/.config/git"
{
echo "$EMAIL $(cat "$SSH_KEY.pub")"
echo "$EMAIL $(cat "$VERIFIER_KEY.pub")"
} > "$HOME/.config/git/allowed_signers"
# git configuration
echo "Set up git config"
git config --global user.email '2665798+mjburghoffer@users.noreply.github.com'
git config --global user.name 'Matthew Burghoffer'
git config --global init.defaultBranch 'main'
git config --global push.default 'current'
git config --global checkout.defaultRemote 'origin'
git config --global --type=bool checkout.autoSetupRemote 'true'
git config --global --type=bool fetch.prune 'true'
git config --global --type=bool rebase.autostash 'true'
git config --global core.editor 'nvim'
git config --global pull.ff 'only'
git config --global merge.conflictStyle 'zdiff3'
git config --global alias.set-upstream '!git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`'
# git diff/merge gui tool (Zed)
git config --global diff.tool 'zed'
git config --global difftool.zed.cmd 'zed --wait --diff "$LOCAL" "$REMOTE"'
git config --global merge.tool 'zed'
git config --global mergetool.zed.cmd 'zed --wait "$MERGED"'
# ssh commit signing
git config --global gpg.format 'ssh'
git config --global user.signingkey "$VERIFIER_KEY.pub"
git config --global --type=bool commit.gpgsign 'true'
git config --global --type=bool tag.gpgsign 'true'
git config --global gpg.ssh.allowedSignersFile "$HOME/.config/git/allowed_signers"
## delta pager
git config --global core.pager 'delta'
git config --global interactive.diffFilter 'delta --color-only'
git config --global --type=bool delta.navigate 'true'
git config --global --type=bool delta.line-numbers 'true'
git config --global --type=bool color.ui 'true'