Last active
May 29, 2023 17:31
-
-
Save n8io/4b186015bb0be839c03bd46190081319 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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