Last active
November 9, 2022 19:44
-
-
Save llimllib/5f01219954e213ec57ae267008e702e5 to your computer and use it in GitHub Desktop.
install and setup a mac exactly as I like it, in as automated a way as possible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# many settings from https://raw.githubusercontent.com/mathiasbynens/dotfiles/master/.macos | |
# many settings from https://raw.githubusercontent.com/thoughtbot/laptop/master/mac | |
# instructions on finding the default you've changed: https://pawelgrzybek.com/change-macos-user-preferences-via-command-line/ | |
# previous install notes at: | |
# https://gist.github.com/llimllib/ee591266e05bd880629a4e7511a61bb3 | |
# https://gist.github.com/llimllib/e864a92da94ceb1ef0da2e06fd1f8d70 | |
# https://gist.github.com/llimllib/3fc4fefcfc0152dad8c58201246d8802 | |
fancy_echo() { | |
local fmt="$1"; shift | |
# shellcheck disable=SC2059 | |
printf "\n$fmt\n" "$@" | |
} | |
# handle failures | |
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT | |
# Things I don't know how to do from the command line: | |
# * use caps lock as esc for all keyboards | |
# * increase screen resolution to retina | |
printf "What's the computer name? " | |
read -r computer_name | |
# set the computer name: | |
sudo scutil --set ComputerName "$computer_name" | |
sudo scutil --set HostName "$computer_name" | |
sudo scutil --set LocalHostName "$computer_name" | |
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$computer_name" | |
# dark mode | |
defaults write NSGlobalDomain AppleInterfaceStyle Dark | |
# speed up key repeat | |
defaults write NSGlobalDomain KeyRepeat -int 1 | |
defaults write NSGlobalDomain InitialKeyRepeat -int 20 | |
# Disable “natural” (Lion-style) scrolling | |
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false | |
# Disable Notification Center and remove the menu bar icon | |
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist 2> /dev/null | |
# I don't think this worked; instead I went into system preferences and | |
# set do not disturb to run from 3:01AM to 3:00AM | |
# Disable auto-correct | |
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false | |
# Set the icon size of Dock items to 16 pixels | |
defaults write com.apple.dock tilesize -int 16 | |
# Set the magnification to true | |
defaults write com.apple.dock magnification -int 1 | |
# Wipe all (default) app icons from the Dock | |
defaults write com.apple.dock persistent-apps -array | |
# Show only open applications in the dock | |
defaults write com.apple.dock static-only -bool true | |
# remove autohide delay | |
defaults write com.apple.dock autohide-delay -float 0 | |
# Automatically hide and show the Dock | |
defaults write com.apple.dock autohide -bool true | |
# show batter percentage | |
defaults write com.apple.menuextra.battery ShowPercent -bool true | |
# show the date in the toolbar | |
defaults write com.apple.menuextra.clock DateFormat -string 'EEE MMM d H:mm' | |
# Disable the sound effects on boot | |
sudo nvram SystemAudioVolume=" " | |
# Disable sound effects when changing volume | |
defaults write NSGlobalDomain com.apple.sound.beep.feedback -integer 0 | |
# Disable sounds effects for user interface changes | |
defaults write NSGlobalDomain com.apple.sound.uiaudio.enabled -int 0 | |
# Set alert volume to 0 | |
defaults write NSGlobalDomain com.apple.sound.beep.volume -float 0.0 | |
# Show volume in the menu bar | |
defaults write com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.volume" -int 0 | |
# Show Bluetooth in the menu bar | |
defaults write com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.bluetooth" -int 0 | |
# Avoid creating .DS_Store files on network or USB volumes | |
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true | |
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true | |
# don't hide files | |
defaults write com.apple.Finder AppleShowAllFiles true | |
# Show the ~/Library folder | |
chflags nohidden ~/Library | |
# Show the /Volumes folder | |
sudo chflags nohidden /Volumes | |
# mouse to max tracking speed | |
defaults write -g com.apple.mouse.scaling -int 3 | |
# disable shake to locate mouse pointer | |
defaults write ~/Library/Preferences/.GlobalPreferences CGDisableCursorLocationMagnification -bool YES | |
# disable pinch to zoom | |
defaults write com.apple.driver.AppleBluetoothMultitouch.mouse TrackpadPinch -int 0 | |
# disable trackpad rotate | |
defaults write com.apple.driver.AppleBluetoothMultitouch.mouse TrackpadRotate -int 0 | |
# disable double tap to zoom | |
defaults write com.apple.driver.AppleBluetoothMultitouch.mouse MouseOneFingerDoubleTapGesture -int 0 | |
defaults write com.apple.driver.AppleBluetoothMultitouch.mouse TrackpadTwoFingerDoubleTapGesture -int 0 | |
# fix key repeat in vs code. I don't use it that often, but this is necessary when I do | |
defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false | |
# speed up window opening by disabling animation | |
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool NO | |
# reboot systemUIServer to enable defaults to take effect | |
killall SystemUIServer | |
if ! command -v brew >/dev/null; then | |
fancy_echo "Installing Homebrew ..." | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
fi | |
# add brew to path | |
export PATH=/opt/homebrew/bin:$PATH | |
# make sure you sign in to the app store before you get here, mas cannot work without being signed in I guess | |
brew install mas | |
# find these codes with `mas search <app name>`. They're stable, so lets' just | |
# use the app IDs | |
# | |
# Xcode | |
mas install 497799835 | |
# AdGuard for Safari | |
mas install 1440147259 | |
brew install atuin | |
# atuin requires this. It is annoying that brew doesn't install it! atuin is | |
# extremely annoying if this is not present. | |
curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/.bash-preexec.sh | |
brew install awscli | |
brew install autoconf | |
brew install automake | |
brew install bash | |
brew install bash-completion@2 | |
brew install bat | |
brew install caddy | |
brew install cmake | |
brew install coreutils | |
brew install curl | |
brew install direnv | |
brew install dos2unix | |
brew install efm-langserver | |
brew install fd | |
brew install ffmpeg | |
brew install findutils | |
brew install fzf && /usr/local/opt/fzf/install --all | |
brew install gcc | |
brew install gnupg | |
brew install git | |
brew install git-delta | |
brew install gnu-sed | |
brew install grep | |
brew install gh | |
brew install htop | |
brew install imagemagick | |
brew install jless | |
brew install jq | |
brew install llvm | |
brew install neovim | |
brew install nmap | |
brew install pandoc | |
brew install postgresql && brew services start postgresql | |
brew install ripgrep | |
brew install s3cmd | |
brew install shellcheck | |
brew install sqlite | |
brew install tree | |
brew install vim | |
brew install wget | |
brew install yarn | |
brew install yt-dlp | |
# deprecated out of brew but I still use them | |
go install github.com/llimllib/devd/cmd/devd@latest | |
go install github.com/cortesi/modd/cmd/modd@latest | |
# brew's install of asdf seems to be quite terrible, so let's install it the | |
# way they want us to | |
# https://asdf-vm.com/#/core-manage-asdf | |
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.2 | |
export PATH=~/.asdf/bin:$PATH | |
# fzf requires an installation script to run... not sure why homebrew doesn't | |
# do this but w/e | |
"$(brew --prefix)"/opt/fzf/install --all --update-rc | |
# install dotfiles | |
mkdir code | |
cd code | |
git clone https://github.com/llimllib/personal_code.git | |
cd .. | |
cp -r code/personal_code/homedir/.* . | |
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim | |
fancy_echo "now open vim and run :VundleInstall" | |
fancy_echo "then quit and mkdir ~/.vim/colors; cp .vim/bundle/Base2Tone-vim/colors/*.vim ~/.vim/colors" | |
# now set the updated bash as your login shell | |
echo /opt/homebrew/bin/bash | sudo tee -a /etc/shells | |
sudo chsh -s /opt/homebrew/bin/bash "$(whoami)" | |
brew install --cask 1password | |
brew install --cask alfred | |
brew install --cask session-manager-plugin | |
brew install --cask amethyst | |
brew install --cask docker | |
brew install --cask firefox | |
brew install --cask google-chrome | |
brew install --cask google-cloud-sdk | |
brew install --cask iterm2 | |
brew install --cask karabiner-elements # and copy karabiner config folder into ~/.config | |
brew install --cask keepingyouawake | |
brew install --cask lastpass | |
brew install --cask macvim | |
brew install --cask multi | |
brew install --cask obsidian | |
brew install --cask slack | |
brew install --cask spotify | |
brew install --cask vlc | |
# install vim-plug for both vim and neovim | |
# https://github.com/junegunn/vim-plug | |
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ | |
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ | |
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' | |
# tell git to use the osx keychain | |
git config --global credential.helper osxkeychain | |
# create a personal access token to allow git to work on your computer | |
# copy ~/.ssh to the new computer and chown to your user | |
# copy ~/.gnupg to the new computer | |
# * set iTerm ctrl-tab and ctrl-shift-tab to "next term" and "prev term" rather | |
# than cycle | |
# install base2tone space-dark and everforest | |
wget https://raw.githubusercontent.com/atelierbram/Base2Tone-iterm2/master/ColorPresets/base2tone-space-dark.itermcolors | |
wget https://raw.githubusercontent.com/icewind/everforest.iterm2/main/Everforest_medium_dark.itermcolors | |
fancy_echo "open iterm -> preferences -> profiles -> color presets and import base2tone-space-dark.itermcolors and Everforest_medium_dark.itermcolors" | |
brew tap homebrew/cask-fonts | |
fonts=(font-iosevka-nerd-font font-hack-nerd-font font-fira-code-nerd-font font-ubuntu-mono-nerd-font font-sf-pro) | |
for font in "${fonts[@]}"; do | |
brew install --cask "$font" | |
done | |
set -euxo pipefail | |
langs=("python" "ruby" "nodejs" "golang" "rust" "terraform") | |
for lang in "${langs[@]}"; do | |
asdf plugin add "$lang" | |
asdf install "$lang" latest | |
asdf global "$lang" latest | |
done | |
asdf reshim | |
# install language servers | |
go install golang.org/x/tools/gopls@latest | |
go install mvdan.cc/gofumpt@latest | |
npm install -g typescript typescript-language-server bash-language-server | |
gem install solargraph | |
pip install pyright | |
# go through the steps to get your local git auth set up | |
gh auth login |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment