-
Notifications
You must be signed in to change notification settings - Fork 35
/
setup-new-mac
executable file
·112 lines (94 loc) · 3.57 KB
/
setup-new-mac
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
#!/usr/bin/env bash
set -e
# Create symlinks from iCloud to home directory
cd "$HOME"
[ ! -L icloud-drive ] && ln -s "$HOME/Library/Mobile Documents/com~apple~CloudDocs" icloud-drive
[ ! -L lolbrary ] && ln -s "$HOME/Library" lolbrary
for link in .config .gemrc .gitconfig .gitignore_global .inputrc .profile .bashrc .vim .vimrc bin .fzf.bash .tmux.conf; do
if [ -L "$HOME/$link" ]; then
echo "Link '$link' already exists"
else
ln -s "icloud-drive/dotfiles/$link" .
fi
done
# Shush MOTD
touch "$HOME/.hushlogin"
# Prevent macOS from restoring terminal
touch "$HOME/.bash_sessions_disable"
## link .ssh config
mkdir -p "$HOME/.ssh"
cd "$HOME/.ssh"
[ ! -L config ] && ln -s ../icloud-drive/dotfiles/.ssh/config .
cd ..
# Set macOS default hidden settings
## Disabling shadows on windows when taking screenshots - requires killall SystemUIServer
defaults write com.apple.screencapture disable-shadow -bool true
## allow disabling inline video in safari http://www.kirkville.com/stop-auto-play-videos-from-annoying-you-in-your-browser/
defaults write com.apple.Safari WebKitMediaPlaybackAllowsInline -bool false
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2AllowsInlineMediaPlayback -bool false
## Allow pressing and holding a key to repeat it in VS Code - https://stackoverflow.com/questions/39972335/how-do-i-press-and-hold-a-key-and-have-it-repeat-in-vscode
defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false
defaults write com.microsoft.VSCodeInsiders ApplePressAndHoldEnabled -bool false
## Avoid pressing and holding for diacritics globally
defaults write -g ApplePressAndHoldEnabled -bool false
# Install things
if command -v brew; then
echo "Homebrew installed; updating:"
brew update
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval $(/opt/homebrew/bin/brew shellenv)
fi
# Brew installations
brew tap heroku/brew
brew tap universal-ctags/universal-ctags
for pkg in vim bash bash-completion@2 git gh nodenv node-build rbenv ruby-build postgresql@15 wget tree jq heroku hugo yarn fzf ripgrep watchman; do
if brew list -1 | grep -q "^${pkg}\$"; then
echo "Package '$pkg' is installed; updating:"
brew upgrade "$pkg" && brew cleanup "$pkg" || true
else
brew install "$pkg"
fi
done
# Switch to brew bash
echo /opt/homebrew/bin/bash | sudo tee -a /etc/shells
chsh -s /opt/homebrew/bin/bash
# As of 3/12/2024, postgresql@15 is keg-only, so add it to the path
export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"
# Start postgres
brew services start postgresql@15
if psql -lqt | cut -d \| -f 1 | grep -qw "$(whoami)"; then
echo "Default postgres database already exists"
else
createdb "$(whoami)"
fi
if brew list -1 | grep -q "^universal-ctags\$"; then
echo "Package 'universal-ctags' is installed; updating:"
brew upgrade bash-completion || true
else
brew install --HEAD universal-ctags
fi
## Set up node
NODE_VERSION="20.11.1"
if [ -d ".nodenv/versions/$NODE_VERSION" ]; then
echo "Node $NODE_VERSION already installed"
else
nodenv install "$NODE_VERSION"
fi
eval "$(nodenv init -)"
nodenv global "$NODE_VERSION"
## Set up ruby
RUBY_VERSION="3.3.0"
if [ -d ".rbenv/versions/$RUBY_VERSION" ]; then
echo "Ruby $RUBY_VERSION already installed"
else
rbenv install "$RUBY_VERSION"
fi
eval "$(rbenv init -)"
rbenv global "$RUBY_VERSION"
gem update --system
gem install bundler htmlbeautifier ripper-tags
# Copy launch agents for launch.d (symlinks not supported)
cp $HOME/icloud-drive/dotfiles/launch-agents/* "$HOME/Library/LaunchAgents"
# Run profile
source .profile