Skip to content

Instantly share code, notes, and snippets.

@gruckion
Last active October 2, 2024 16:01
Show Gist options
  • Save gruckion/8202afb97509f9fb2cf59ff6318a2b34 to your computer and use it in GitHub Desktop.
Save gruckion/8202afb97509f9fb2cf59ff6318a2b34 to your computer and use it in GitHub Desktop.
Setup Mac script
#!/bin/sh
####################################################################
# 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
brew upgrade
brew clenaup
# Check brew is working correctly
brew doctor
####################################################################
# Bootstrap script for setting up a new OSX machine for a developer
####################################################################
echo "Install Xcode"
# Install mas
brew install mas
# Check for Xcode
mas search Xcode
# Install XCode
mas install 497799835
xcode-select --install
# Install cocoapods
sudo gem install cocoapods -n /usr/local/bin
# Install xcode-install
sudo gem install xcode-install
# Install 14.4 simulator
xcversion simulators --install="iOS 14.4 Simulator"
xcrun simctl list
####################################################################
# Install GNU core utilities (those that come with OS X are outdated)
####################################################################
brew install coreutils
brew install gnu-sed
brew install gnu-tar
brew install gnu-indent
brew install gnu-which
brew install gnu-grep
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
brew install findutils
####################################################################
# Brew install packages needed for developers
####################################################################
PACKAGES=(
ant
maven
gradle
bash
xz
zsh
zsh-completions
docker
git
awscli
nvm
node
python
python3
pyenv
watchman
appium
tfenv
pre-commit
terraform-docs
tflint
thefuck
snappy
ipcalc
bind # for using dig DNS tool
rectangle
zsh-syntax-highlighting
zsh-autosuggestions
fzf
infracost
jq
graphviz
monitorcontrol
act
cmake
protobuf
gnupg
)
echo "Installing packages..."
brew install ${PACKAGES[@]}
echo "Cleaning up..."
brew cleanup
####################################################################
# Brew install applications via cask
####################################################################
echo "Installing cask..."
homebrew/cask
homebrew/cask-versions
homebrew/core
homebrew/services
CASKS=(
r
rstudio
iterm2
postman
visual-studio-code
sourcetree
# browsers
google-chrome
firefox
homebrew/cask-versions/firefox-developer-edition
opera
opera-developer
microsoft-edge
microsoft-edge-dev
eclipse-java
nosql-workbench
raindropio
postman
whatsapp
obs
nightfall
terminal-notifier
brave-browser
figma
alt-tab
dropzone
cheatsheet
another-redis-desktop-manager
)
echo "Installing cask apps..."
brew install --cask ${CASKS[@]}
echo "Install display placer"
brew tap jakehilborn/jakehilborn && brew install displayplacer
####################################################################
# Setup Python packages
####################################################################
echo "Installing Python packages..."
PYTHON_PACKAGES=(
ipython
virtualenv
virtualenvwrapper
)
sudo -H pip3 install ${PYTHON_PACKAGES[@]}
####################################################################
# Install global node modules
####################################################################
echo "Installing Node packages..."
NODE_PACKAGES=(
@aws-amplify/cli
detox-cli
expo-cli
ignite-cli
serverless
tree-cli
typescript
yarn
)
yarn global add ${NODE_PACKAGES[@]}
####################################################################
# Setup nvm
####################################################################
mkdir ~/.nvm
chmod +x /usr/local/opt/nvm/nvm.sh
# Install LTS version
nvm install --lts
nvm alias default stable
nvm use default
# Update npm
npm i -g npm
####################################################################
# Setup git
####################################################################
# Useful guide https://dev.to/equiman/setup-macos-for-development-3kc2
rm '/usr/local/bin/git-cvsserver'
brew link --overwrite git
brew install git-lfs
git lfs install
####################################################################
# Set ZSH as th default shell
####################################################################
echo "ZSH setup"
# Take ownership of files
sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions
chmod u+w /usr/local/share/zsh /usr/local/share/zsh/site-functions
# Ensure Zsh is set as the default shell
sudo sh -c "echo $(which zsh) >> /etc/shells" && chsh -s $(which zsh)
# Shell integration https://iterm2.com/documentation-shell-integration.html
curl -L https://iterm2.com/shell_integration/zsh \
-o ~/.iterm2_shell_integration.zsh
source ~/.iterm2_shell_integration.zsh
# Setup Terraform
tfenv install 0.15.3
tfenv use 0.15.3
####################################################################
# Setup Android / Java
####################################################################
# SDK Man
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
# Required permissions
sudo chown -R $(whoami) /usr/local/opt
sudo chown -R $(whoami) /usr/local/share
# Only required if a single user uses the machine
sudo chown -R $(whoami) /usr/local/lib
# Install Java
sdk install java 8.0.272.hs-adpt
sdk use java 8.0.272.hs-adpt
sdk default java 8.0.272.hs-adpt
# Install Android SDK
brew install --cask android-sdk
# Required for sdkmanager to run
touch ~/.android/repositories.cfg
# Install Android SDK 29 + Build Tool 28.0.3
sdkmanager "ndk-bundle"
sdkmanager "platform-tools"
sdkmanager "build-tools;28.0.3"
sdkmanager "platforms;android-29"
sdkmanager --update
# Environment variables
echo "# Adds Environment variables for Java" >> ~/.zshrc
echo "export ANT_HOME=/usr/local/opt/ant" >> ~/.zshrc
echo "export MAVEN_HOME=/usr/local/opt/maven" >> ~/.zshrc
echo "export GRADLE_HOME=/usr/local/opt/gradle" >> ~/.zshrc
echo "export ANDROID_HOME=/usr/local/share/android-sdk" >> ~/.zshrc
echo "export ANDROID_NDK_HOME=/usr/local/share/android-sdk/ndk-bundle" >> ~/.zshrc
echo "export INTEL_HAXM_HOME=/usr/local/Caskroom/intel-haxm" >> ~/.zshrc
echo "export ANDROID_BT_VERSION=$(ls -tr $ANDROID_HOME/build-tools | sort | tail -1)" >> ~/.zshrc
# Update PATH
echo "# Sets the PATH variable" >> ~/.zshrc
echo "export PATH=\$ANT_HOME/bin:\$PATH" >> ~/.zshrc
echo "export PATH=\$MAVEN_HOME/bin:\$PATH" >> ~/.zshrc
echo "export PATH=\$GRADLE_HOME/bin:\$PATH" >> ~/.zshrc
echo "export PATH=\$ANDROID_HOME/tools:\$PATH" >> ~/.zshrc
echo "export PATH=\$ANDROID_HOME/platform-tools:\$PATH" >> ~/.zshrc
echo "export PATH=\$ANDROID_HOME/build-tools/\$ANDROID_BT_VERSION:\$PATH" >> ~/.zshrc
echo "export PATH=\$ANDROID_HOME/bin:\$PATH" >> ~/.zshrc
echo "export PATH=\$ANDROID_HOME/:\$PATH" >> ~/.zshrc
source ~/.zshrc
# Android Studio, bundle tool and intel HAXM
brew install bundletool
brew install --cask android-studio
brew install --cask intel-haxm
# # Install Androud Emulator
# brew install --cask genymotion
# # Add to PATH
# echo "export GMTOOL_PATH=/Applications/Genymotion.app/Contents/MacOS/" >> ~/.zshrc
# echo "export PATH=\$GMTOOL_PATH:\$PATH" >> ~/.zshrc
# genyshell -c "devices list"
# # Create a device
# gmtool admin create "Google Pixel - 9.0 - API 28 - 1080x1920" GP_9
# Run a device
# gmtool admin run GP_9
# View iPhone or Android from desktop and file transfer
brew install scrcpy
####################################################################
# Configure OSX default settings
####################################################################
echo "Configuring OSX..."
# 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
# Show hidden files by default
defaults write com.apple.finder AppleShowAllFiles -bool true
# Show finder status bar
defaults write com.apple.finder ShowStatusBar -bool true
# Disable smart quotes and smart dashes as they are annoying when typing code
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
# Showing icons for hard drives, servers, and removable media on the desktop
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
# Disabling the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Use column view in all Finder windows by default
defaults write com.apple.finder FXPreferredViewStyle Clmv
# Enabling snap-to-grid for icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
# Speeding up Mission Control animations and grouping windows by application
defaults write com.apple.dock expose-animation-duration -float 0.1
defaults write com.apple.dock "expose-group-by-app" -bool true
# Setting Dock to auto-hide and removing the auto-hiding delay
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -float 0
# Enabling the Develop menu and the Web Inspector in Safari
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write com.apple.Safari "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" -bool true
# Adding a context menu item for showing the Web Inspector in web views
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
# Disabling automatic termination of inactive apps
defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true
# Use plain text mode for new TextEdit documents
defaults write com.apple.TextEdit RichText -int 0
# Open and save files as UTF-8 in TextEdit
defaults write com.apple.TextEdit PlainTextEncoding -int 4
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
defaults write NSGlobalDomain AppleShowAllExtensions -bool false
# Finder plugins
# Position windows easily
brew install --cask spectacle
# Restart finder and source new environment variables
source ~/.zshrc
killall Finder
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment