-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·143 lines (113 loc) · 3.75 KB
/
install.sh
File metadata and controls
executable file
·143 lines (113 loc) · 3.75 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
#!/bin/bash
# vim: tw=0
set -eo pipefail
color() {
local colornumber="$1"
shift
tput setaf "$colornumber"
echo "$*"
tput sgr0
}
# blue = 4
# magenta = 5
red(){ color 1 "$*"; }
green(){ color 2 "$*"; }
yellow(){ color 3 "$*"; }
info(){
green "=== $*"
}
error(){
red "!! $*" >&2
}
stay_awake_while(){
caffeinate -dims "$@"
}
quietly_brew_bundle(){
local brewfile=$1
shift
local regex='(^Using )|Homebrew Bundle complete|Skipping install of|It is not currently installed|Verifying SHA-256|==> (Downloading|Purging)|Already downloaded:|No SHA-256'
stay_awake_while brew bundle --file="$brewfile" "$@" | (grep -vE "$regex" || true)
}
command_does_not_exist(){
! command -v "$1" > /dev/null
}
make_qlstephen_work_on_catalina(){
xattr -cr ~/Library/QuickLook/QLStephen.qlgenerator
qlmanage -r
qlmanage -r cache
killall Finder
}
info "Checking for command-line tools..."
if command_does_not_exist xcodebuild; then
stay_awake_while xcode-select --install
fi
info "Installing Homebrew (if not already installed)..."
if command_does_not_exist brew; then
stay_awake_while /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# Don't run `brew cleanup <package>` after each package is installed. It just makes things take longer.
export HOMEBREW_NO_INSTALL_CLEANUP=1
eval "$(/opt/homebrew/bin/brew shellenv)"
info "Installing Homebrew packages..."
for brewfile in Brewfile */Brewfile; do
quietly_brew_bundle "$brewfile" --verbose
done
# Brewfile.casks exits 1 sometimes but didn't actually fail
quietly_brew_bundle Brewfile.casks || true
# Pin postgresql since I use Postgres.app and we only need it as a dependency
brew pin postgresql@14
make_qlstephen_work_on_catalina
info "Installing rust..."
stay_awake_while rustup-init --no-modify-path -y > /dev/null
# Make sure `cargo` is in $PATH
source "$HOME/.cargo/env"
rustup component add clippy
rustup component add rust-analyzer
info "Installing Firefox open URL printer..."
if command_does_not_exist firefox-all-open-urls; then
stay_awake_while cargo install --git https://github.com/gabebw/rust-firefox-all-open-urls
fi
if ! echo "$SHELL" | grep -Fq fish; then
info "Your shell is not Fish. Changing it to Fish..."
# Fix this error when running `chsh`:
# chsh: /usr/local/bin/fish: non-standard shell
which fish | sudo tee -a /etc/shells > /dev/null
# Now check if it worked
if ! grep -Fq "$(which fish)" /etc/shells; then
error "Sorry, fish is not (YET) an approved shell"
error "I tried to add it automatically but it didn't work."
error "Please manually add this line to /etc/shells: $(which fish)"
exit 1
fi
chsh -s "$(which fish)"
fi
info "Linking dotfiles into ~..."
# Before `rcup` runs, there is no ~/.rcrc, so we must tell `rcup` where to look.
# We need the rcrc because it tells `rcup` to ignore thousands of useless Vim
# backup files that slow it down significantly.
export RCRC=rcrc
stay_awake_while rcup -d .
info "Installing Neovim packages..."
nvim +qa
stay_awake_while ./system/osx-settings
if command -v asdf &>/dev/null || [[ -d ~/.asdf ]]; then
echo 'Removing asdf...'
rm -rf ~/.asdf || true
brew uninstall asdf || true
fi
# Load mise (before setup scripts) in case it's the first time installing them
eval (mise activate)
info "Running all setup scripts..."
for setup in tag-*/setup vscode/setup; do
dir=$(basename "$(dirname "$setup")")
info "Running setup for ${dir#tag-}..."
. "$setup"
done
mkdir -p ~/code/work
mkdir -p ~/code/personal
mkdir -p ~/code/src
green "== Success!"
yellow "== Post-install instructions =="
yellow "1. Remap Caps Lock to Escape in the Keyboard prefpane"
yellow "2. Set up top right Hot Corner -> Desktop in Desktop & Screen Saver prefpane"