-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmac-setup.sh
More file actions
executable file
·92 lines (72 loc) · 2.74 KB
/
mac-setup.sh
File metadata and controls
executable file
·92 lines (72 loc) · 2.74 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
#!/bin/bash
if [ "$(hidutil property --get 'UserKeyMapping')" == '(null)' ]; then
echo 'Remapping macOS modifiers...'
# remap CapsLock to Escape (now)
./scripts/remap_macos_modifiers.sh
# remap CapsLock to Escape (survives system restarts)
# this was generated using https://hidutil-generator.netlify.app/
PLIST_TARGET="$HOME/Library/LaunchAgents/com.local.KeyRemapping.plist"
if [ ! -f "$PLIST_TARGET" ]; then
sudo cp ./macos/com.local.KeyRemapping.plist "$PLIST_TARGET"
fi
fi
# install homebrew
if ! command -v brew &>/dev/null; then
echo 'Homebrew not installed, installing...'
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
echo 'Setting up App Shortcuts...'
# ^ for Control, @ for Command, $ for shift
set_app_shortcut() {
defaults write "$1" NSUserKeyEquivalents -dict-add "$2" "$3"
}
# WezTerm bundle identifier
# got it using `mdls -name kMDItemCFBundleIdentifier -r /Applications/WezTerm.app`
app_id='com.github.wez.wezterm'
# these can be set on the UI and then read to replicate using the following
# command: `defaults read com.github.wez.wezterm NSUserKeyEquivalents`
# Disable default shortcuts for tabs in wezterm
set_app_shortcut "$app_id" 'Activate the tab to the left' '\0'
set_app_shortcut "$app_id" 'Activate the tab to the right' '\0'
echo 'Getting brew packages...'
brew bundle
# NOTE: check this page if getting an error from xcodebuild:
# https://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error
if ! command -v unicornleap &>/dev/null; then
echo 'Installing unicornleap... (requires XCode)'
# install full xcode (required for unicorn)
mas install 497799835
# accept license
sudo xcodebuild -license
# finish Xcode setup
xcodebuild -runFirstLaunch
mkdir -p ~/dev/forks
# clone unicornleap
rm -rf ~/dev/forks/unicornleap
git clone --depth=1 git@github.com:jgdavey/unicornleap.git ~/dev/forks/unicornleap
# create install dir
mkdir ~/.bin
# Install
# shellcheck disable=2164
pushd ~/dev/forks/unicornleap \
&& make \
&& make images \
&& cp build/unicornleap ~/.bin/ \
&& popd || exit
fi
# Install TerminalVim
if [[ ! -f "/Applications/TerminalVim.app" ]]; then
echo 'Installing TerminalVim app'
cp -r ./iterm/TerminalVim.app /Applications/TerminalVim.app
fi
if [[ ! -f "/Applications/BTop.app" ]]; then
echo 'Installing BTop app'
cp -r ./iterm/BTop.app /Applications/BTop.app
fi
# setup file handlers for TerminalVim
terminal_vim_id="$(osascript -e 'id of app "TerminalVim"')"
for ext in md txt js jsx ts tsx json lua rb ex exs eex heex yaml yml plist; do
echo "Setting TerminalVim as handler for .$ext"
duti -s "$terminal_vim_id" ".$ext" editor
done