Skip to content

Instantly share code, notes, and snippets.

@iosifnicolae2
Last active April 2, 2024 18:07
Show Gist options
  • Save iosifnicolae2/ed3e873384f609e3c07d6efa31f5eb40 to your computer and use it in GitHub Desktop.
Save iosifnicolae2/ed3e873384f609e3c07d6efa31f5eb40 to your computer and use it in GitHub Desktop.
Automatic MacOS installation
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new OSX machine
#
# This should be idempotent so it can be run multiple times.
#
# Some apps don't have a cask and so still need to be installed by hand. These
# include:
#
# - Twitter (app store)
# - Postgres.app (http://postgresapp.com/)
#
# Notes:
#
# - If installing full Xcode, it's better to install that first from the app
# store before running the bootstrap script. Otherwise, Homebrew can't access
# the Xcode libraries as the agreement hasn't been accepted yet.
#
# Reading:
#
# - http://lapwinglabs.com/blog/hacker-guide-to-setting-up-your-mac
# - https://gist.github.com/MatthewMueller/e22d9840f9ea2fee4716
# - https://news.ycombinator.com/item?id=8402079
# - http://notes.jerzygangi.com/the-best-pgp-tutorial-for-mac-os-x-ever/
echo "Starting bootstrapping"
# Check for Homebrew, install if we don't have it
if test ! $(which brew); then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Update homebrew recipes
brew update
# Install GNU core utilities (those that come with OS X are outdated)
brew install coreutils gnu-sed gnu-tar gnu-indent gnu-which gnu-getopt findutils bash
PACKAGES=(
ack
arduino-cli
autoconf
automake
awscli
base64
bash
datawire/blackbird/telepresence-arm64
ffmpeg
gettext
gifsicle
git
git-crypt
git-filter-repo
git-lfs
git-secret
glib
graphviz
hasura-cli
helm
hexedit
imagemagick
jq
libjpeg
libmemcached
lynx
markdown
memcached
mercurial
minikube
mtr
npm
nmap
node@18
nvm
openjdk
openvpn
pkg-config
postgresql
[email protected]
pyyaml
rclone
pypy
snappy
telepresence-arm64
qrencode
rabbitmq
rename
skaffold
ssh-copy-id
terminal-notifier
terraform
the_silver_searcher
tmux
tree
vim
virtualenv
wget
wireguard-tools
zsh-autocomplete
gh
bash-completion@2
)
echo "Installing packages..."
brew install ${PACKAGES[@]}
brew link --overwrite python
echo "Cleaning up..."
brew cleanup
echo "Installing cask..."
brew install caskroom/cask/brew-cask
CASKS=(
1password
1password-cli
android-platform-tools
android-studio
docker
flutter
discord
drawio
github
google-chrome
google-cloud-sdk
google-drive
intellij-idea
iterm2
joshjon-nocturnal
linearmouse
microsoft-office
monitorcontrol
microsoft-remote-desktop
mqtt-explorer
ngrok
notion
obs
openvpn-connect
parallels
pgadmin4
postman
raycast
robo-3t
sequel-pro
serial
shottr
signal
skype
slack
spectacle
stats
teamviewer
the-unarchiver
vagrant
utm
vlc
visual-studio-code
whatsapp
zappy
wireshark
zulu
zoom
)
echo "Installing cask apps..."
brew install --cask ${CASKS[@]}
echo "Installing Ruby gems"
RUBY_GEMS=(
bundler
filewatcher
cocoapods
)
sudo gem install ${RUBY_GEMS[@]}
echo "Configuring OSX..."
# Set fast key repeat rate
defaults write NSGlobalDomain KeyRepeat -int 0
# Require password as soon as screensaver or sleep mode starts
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Show filename extensions by default
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Disable "natural" scroll
# defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
# Disable Spotlight
sudo mdutil -a -i off
# and then follow https://manual.raycast.com/hotkey
# Disable recent applications in Dock
defaults write com.apple.dock show-recents -bool no
defaults write com.apple.dock recent-apps -array # intentionally empty
sudo nano /etc/paths
# Add /opt/homebrew/bin as first line
if type brew &>/dev/null
then
HOMEBREW_PREFIX="$(brew --prefix)"
if [[ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]]
then
source "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
else
for COMPLETION in "${HOMEBREW_PREFIX}/etc/bash_completion.d/"*
do
[[ -r "${COMPLETION}" ]] && source "${COMPLETION}"
done
fi
fi
if type brew &>/dev/null
then
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
autoload -Uz compinit
compinit
fi
echo 'eval "$(gh copilot alias -- bash)"' >> ~/.bashrc
echo 'eval "$(gh copilot alias -- zsh)"' >> ~/.zshrc
echo 'source /opt/homebrew/share/zsh-autocomplete/zsh-autocomplete.plugin.zsh' >> ~/.zshrc
echo 'source /opt/homebrew/share/zsh-autocomplete/zsh-autocomplete.plugin.zsh' >> ~/.zshrc
echo "alias python='python3'" >> ~/.zshrc
echo "Bootstrapping complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment