Skip to content

Instantly share code, notes, and snippets.

@naingaungphyo
Forked from tomevans18/macSetup.sh
Created February 21, 2023 02:20
Show Gist options
  • Save naingaungphyo/b46f07936e514b148078967ec230855c to your computer and use it in GitHub Desktop.
Save naingaungphyo/b46f07936e514b148078967ec230855c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Install command-line tools using Homebrew.
# Ask for the administrator password upfront.
sudo -v
# Keep-alive: update existing `sudo` time stamp until the script has finished.
while true; do
sudo -n true
sleep 60
kill -0 "$$" || exit
done 2>/dev/null &
# Check for Homebrew, and then install it
if test ! "$(which brew)"; then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo "Homebrew installed successfully"
else
echo "Homebrew already installed!"
fi
# Install XCode Command Line Tools
echo 'Checking to see if XCode Command Line Tools are installed...'
brew config
# Updating Homebrew.
echo "Updating Homebrew..."
brew update
# Upgrade any already-installed formulae.
echo "Upgrading Homebrew..."
brew upgrade
# Update the Terminal
# Install oh-my-zsh
echo "Installing oh-my-zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
echo "Setting ZSH as shell..."
chsh -s /bin/zsh
# Install Git
echo "Installing Git..."
brew install git
# Install gnupg
echo "Installing gnupg..."
brew install gnupg
# Setup gnupg
echo "Use the following tutorial - https://docs.gitlab.com/ee/user/project/repository/gpg_signed_commits/"
gpg --full-gen-key
# Config Git
echo "Git config"
echo "What is your git user name?"
read gitUserName
echo "What is your git email?"
read gitEmail
git config --global user.name $gitUserName
git config --global commit.gpgsign true
git config --global credential.helper osxkeychain
git config --global gpg.program "/usr/local/bin/gpg"
# Helpful CLI tools
echo "Helpful CLI tools..."
brew install tree
brew install trash
# Node + yarn
echo "Installing Node and Yarn..."
echo "(You may need to downgrade Node to LTS)"
brew install node
brew install yarn --without-node
# Apps
apps=(
visual-studio-code
google-chrome
firefox
slack
1password
virtualbox
zoomus
figma
insomnia
)
# Install apps to /Applications
# Default is: /Users/$user/Applications
echo "installing apps with Cask..."
brew install --cask --appdir="/Applications" ${apps[@]}
# Remove outdated versions from the cellar.
echo "Running brew cleanup..."
brew cleanup
echo "Setting some Mac settings..."
#"Saving to disk (not to iCloud) by default"
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
#"Check for software updates daily, not just once per week"
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
#"Enabling full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
#"Enabling sort by kind for icons on the desktop and in other icon views"
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy kind" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy kind" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy kind" ~/Library/Preferences/com.apple.finder.plist
#"Use column view in all Finder windows by default"
defaults write com.apple.finder FXPreferredViewStyle Clmv
#"Showing icons for hard drives, servers, and removable media on the desktop"
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
#"Setting the icon size of Dock items to 42 pixels because thats the meaning of life"
defaults write com.apple.dock tilesize -int 42; killall Dock;
#"Avoiding the creation of .DS_Store files on network volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
#"Enabling Safari's debug menu"
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
#"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
#"Enabling UTF-8 ONLY in Terminal.app and setting the Pro theme by default"
defaults write com.apple.terminal StringEncodings -array 4
defaults write com.apple.Terminal "Default Window Settings" -string "Pro"
defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"
killall Finder
echo "You're done!"
echo "Restart your terminal to allow changes to take effect"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment