Last active
June 6, 2021 08:16
-
-
Save thatkookooguy/b6ec01aed3506280722dd52d033c9df3 to your computer and use it in GitHub Desktop.
thatkookooguy osx bootstrap
This file contains hidden or 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
#!/usr/bin/env bash | |
# | |
# Bootstrap script for setting up a new OSX machine | |
# | |
# This should be idempotent so it can be run multiple times. | |
# | |
# Some apps don't have a cask and so still need to be installed by hand. These | |
# include: | |
# | |
# - Twitter (app store) | |
# - Postgres.app (http://postgresapp.com/) | |
# | |
# Notes: | |
# | |
# - If installing full Xcode, it's better to install that first from the app | |
# store before running the bootstrap script. Otherwise, Homebrew can't access | |
# the Xcode libraries as the agreement hasn't been accepted yet. | |
# | |
# Reading: | |
# | |
# - http://lapwinglabs.com/blog/hacker-guide-to-setting-up-your-mac | |
# - https://gist.github.com/MatthewMueller/e22d9840f9ea2fee4716 | |
# - https://news.ycombinator.com/item?id=8402079 | |
# - http://notes.jerzygangi.com/the-best-pgp-tutorial-for-mac-os-x-ever/ | |
# helpers | |
function echo_ok() { echo -e '\033[1;32m'"$1"'\033[0m'; } | |
function echo_warn() { echo -e '\033[1;33m'"$1"'\033[0m'; } | |
function echo_error() { echo -e '\033[1;31mERROR: '"$1"'\033[0m'; } | |
echo_ok "Install starting. You may be asked for your password (for sudo)." | |
# requires xcode and tools! | |
xcode-select -p || exit "XCode must be installed! (use the app store)" | |
# homebrew | |
export HOMEBREW_CASK_OPTS="--appdir=/Applications" | |
if hash brew &>/dev/null; then | |
echo_ok "Homebrew already installed. Getting updates..." | |
brew update | |
brew doctor | |
else | |
echo_warn "Installing homebrew..." | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
fi | |
# Update homebrew recipes | |
brew update | |
# Install GNU core utilities (those that come with OS X are outdated) | |
# brew tap homebrew/dupes | |
# brew install coreutils | |
# brew install gnu-sed --with-default-names | |
# brew install gnu-tar --with-default-names | |
# brew install gnu-indent --with-default-names | |
# brew install gnu-which --with-default-names | |
# brew install gnu-grep --with-default-names | |
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed | |
# brew install findutils | |
# Install Bash 4 | |
brew install bash | |
PACKAGES=( | |
ansible # Ansible is an open-source software provisioning, configuration management, and application-deployment tool | |
awscli # AWS Command Line Interface | |
aws-elasticbeanstalk # AWS Elastic Beanstalk | |
bash-completion | |
bash-git-prompt | |
cask # Homebrew-Cask extends Homebrew and allows you to install large binary files via a command-line tool. You can for example install applications like Google Chrome, Dropbox, VLC and Spectacle | |
cookiecutter # PYTHON: A command-line utility that creates projects from cookiecutters (project templates) | |
curl | |
dep | |
flake8 # PYTHON: Your Tool For Style Guide Enforcemen | |
gist # The gist gem provides a gist command that you can use from your terminal to upload content to https://gist.github.com/. | |
git | |
glances # Alternative to top/htop | |
go-delve/delve/delve # Delve is a debugger for the Go programming language. | |
grafana # Grafana is the open source analytics and monitoring solution for every database | |
graphviz # Graph Visualization Software | |
hh | |
hicolor-icon-theme | |
htop | |
hugo | |
influxdb | |
jq # jq is a lightweight and flexible command-line JSON processor. | |
kubernetes-cli # Kubernetes command-line interface | |
kubernetes-helm # The Kubernetes package manager | |
mackup | |
mariadb | |
midnight-commander | |
# node # Commented out since it will be installed using NVM | |
openssl | |
p7zip | |
pandoc | |
pipenv | |
python3 | |
pyenv | |
pyenv-virtualenv | |
shellcheck | |
shfmt | |
ssh-copy-id | |
terraform | |
terminal-notifier | |
the_silver_searcher | |
thefuck | |
tree | |
watch | |
wget | |
xz | |
youtube-dl # youtube-dl is a command-line program to download videos from YouTube.com and a few more sites. | |
zsh | |
zsh-completions | |
) | |
echo_ok "Installing packages..." | |
brew install "${PACKAGES[@]}" | |
echo_ok "Installing AWS tools" | |
brew tap aws/tap | |
brew install aws-sam-cli # sam is the AWS CLI tool for managing Serverless applications written with AWS Serverless Application Model (SAM) | |
echo_ok "Cleaning up..." | |
brew cleanup | |
echo_ok "Installing cask..." | |
# brew install caskroom/cask/brew-cask | |
brew tap caskroom/cask | |
CASKS=( | |
adobe-acrobat-reader | |
alfred # Productivity App for macOS | |
appcleaner # AppCleaner is a small application which allows you to thoroughly uninstall unwanted apps. | |
appzapper # The uninstaller Apple forgot. (pretty much the same as appcleaner) | |
cakebrew # The Mac App for Homebrew. (UI) | |
calibre # E-book management | |
cyberduck # Cyberduck is a libre server and cloud storage browser for Mac & Windows | |
daisydisk # DaisyDisk is a paid disk space analyzer for macOS | |
deluge # Torrent Client | |
docker # Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. | |
flycut # Clipboard manager | |
github # GitHub Desktop simplifies your development workflow. git UI | |
google-chrome # Well.... Google Chrome | |
google-cloud-sdk # The Cloud SDK is a set of command-line tools for developing with Google Cloud | |
google-hangouts # Chat developed by google. Supports video calls etc. | |
iterm2 # iTerm2 is a GPL-licensed terminal emulator for macOS | |
keka # the macOS file archiver | |
kindle # Amazon's Ebook manager | |
lingon-x # An easy to use yet powerful app to run things automatically | |
macvim # MacVim is a port of the text editor Vim to Mac OS X that is meant to look better and integrate more seamlessly with the Mac than the older Carbon port of Vim | |
qbittorrent # qBittorrent is a cross-platform free and open-source BitTorrent client | |
qlstephen # A QuickLook plugin that lets you view plain text files without a file extension | |
skitch # Image editor that enables you to easily take screenshots | |
slack # Slack is a cloud-based proprietary instant messaging platform | |
spotify # Spotify app for listening to music | |
spotify-notifications # Bridging Spotify and OS X Notification Center | |
teamviewer # remote control, desktop sharing, online meetings, web conferencing and file transfer between computers | |
vagrant # Vagrant is an open-source software product for building and maintaining portable virtual software development environments, e.g. for VirtualBox, KVM, Hyper-V, Docker containers, VMware, and AWS. It tries to simplify the software configuration management of virtualizations in order to increase development productivity. | |
virtualbox # free and open-source hosted hypervisor for x86 virtualization | |
visual-studio-code # Visual Studio Code is a source-code editor developed by Microsoft | |
vlc # free and open-source portable cross-platform media player | |
gitkraken # Free Git GUI | |
vnc-viewer # Remote control using vnc | |
biscuit # Biscuit is a browser where you can organize your most-used apps | |
hyper # A terminal built on web technologies | |
paragon-ntfs # Paragon NTFS for Mac (read\write NTFS drives) | |
bluestacks # Run android apps on your PC\MAC | |
dbeaver-community # SQL client software application and a database administration tool | |
# dbeaver-enterprise # enterprize addition of above software | |
kubernetic # The Kubernetes Desktop Client | |
KeyCastr # Show keyboard clicks for screen recordings | |
camtasia # record and create professional-looking videos | |
image2icon # Create and personalize icons from your pictures | |
vysor # Remote control your android devices | |
dropdmg # The easiest way to create and work with Mac disk images (.dmg files). | |
1clipboard # A universal clipboard managing app that makes it easy to access your clipboard from anywhere on any device. | |
gpg-suite # a tool to manage gpgs (mostly for github commits?) | |
now # optimal workflow for frontend teams. Deploy in a single cli command | |
) | |
echo_ok "Installing cask apps..." | |
brew cask install "${CASKS[@]}" | |
# brew cask quicklook | |
# breakdown: | |
# - qlcolorcode - Quick look in finder for source code with syntax highlighting | |
# - qlmarkdown - Quick look for markdown files | |
# - qlprettypatch - Quick look for version control patch files. Shows a diff between the two versions | |
# - qlstephen - Quick look for common files without extensions like README, CHANGELOG, etc. | |
# - qlimagesize - Quick look for images that displays the dimensions, DPI and file size of an image in the title bar. This plugin can also preview and generate Finder thumbnails for natively unsupported images formats bpg and WebP. | |
# - quicklook-csv - Quick look CSV files | |
# - quicklook-json - Quick look JSON files [http://www.sagtau.com/quicklookjson.html] | |
echo_ok "Installing QuickLook Plugins..." | |
brew cask install \ | |
qlcolorcode qlmarkdown qlprettypatch qlstephen \ | |
qlimagesize \ | |
quicklook-csv quicklook-json epubquicklook | |
echo_ok "Installing fonts..." | |
# Installing powerline fonts for zsh and special characters in terminal | |
# Installing some fonts I prefer for vscode | |
brew tap caskroom/fonts | |
FONTS=( | |
font-clear-sans | |
font-consolas-for-powerline | |
font-dejavu-sans-mono-for-powerline | |
font-fira-code | |
font-fira-mono-for-powerline | |
font-inconsolata | |
font-inconsolata-for-powerline | |
font-liberation-mono-for-powerline | |
font-menlo-for-powerline | |
font-roboto | |
font-hack # font for terminals and monospace in general | |
font-comfortaa # kibibit's font | |
font-righteous # kibibit's font | |
) | |
brew cask install "${FONTS[@]}" | |
echo_ok "Installing Python packages..." | |
PYTHON_PACKAGES=( | |
ipython | |
virtualenv | |
virtualenvwrapper | |
) | |
sudo pip install "${PYTHON_PACKAGES[@]}" | |
echo_ok "Installing Ruby gems..." | |
# Tools used for developing ruby | |
# - bundler - Bundler is an exit from dependency hell, and ensures that the gems you need are present in development, staging, and production. Starting work on a project is as simple as bundle install. | |
# - rake - A make-like build utility for Ruby. something like gradle, grunt, etc. | |
RUBY_GEMS=( | |
bundler | |
rake | |
) | |
sudo gem install "${RUBY_GEMS[@]}" | |
echo_ok "Installing global npm packages..." | |
npm install -g slap@latest # Slap is a Sublime-like terminal-based text editor that strives to make editing from the terminal easier | |
npm install -g vtop # A graphical activity monitor for the command line. | |
npm install -g nodemon # Automatically restarting the node application when file changes in the directory are detected | |
npm install -g npm-name-cli # Check whether a package or organization name is available on npm | |
npm install -g ndb # ndb is an improved debugging experience for Node.js, enabled by Chrome DevTools | |
npm install -g tldr # Simplified and community-driven man pages | |
npm install -g spoof # Easily spoof your MAC address in macOS, Windows, & Linux! https://feross.org/spoofmac/ | |
npm install -g fkill-cli # Fabulously kill processes. Cross-platform. | |
echo_ok "Installing oh my zsh..." | |
if [[ ! -f ~/.zshrc ]]; then | |
echo '' | |
echo '##### Installing oh-my-zsh...' | |
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh | |
cp ~/.zshrc ~/.zshrc.orig | |
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc | |
chsh -s /bin/zsh | |
echo '' | |
echo '##### Installing oh-my-zsh plugins...' | |
git clone https://github.com/lukechilds/zsh-nvm ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-nvm | |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting | |
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions | |
git clone [email protected]:zdharma/history-search-multi-word.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/history-search-multi-word | |
git clone https://github.com/wbingli/zsh-wakatime.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/wakatime | |
curl | |
echo_ok '##### Finished installing oh-my-zsh plugins' | |
echo '##### Applying oh-my-zsh plugins...' | |
countAgnosterzak=$(grep -c "agnosterzak" ~/.zshrc) | |
if [ $countAgnosterzak != 0]; then | |
echo "Found agnosterzak. Skipping theme changing" | |
else | |
sed -i '' 's/ZSH\_THEME\=\"robbyrussell\"/ZSH_THEME\=\"agnosterzak\"/' ~/.zshrc | |
fi | |
countAgnosterzak=$(grep -c "zsh-autosuggestions" ~/.zshrc) | |
if [ $countAgnosterzak != 0]; then | |
echo "Found plugins. Skipping adding plugins" | |
else | |
sed -i '' 's/\(^plugins=([^)]*\)/\1 zsh-autosuggestions zsh-syntax-highlighting zsh-nvm history-search-multi-word wakatime/' .zshrc | |
fi | |
countPromptNodeJs=$(grep -c "prompt_nodejs()" ~/.zshrc) | |
if [ $countPromptNodeJs != 0]; then | |
echo "Found agnoster prompts. Skipping injection" | |
else | |
echo " | |
prompt_kubectx() { | |
prompt_segment 209 19 "\u2388 " # Symbol | |
prompt_segment 209 17 "$(kubectl config current-context 2>/dev/null)" # Cluster | |
prompt_segment 209 26 "$(kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)" # Namespace | |
} | |
prompt_nodejs() { | |
local node_info="$(node /Users/nkalman/.oh-my-zsh/node_prompt/index.js)" | |
if [[ -n $node_info ]]; then | |
prompt_segment 34 15 "$node_info" | |
fi | |
} | |
build_prompt() { | |
RETVAL=$? | |
print -n "\n" | |
prompt_status | |
prompt_battery | |
prompt_time | |
prompt_virtualenv | |
prompt_dir | |
prompt_git | |
prompt_hg | |
prompt_kubectx | |
prompt_nodejs | |
prompt_end | |
CURRENT_BG='NONE' | |
print -n "\n" | |
prompt_context | |
prompt_end | |
} | |
" >>~/.zshrc | |
fi | |
echo_ok '##### Finished applying oh-my-zsh plugins' | |
fi | |
echo_ok "Configuring Github" | |
if [[ ! -f ~/.ssh/id_rsa ]]; then | |
echo '' | |
echo '##### Please enter your github username: ' | |
read github_user | |
echo '##### Please enter your github email address: ' | |
read github_email | |
# setup github | |
if [[ $github_user && $github_email ]]; then | |
# setup config | |
git config --global user.name "$github_user" | |
git config --global user.email "$github_email" | |
git config --global github.user "$github_user" | |
# git config --global github.token your_token_here | |
git config --global color.ui true | |
git config --global push.default current | |
# VS Code support | |
git config --global core.editor "code --wait" | |
# set rsa key | |
curl -s -O http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain | |
chmod u+x git-credential-osxkeychain | |
sudo mv git-credential-osxkeychain "$(dirname $(which git))/git-credential-osxkeychain" | |
git config --global credential.helper osxkeychain | |
# generate ssh key | |
cd ~/.ssh || exit | |
ssh-keygen -t rsa -C "$github_email" | |
pbcopy <~/.ssh/id_rsa.pub | |
echo '' | |
echo '##### The following rsa key has been copied to your clipboard: ' | |
cat ~/.ssh/id_rsa.pub | |
echo '##### Follow step 4 to complete: https://help.github.com/articles/generating-ssh-keys' | |
ssh -T [email protected] | |
fi | |
fi | |
echo_ok "Installing VS Code Extensions..." | |
VSCODE_EXTENSIONS=( | |
dbaeumer.vscode-eslint | |
msjsdiag.debugger-for-chrome | |
formulahendry.auto-close-tag | |
formulahendry.auto-rename-tag | |
eamodio.gitlens | |
wix.vscode-import-cost | |
Orta.vscode-jest | |
wayou.vscode-todo-highlight | |
MS-vsliveshare.vsliveshare | |
vscode-icons-team.vscode-icons | |
EliverLara.andromeda | |
github.vscode-pull-request-github | |
CoenraadS.bracket-pair-colorizer | |
AlanWalk.markdown-toc | |
DavidAnson.vscode-markdownlint | |
PeterJausovec.vscode-docker | |
Shan.code-settings-sync | |
Zignd.html-css-class-completion | |
anseki.vscode-color | |
christian-kohler.npm-intellisense | |
christian-kohler.path-intellisense | |
codezombiech.gitignore | |
dansilver.typewriter | |
donjayamanne.githistory | |
dracula-theme.theme-dracula | |
eg2.vscode-npm-script | |
ipedrazas.kubernetes-snippets | |
loganarnett.lambda-snippets | |
lukehoban.Go | |
mohsen1.prettify-json | |
monokai.theme-monokai-pro-vscode | |
ms-python.python | |
waderyan.gitblame | |
foxundermoon.shell-format | |
timonwong.shellcheck | |
angular.ng-template | |
hardikpthv.angularmaterial | |
stringham.angular-template-formatter | |
allenlawrence.auto-mongodb | |
auchenberg.vscode-browser-preview | |
formulahendry.code-runner | |
oliversturm.fix-json | |
kenhowardpdx.vscode-gist | |
mhutchie.git-graph | |
github.vscode-pull-request-github | |
ritwickdey.liveserver | |
ms-vsliveshare.vsliveshare | |
attilabuti.vscode-mjml | |
nrwl.angular-console | |
mrmlnc.vscode-postcss-sorting | |
rust-lang.rust | |
litleleprikon.socket-io-vscode | |
zengxingxin.sort-js-object-keys | |
sourcegraph.sourcegraph | |
jock.svg | |
vitaliymaz.vscode-svg-previewer | |
felixrieseberg.vsc-travis-ci-status | |
ms-vscode.vscode-typescript-tslint-plugin | |
jvitor83.types-autoinstaller | |
aljazsim.tsco | |
rbbit.typescript-hero | |
octref.vetur | |
ashinzekene.nestjs | |
wakatime.vscode-wakatime | |
redhat.vscode-yaml | |
ms-kubernetes-tools.vscode-kubernetes-tools | |
visualstudioexptteam.vscodeintellicode | |
) | |
if hash code &>/dev/null; then | |
echo_ok "Installing VS Code extensions..." | |
for i in "${VSCODE_EXTENSIONS[@]}"; do | |
code --install-extension "$i" | |
done | |
fi | |
echo_ok "Configuring OSX..." | |
# Set fast key repeat rate | |
# The step values that correspond to the sliders on the GUI are as follow (lower equals faster): | |
# KeyRepeat: 120, 90, 60, 30, 12, 6, 2 | |
# InitialKeyRepeat: 120, 94, 68, 35, 25, 15 | |
defaults write NSGlobalDomain KeyRepeat -int 6 | |
defaults write NSGlobalDomain InitialKeyRepeat -int 25 | |
# Always show scrollbars | |
defaults write NSGlobalDomain AppleShowScrollBars -string "Always" | |
# 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 | |
# Expanded Save menu | |
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true | |
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true | |
# Expanded Print menu | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true | |
# Disable tap-to-click | |
# defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool false | |
# defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 | |
# Disable "natural" scroll | |
# defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false | |
echo_ok 'Running OSX Software Updates...' | |
sudo softwareupdate -i -a | |
echo_ok "Creating folder structure..." | |
#[[ ! -d Wiki ]] && mkdir Wiki | |
[[ ! -d Development ]] && mkdir Development | |
echo_ok "Bootstrapping complete" | |
echo_ok "kibibit is awesome" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment