Out of the box, using terminal in OSX is pretty abysmal. The built-in terminal application is inflexible and ugly, to say nothing of bash itself which is missing several handy tools that, once you’ve used them, you’ll wonder how you ever got along without them.
Homebrew
Homebrew is the missing package manager for OSX. It’s essential to developing on a mac.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Note: this should install xcode automatically if necessary, but if it doesn’t, run sudo xcode-select --install
Handy brew Commands
brew doctor
- self-check, run if things are brokenbrew search SOMETHING
- searches forSOMETHING
package, but checking online might be easier.brew list --versions
- show all installed packages and versionsbrew install git
/brew uninstall git
/brew upgrade git
brew update
/brew upgrade
- updates apps or all packages, respectivelybrew outdated
- show available upgrades
Install Non-Open Source Software
No more “Drag this icon to install…”, brew cask
installs OSX apps: brew cask install firefox
Browse a list of available casks then easily install. Notable apps available this way are:
Iterm
A much more powerful and flexible terminal that is also light and doesn’t over-use resources; run brew cask install iterm2
The Z Shell
The zsh
(or “Z”) shell is built on top of bash
with additional features. It works best with a framework for plugins running on top of it, Oh My Zsh
being one of the best.
brew install zsh
brew install wget
- so the next command runs correctlysh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo $0
should print-zsh
but if not, you can setzsh
as your default shell manually:chsh -s $(which zsh)
All the configuration for ZSH is in ~/.zshrc
. After making changes to that file, run source ~/.zshrc
to load the changes.
Auto Suggestions
This is easily one of the most powerful plugins for anyone who uses the terminal frequently. ZSH Auto Suggestions simply auto-completes as you type based on previously executed commands (ready from you bash history).
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
to install this plugin.- Add
zsh-autosuggestions
to your plugins list in~/.zshrc
(see below for a full list of plugins)
Spaceship Theme
The Spaceship Prompt is a completely optional, but handy add-on to ZSH that includes a very useful terminal display, showing the current git branch, branch status, success or failure of the previous command, and much more.
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"
to install this theme.ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"
to link the theme correctly.- Set
ZSH_THEME="spaceship"
in your.zshrc
(but see below for a fuller list of customizations).
There are many other themes to choose from as well.
Recommended .zshrc
Override the default “robbyrussell” theme with “spaceship” plus some recommended settings:
#ZSH_THEME="robbyrussell"
ZSH_THEME="spaceship"
SPACESHIP_USER_SHOW="false"
SPACESHIP_HOST_SHOW="false"
SPACESHIP_PHP_SHOW="false"
SPACESHIP_PROMPT_ADD_NEWLINE="true"
SPACESHIP_DIR_TRUNC_PREFIX=".../"
SPACESHIP_DIR_TRUNC_REPO="false"
Recommended plugins:
plugins=(git colorize pip python brew osx zsh-autosuggestions)
You might also consider some convenience aliases (add to the bottom of the .zshrc
file):
alias ls='ls --color=auto -lhapG' # prettier output of ls, includes dir slashes
alias gs='git status'
# git add --all
alias gaa='git add --all'
# git commit -m (you can supply the message as such:)
# gcm 'my commit message'
alias gcm='git commit -m '
From here add whatever other aliases you find useful!