Skip to content

Instantly share code, notes, and snippets.

@n8io
Last active May 29, 2023 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n8io/4b186015bb0be839c03bd46190081319 to your computer and use it in GitHub Desktop.
Save n8io/4b186015bb0be839c03bd46190081319 to your computer and use it in GitHub Desktop.
#!/bin/bash
# bash <(wget -nv -O - "https://gist.githubusercontent.com/n8io/4b186015bb0be839c03bd46190081319/raw") # args...
set -e
touch ~/.hushlogin
touch ~/.zshrc
# Install Brew
if ! [ -x "$(command -v brew)" ]; then
echo "⏳ Installing Brew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc && source ~/.zshrc
echo "πŸ‘ Brew installed successfully"
else
echo "βœ… Brew is already installed"
fi
# Install python
if ! brew list python &>/dev/null; then
echo "⏳ Installing python3..."
brew install python
echo "export PATH=/opt/homebrew/opt/python/libexec/bin:$PATH" >> ~/.zshrc && source ~/.zshrc
echo "πŸ‘ python3 installed successfully"
else
echo "βœ… python3 is already installed"
fi
# Install Chrome
(
CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
if ! [ -x "$CHROME_BIN" ]; then
echo "⏳ Installing Chrome..."
brew install --cask google-chrome
echo "πŸ‘ Chrome installed successfully"
if ! [ -x $(command -v "defaultbrowser") ]; then
echo "⏳ Making Chrome the default browser..."
brew install defaultbrowser
defaultbrowser chrome
dockutil --add "/Applications/Google Chrome.app" "$HOME"
echo "βœ… Chrome is now the default browser"
open https://chrome.google.com/webstore/detail/1password-%E2%80%93-password-mana/aeblfdkhhhdcdjpifhhbdiojplfjncoa
fi
else
echo "βœ… Chrome is already installed"
fi
)
# Install VSCode
if ! [ -x "$(command -v code)" ]; then
echo "⏳ Installing VSCode..."
brew install --cask visual-studio-code
echo "export PATH=/usr/local/bin/:$PATH" >> ~/.zshrc && source ~/.zshrc
echo "export EDITOR=\"code --wait\"" >> ~/.zshrc
echo "alias code=\"/usr/local/bin//code\"" >> ~/.zshrc
# Install extensions
code --install-extension christian-kohler.path-intellisense
code --install-extension dbaeumer.vscode-eslint
code --install-extension emmanuelbeziat.vscode-great-icons
code --install-extension esbenp.prettier-vscode
code --install-extension file-icons.file-icons
code --install-extension GitHub.vscode-pull-request-github
code --install-extension hashicorp.terraform
code --install-extension mikestead.dotenv
code --install-extension ms-azuretools.vscode-docker
code --install-extension ms-vscode-remote.remote-containers
code --install-extension ms-vscode.live-server
code --install-extension ms-vscode.makefile-tools
code --install-extension PKief.material-icon-theme
code --install-extension redhat.vscode-yaml
code --install-extension RichardKotze.git-mob
code --install-extension richie5um2.vscode-sort-json
code --install-extension ryanluker.vscode-coverage-gutters
code --install-extension statelyai.stately-vscode
code --install-extension streetsidesoftware.code-spell-checker
code --install-extension wmaurer.change-case
echo "πŸ‘ VSCode installed successfully"
else
echo "βœ… VSCode is already installed"
fi
# Install dockutil
if ! brew list dockutil &>/dev/null; then
echo "⏳ Installing dockutil..."
brew install --cask hpedrorodrigues/tools/dockutil
echo "πŸ‘ dockutil installed successfully"
else
echo "βœ… dockutil is already installed"
fi
# Install xcode developer tools
if ! xcode-select -p &>/dev/null; then
echo "⏳ Installing xcode developer tools..."
xcode-select --install
echo "πŸ‘ xcode developer tools installed successfully"
else
echo "βœ… xcode developer tools is already installed"
fi
# Install GPG Suite
if ! brew list gpg-suite &>/dev/null; then
echo "⏳ Installing GPG Suite..."
brew install --cask gpg-suite
echo "πŸ‘ GPG Suite installed successfully"
else
echo "βœ… GPG Suite is already installed"
fi
# Install git
if ! brew list git &>/dev/null; then
echo "⏳ Installing git..."
brew install git
echo "πŸ‘ git installed successfully"
else
echo "βœ… git is already installed"
fi
# Install bat
if ! brew list bat &>/dev/null; then
echo "⏳ Installing bat..."
brew install bat
echo "alias cat=\"bat\"" >> ~/.zshrc
echo "πŸ‘ bat installed successfully"
else
echo "βœ… bat is already installed"
fi
# Install switchaudio
if ! brew list switchaudio-osx &>/dev/null; then
echo "⏳ Installing switchaudio..."
brew install switchaudio-osx
echo "πŸ‘ switchaudio installed successfully"
else
echo "βœ… switchaudio is already installed"
fi
# Install jq
if ! brew list jq &>/dev/null; then
echo "⏳ Installing jq..."
brew install jq
echo "πŸ‘ jq installed successfully"
else
echo "βœ… jq is already installed"
fi
# Install zsh
if ! brew list zsh &>/dev/null; then
echo "⏳ Installing zsh..."
brew install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
(
ZSHRC_PATH="${HOME}/.zshrc"
ZSH_PLUGINS_DIR="${HOME}/.oh-my-zsh/custom/plugins"
cd "$ZSH_PLUGINS_DIR"
git clone --depth 1 -- https://github.com/zsh-users/zsh-syntax-highlighting
git clone --depth 1 -- https://github.com/zsh-users/zsh-autosuggestions
sed -i.bak "s/^plugins=.*/plugins=(git dotenv zsh-autosuggestions zsh-syntax-highlighting)/" "$ZSHRC_PATH" && rm "$ZSHRC_PATH.bak"
)
echo "πŸ‘ zsh installed successfully"
else
echo "βœ… zsh is already installed"
fi
# Install nvm
if ! brew list nvm &>/dev/null; then
echo "⏳ Installing nvm..."
brew install nvm
echo "export NVM_DIR=\"$HOME/.nvm\" && [ -s \"/opt/homebrew/opt/nvm/nvm.sh\" ] && \. \"/opt/homebrew/opt/nvm/nvm.sh\" && [ -s \"/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm\" ] && \. \"/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm\"" >> ~/.zshrc
nvm install lts/hydrogen
nvm alias default lts/hydrogen
echo "πŸ‘ nvm installed successfully"
else
echo "βœ… nvm is already installed"
fi
# Install Rocket
if ! brew list rocket &>/dev/null; then
echo "⏳ Installing Rocket..."
brew install --cask rocket
echo "πŸ‘ Rocket installed successfully"
else
echo "βœ… Rocket is already installed"
fi
# Install iTerm2
if ! brew list iterm2 &>/dev/null; then
echo "⏳ Installing iTerm2..."
brew install --cask iterm2
echo "πŸ‘ iTerm2 installed successfully"
else
echo "βœ… iTerm2 is already installed"
fi
# Install Slack
if ! brew list slack &>/dev/null; then
echo "⏳ Installing Slack..."
brew install --cask slack
echo "πŸ‘ Slack installed successfully"
else
echo "βœ… Slack is already installed"
fi
# Install Insomnia
if ! brew list insomnia &>/dev/null; then
echo "⏳ Installing Insomnia..."
brew install --cask insomnia
echo "πŸ‘ Insomnia installed successfully"
else
echo "βœ… Insomnia is already installed"
fi
# Install Divvy
if ! brew list divvy &>/dev/null; then
echo "⏳ Installing Divvy..."
brew install --cask divvy
echo "πŸ‘ Divvy installed successfully"
else
echo "βœ… Divvy is already installed"
fi
# Install BeardedSpice
if ! brew list beardedspice &>/dev/null; then
echo "⏳ Installing BeardedSpice..."
brew install --cask beardedspice
echo "πŸ‘ BeardedSpice installed successfully"
else
echo "βœ… BeardedSpice is already installed"
fi
# Install Spotify
if ! brew list spotify &>/dev/null; then
echo "⏳ Installing Spotify..."
brew install --cask spotify
echo "πŸ‘ Spotify installed successfully"
else
echo "βœ… Spotify is already installed"
fi
# Install Kap
if ! brew list kap &>/dev/null; then
echo "⏳ Installing Kap..."
brew install --cask kap
echo "πŸ‘ Kap installed successfully"
else
echo "βœ… Kap is already installed"
fi
# Install Mac App Store installer
if ! brew list mas &>/dev/null; then
echo "⏳ Installing Mac App Store util..."
brew install mas
echo "πŸ‘ Mac App Store util installed successfully"
else
echo "βœ… Mac App Store util is already installed"
fi
# Install Mac Apps
(APP="Actions"; ID="1586435171"; if ! open -Ra "$APP" &>/dev/null; then echo "⏳ Installing ${APP} app..."; mas install $ID; else echo "βœ… ${APP} is already installed"; fi)
(APP="Battery Indicator"; ID="1206020918"; if ! open -Ra "$APP" &>/dev/null; then echo "⏳ Installing ${APP} app..."; mas install $ID; else echo "βœ… ${APP} is already installed"; fi)
(APP="Dato"; ID="1470584107"; if ! open -Ra "$APP" &>/dev/null; then echo "⏳ Installing ${APP} app..."; mas install $ID; else echo "βœ… ${APP} is already installed"; fi)
(APP="Today"; ID="6443714928"; if ! open -Ra "$APP" &>/dev/null; then echo "⏳ Installing ${APP} app..."; mas install $ID; else echo "βœ… ${APP} is already installed"; fi)
(APP="Velja"; ID="1607635845"; if ! open -Ra "$APP" &>/dev/null; then echo "⏳ Installing ${APP} app..."; mas install $ID; else echo "βœ… ${APP} is already installed"; fi)
(APP="Shortcuts"; ID="915249334"; if ! open -Ra "$APP" &>/dev/null; then echo "⏳ Installing ${APP} app..."; mas install $ID; else echo "βœ… ${APP} is already installed"; fi)
(APP="Shortery"; ID="1594183810"; if ! open -Ra "$APP" &>/dev/null; then echo "⏳ Installing ${APP} app..."; mas install $ID; else echo "βœ… ${APP} is already installed"; fi)
(APP="Command X"; ID="6448461551"; if ! open -Ra "$APP" &>/dev/null; then echo "⏳ Installing ${APP} app..."; mas install $ID; else echo "βœ… ${APP} is already installed"; fi)
# Disable recents in Dock
defaults write com.apple.dock show-recents -bool no
# Setup Dock icons
dockutil --remove all "$HOME" --no-restart
dockutil --add "/Applications/Slack.app" "$HOME" --no-restart &>/dev/null
dockutil --add "/Applications/Mail.app" "$HOME" --no-restart &>/dev/null
dockutil --add "/Applications/Google Chrome.app" "$HOME" --no-restart &>/dev/null
dockutil --add "/Applications/iTerm.app" "$HOME" --no-restart &>/dev/null
dockutil --add "/Applications/Insomnia.app" "$HOME" --no-restart &>/dev/null
dockutil --add "/Applications/Spotify.app" "$HOME" --no-restart &>/dev/null
# Show hidden files in Finder
defaults write com.apple.finder AppleShowAllFiles true
# Tab through dialogs
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Faster key repeat rates
defaults write -g InitialKeyRepeat -int 12
defaults write -g KeyRepeat -int 4
defaults write -g ApplePressAndHoldEnabled -bool false
# Expand save dialog by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
# Disable the β€œAre you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Disable Resume system-wide so a restart is a true restart
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
# Enable tap to click
defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true
# Drag windows with three fingers
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -bool true
# Enabled two finger right click
defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
# Save screenshots to the ~/Desktop/screenshots
mkdir -p "${HOME}/Desktop/screenshots"
defaults write com.apple.screencapture location -string "${HOME}/Desktop/screenshots"
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)
defaults write com.apple.screencapture type -string "png"
# Show icons for hard drives, servers, and removable media on the desktop
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true
# Finder: show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Finder: show status bar
defaults write com.apple.finder ShowStatusBar -bool true
# Finder: show path bar
defaults write com.apple.finder ShowPathbar -bool true
# Use current directory as default search scope in Finder
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Keep folders on top when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# Use list view in all Finder windows by default
# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv`
defaults write com.apple.Finder FXPreferredViewStyle -string "Nlsv"
# Disable the warning before emptying the Trash
defaults write com.apple.finder WarnOnEmptyTrash -bool false
# Empty Trash securely by default
defaults write com.apple.finder EmptyTrashSecurely -bool true
# Set the icon size of Dock items to 36 pixels
defaults write com.apple.dock tilesize -int 50
# Remove the animation when hiding/showing the Dock
defaults write com.apple.dock autohide-time-modifier -float 0
# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true
# Disable re-open windows on restart dialog
defaults write com.apple.loginwindow TALLogoutSavesState -bool false
defaults write com.apple.loginwindow LoginwindowLaunchesRelaunchApps -bool false
# Disable the sound effects on boot
sudo nvram SystemAudioVolume=%01
# Save to disk (not to iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Automatically quit printer app once the print jobs complete
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
# Set language and text formats
defaults write NSGlobalDomain AppleLanguages -array "en" "en-US"
defaults write NSGlobalDomain AppleLocale -string "en_US@currency=USD"
defaults write NSGlobalDomain AppleMeasurementUnits -string "Inches"
defaults write NSGlobalDomain AppleMetricUnits -bool false
# 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
# Enable 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
# App Store: Download newly available updates in background
defaults write com.apple.SoftwareUpdate AutomaticDownload -int 1
# Turn on app auto-update
defaults write com.apple.commerce AutoUpdate -bool true
# ---- The items below should be last ----
# Restart things
killall Finder
killall Dock
# Add ssh key
test -f "$HOME/.ssh/id_rsa" || (ssh-keygen -t rsa -C "$(git config --get user.email)" -f "$HOME/.ssh/id_rsa" -P "" -q && ssh-add --apple-use-keychain "$HOME/.ssh/id_rsa")
test -f "$HOME/.ssh/config" || (cat >> "$HOME/.ssh/config" <<EOL
Host *
AddKeysToAgent yes
ForwardAgent yes
IdentityFile ~/.ssh/id_rsa
ServerAliveInterval 60
StrictHostKeyChecking no
UseKeychain yes
EOL
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment