-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·139 lines (109 loc) · 4.04 KB
/
setup.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
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
#!/bin/bash
set -eu
set -o pipefail
# Brew
which -s brew || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
# Dotfiles
[[ -d ~/.dotfiles.base ]] \
|| git clone git@github.com:rouge8/dotfiles-base.git ~/.dotfiles.base \
&& ~/.dotfiles.base/bin/dotfiles.symlink install
[[ -d ~/.dotfiles.public ]] \
|| git clone git@github.com:rouge8/dotfiles ~/.dotfiles.public \
&& ~/bin/dotfiles install
cd ~/.dotfiles.public
# Install 'em all
brew bundle install
# VirtualFish
vf install compat_aliases
# Rust
rustup --version || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- --no-modify-path
rustup toolchain install stable nightly
rustup component add rust-src rustfmt clippy llvm-tools-preview rust-analyzer
# Python tools
pipx install --python python3.12 ipython
pipx inject ipython httpx attrs rich
pipx install twine
pipx inject twine readme_renderer[md]
pipx install build
# Various things
make -j$(nproc)
# Make some directories
mkdir -p ~/tmp ~/forks
if [[ -d ~/Dropbox/Projects && ! -d ~/projects ]]; then
ln -s ~/Dropbox/Projects/ ~/projects
fi
# Set fish as the login shell
FISH_BIN="$(brew --prefix)/bin/fish"
if ! grep -xq "$FISH_BIN" /etc/shells; then
echo "Adding $FISH_BIN to /etc/shells..."
echo "$FISH_BIN" | sudo tee -a /etc/shells
fi
chsh -s "$FISH_BIN"
# But configure Terminal.app to always use bash as a fallback
defaults write com.apple.terminal Shell /bin/bash
# Poetry
poetry config virtualenvs.path "$HOME/.virtualenvs"
# Vim
fish -c vim-plug-install
# Docker
echo '{"credsStore": "osxkeychain", "cliPluginsExtraDirs": ["/opt/homebrew/lib/docker/cli-plugins"]}' > ~/.docker/config.json
brew services start docuum
#######################
# macOS configuration #
#######################
echo "macOS configuration..."
# Scroll bars
defaults write -g AppleShowScrollBars Always
# Finder
defaults write com.apple.finder ShowPathbar -bool true
defaults write -g AppleShowAllExtensions -bool true
chflags nohidden ~/Library
# Dock
defaults write com.apple.dock tilesize -int 40
defaults write com.apple.dock magnification -bool true
defaults write com.apple.dock largesize -int 100
# Keyboard
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false
defaults write -g NSAutomaticPeriodSubstitutionEnabled -bool false
defaults write -g NSAutomaticCapitalizationEnabled -bool false
# Enable Tab in all controls
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# No Natural scrollng
defaults write -g com.apple.swipescrolldirection -bool false
# Screensaver and lock screen
defaults -currentHost write com.apple.screensaver idleTime -int 1200 # 20 minutes
echo Configuring "Require password immediately after screensaver"...
sysadminctl -screenLock immediate -password -
# Terminal.app
open -a Terminal.app misc/Gruvbox-dark.terminal
defaults write com.apple.terminal 'Default Window Settings' -string Gruvbox-dark
defaults write com.apple.terminal 'Startup Window Settings' -string Gruvbox-dark
# Moom
defaults import com.manytricks.Moom misc/Moom.plist
# TODO: Remove once
# https://github.com/kovidgoyal/kitty/commit/a7e9030c12a6c623e480e9f65055fe8956a9ea3a
# is released
# Add /usr/local/bin to $PATH even for GUI apps
echo 'Updating $PATH...'
sudo launchctl config user path /usr/bin:/bin:/usr/sbin:/sbin:$(brew --prefix)/bin
# Restart Finder and Dock
killall Dock
killall Finder
# Menu bar
open /System/Library/CoreServices/Menu\ Extras/TimeMachine.menu
defaults write com.apple.TextInputMenu visible -bool true
defaults write com.apple.menuextra.clock DateFormat -string "EEE HH:mm:ss"
# TODO: Dock layout
# TODO: keyboard input sources shortcuts
# TODO: keyboard input sources
# TODO: time machine menu bar
# TODO: things in menu bar that launch at startup
# TODO: hue app
set +x
echo
echo
echo
echo "TODO: Open System Preferences > Keyboard > Modifier Keys to remap capslock to control"
echo
echo "If this is a personal computer, run 'brew bundle install --file Brewfile.home' and re-run '~/.dotfiles.public/setup.sh' to complete installation."