Skip to content

Instantly share code, notes, and snippets.

@alex-cory
Last active January 4, 2023 14:53
Show Gist options
  • Save alex-cory/eb5bac32a6c9f7a82f256ce1a9454dd2 to your computer and use it in GitHub Desktop.
Save alex-cory/eb5bac32a6c9f7a82f256ce1a9454dd2 to your computer and use it in GitHub Desktop.
My mac setup
#!/usr/bin/env bash
#
# BUGS:
# 1. not adding settings to .zshrc from below (i.e. default theme, packages, custom functions, etc.)
# 2. not auto-hiding doc
# 3. not auto-hiding menu bar
# 4. not adding .vimrc
# 5. not automatically copying iTerm profile, Option + Space not setup to toggle iTerm, doesn't default to opening iTerm at startup
#
# Bootstrap script for setting up a new OSX machine
#
# 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/
# - https://github.com/bramus/freshinstall/blob/master/steps/1.macos-settings.sh
# https://macos-defaults.com/
# - https://github.com/FelixKratz/SketchyBar
# - https://github.com/dylanaraps/neofetch
# - https://github.com/aristocratos/btop
echo "Starting bootstrapping"
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
echo "Please add this public key to Github \n"
echo "https://github.com/account/ssh \n"
read -p "Press [Enter] key after this..."
# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
echo "Installing homebrew..."
# OLD: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Update homebrew recipes
echo "Updating homebrew..."
brew update
echo "Installing Git..."
# brew install git
echo "Git config"
git config --global user.name "Alex Cory"
git config --global user.email [email protected]
# allow git to pull authentication from your keychain
# you might not want this. Do your research
git config --global credential.helper osxkeychain
# Want to know more cool packages? See here: https://github.com/alebcay/awesome-shell
PACKAGES=(
ack
cask
exa # colorful ls (ex: exa -labg)
git
hub
htop
httpie # better curl
hstr # better history - ctrl + r
jq # like sed but for json
lynx # cli web browser. maybe "links" is better
markdown
mosh # better ssh
npm
python
python3
pypy
rename
ssh-copy-id
terminal-notifier
ag # the silver searcher
tmux
tree
vim
wget
pngpaste
TomAnthony/brews/itermocil
yarn # better npm
wifi-password
github/gh/gh # github cli
coreutils # Directory listings for zsh with git features: https://github.com/supercrabtree/k
mackup # Keep your application settings in sync.: https://github.com/lra/mackup/
bat # Better `cat` command https://github.com/sharkdp/bat
)
echo "Installing packages..."
brew install ${PACKAGES[@]}
# install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# make zsh the default shell
chsh -s $(which zsh)
echo "Installing apps..."
brew cask install google-chrome
# chrome setings
# 🚫 - duplicate tab shortcut: ⌥ + shift + D (chrome extension: http://bit.ly/2YG03aD)
# 🚫 - open chrome extentions keyboard shortcut: ⌘ + ,
# hide desktop items
defaults write com.apple.finder CreateDesktop false; killall Finder
# Trackpad: enable tap to click for this user and for the login screen
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
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 0
# Set the icon size of Dock items to 36 pixels
# defaults write com.apple.dock tilesize -int 36
# Wipe all (default) app icons from the Dock
# This is only really useful when setting up a new Mac, or if you don’t use
# the Dock to launch apps.
#defaults write com.apple.dock persistent-apps -array
# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true
# Definitions
# 🚫 Not Implemented
# 🧪 Requires Testing - might not work
# ✅ Works -- on Macbook 15 pro 2019 - Intel - macOS Monterey 12.6
# mac settings TODO:
# 🧪 - 3 finger drag - https://tinyurl.com/2qfnsks2
# defaults -currentHost write NSGlobalDomain com.apple.trackpad.threeFingerSwipeGesture -int 1
# 🚫 - mouse speed 100%
# 🚫 - black theme
# 🚫 - auto-hide menu bar
# 🚫 - auto-hide doc
# 🚫 - doc size: 15%
# 🚫 - doc magnification: 80%
# 🚫 - caps lock key -> ctrl
echo "Copy the following lines into you ~/.zshrc"
tee -a ~/.zshrc > /dev/null <<EOT
plugins=(git node npm extract z yarn colored-man-pages colorize pip python brew macos zsh-syntax-highlighting zsh-autosuggestions dirhistory history)
ZSH_THEME="nicoulaj"
alias gd="git diff -- ':!package-lock.json' ':!yarn.lock'"
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias ggcm='git add --all && git commit -m'
alias .z='vim ~/.zshrc'
touch() {
for p in "$@"; do
_dir="$(dirname -- "$p")"
[ -d "$_dir" ] || mkdir -p -- "$_dir"
command touch -- "$p"
done
}
EOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment