Skip to content

Instantly share code, notes, and snippets.

@foray1010
Created April 3, 2018 14:46
Show Gist options
  • Save foray1010/39872348d58cebee673bff873515a6ef to your computer and use it in GitHub Desktop.
Save foray1010/39872348d58cebee673bff873515a6ef to your computer and use it in GitHub Desktop.
my init script for macos
#!/bin/bash
# set firmware password
sudo firmwarepasswd -setpasswd -setmode command
# enable firewall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
## do not response to ping
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode on
# remove untrustable certs
/usr/bin/curl https://raw.githubusercontent.com/chengr28/RevokeChinaCerts/master/Mac/TrustSettings.plist -o "$TMPDIR/TrustSettings.plist"
sudo security trust-settings-import -d "$TMPDIR/TrustSettings.plist"
# disable the Character Accent Menu and Enable Key Repeat
defaults write -g ApplePressAndHoldEnabled -bool false
# prevent reading .DS_Store on SMB drives to speed up loading
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# show absolute path in finder's title bar
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
# enable dark theme for dock and menu bar
osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to true'
##################
# setup Homebrew #
##################
# install Xcode with command line tools which is needed for Homebrew
xcode-select --install
xcodebuild -license accept
# install Homebrew
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# setup Homebrew tap
brew tap beeftornado/rmtree # remove a formula and its unused dependencies
brew tap buo/cask-upgrade # upgrade packages installed via `brew cask install` by `brew cu`
brew tap caskroom/cask
brew tap caskroom/fonts
################
# brew install #
################
brew install exa # new `ls` in rust
brew install fd # new `find` in rust
brew install mackup # sync software config in cloud
brew install neovim
brew install python3
brew install ripgrep # new `grep` in rust
brew install shellcheck # shellscript linter
brew install tldr # short version of `man` or `--help`
brew install wget # mac has `curl` by default but not `wget`
brew install yarn --without-node
# app store package manager
brew install mas
## install from app store
mas install 1063631769 # Medis
mas install 405399194 # Kindle
mas install 409203825 # Numbers
mas install 497799835 # Xcode
mas install 507257563 # Sip
mas install 568494494 # Pocket
# zsh
brew install zsh
## zsh plugin manager
brew install zplug
## use zsh as default shell
zshPath="$(which zsh)"
if grep "$zshPath" /etc/shells > /dev/null; then
echo "already contain $zshPath in /etc/shells"
else
echo "missing $zshPath in /etc/shells, adding..."
sudo sh -c "echo $zshPath >> /etc/shells"
fi
chsh -s "$zshPath"
# dev
## git
brew install git
### better gif diff
brew install diff-so-fancy
git config --global core.pager "diff-so-fancy | less --tabs=2 -RFX"
## react-native
brew install watchman
# devops
brew install awscli
# brew install kubectl # should be included by docker-edge
################
# cask install #
################
brew cask install appcleaner # *try to* completely remove an app
brew cask install authy
brew cask install bettertouchtool # allow mapping three finger tap to middle click
brew cask install charles
brew cask install clipy # clipboard manager
brew cask install cyberduck
brew cask install firefox
brew cask install flux # better night shift
brew cask install font-fira-code
brew cask install font-hack
brew cask install gas-mask # /etc/host manager
brew cask install google-backup-and-sync
brew cask install google-chrome
brew cask install grammarly
brew cask install imageoptim
brew cask install istat-menus
brew cask install iterm2
brew cask install kap # screen recorder
brew cask install kitematic # docker ui manager
brew cask install losslesscut # losslessly cut *.mp4
brew cask install onyx
brew cask install openvanilla # chinese input method provider
brew cask install remote-play # PS4 remote play
brew cask install shiftit # control windows size and location by keyboard
brew cask install skype
brew cask install slack
brew cask install spotify
brew cask install steam
brew cask install stretchly # breaktime reminder
brew cask install telegram
brew cask install telegram-desktop
brew cask install the-unarchiver # decompress *.7z, *.rar, etc
brew cask install tunnelblick
brew cask install virtualbox
brew cask install vlc
brew cask install whatsapp
# dev
brew cask install docker-edge # use docker-edge but not docker because k8s support
brew cask install ngrok
brew cask install postman
brew cask install reactotron
brew cask install robo-3t
brew cask install visual-studio-code
## react-native
brew cask install react-native-debugger
### java related
brew cask install caskroom/versions/java8
#### android
brew cask install android-sdk # intel-haxm included
brew cask install android-studio
# devops
brew cask install google-cloud-sdk
# brew cask install minikube # should be able to be replaced by docker-edge
################
# brew cleanup #
################
brew cleanup
brew cask cleanup
brew prune
################
# install Node #
################
nvm_latest_tag=$(curl -s https://api.github.com/repos/creationix/nvm/releases/latest | python3 -c "import sys, json; print(json.load(sys.stdin)['name'])")
curl -o- "https://raw.githubusercontent.com/creationix/nvm/$nvm_latest_tag/install.sh" | bash
## init nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
## install latest lts node
nvm install --lts
nvm alias default "lts/*"
echo "should clean .zshrc manually to remove nvm loading scripts as it is located in .zshenv"
########################
# start essential apps #
########################
apps=(
"/Applications/Backup and Sync.app"
"/Applications/BetterTouchTool.app"
"/Applications/Clipy.app"
"/Applications/Flux.app"
"/Applications/Gas Mask.app"
"/Applications/iStat Menus.app"
"/Applications/ShiftIt.app"
"/Applications/stretchly.app"
)
for app in "${apps[@]}"; do
if [ -s "$app" ]; then
echo "starting $app..."
open "$app"
else
echo "$app does not exist, please check if it is not needed anymore"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment