Practical macOS Terminal Setup

A terminal setup should remove friction, not become a second operating system that needs weekly maintenance. These are the few tweaks I still find useful.

Show the current Git branch

Modern macOS uses Zsh by default. Add this to ~/.zshrc:

1
2
3
4
5
6
autoload -Uz vcs_info
precmd() { vcs_info }

zstyle ':vcs_info:git:*' formats ' (%b)'
setopt PROMPT_SUBST
PROMPT='%n@%m %F{green}%~%f${vcs_info_msg_0_} $ '

Reload the shell:

1
source ~/.zshrc

If you intentionally use Bash, put the equivalent prompt configuration in ~/.bash_profile or ~/.bashrc. Editing a Bash file while running Zsh is a surprisingly effective way to configure absolutely nothing.

Install the VS Code command

In VS Code:

  1. Press Command + Shift + P.
  2. Run Shell Command: Install ‘code’ command in PATH.
  3. Open a project with:
1
code .

Install the Sublime Text command

The safest option is Sublime Text’s Tools → Install Command Line Tool. If that option is unavailable, create the symlink manually:

1
2
3
sudo ln -sf \
"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" \
/usr/local/bin/subl

On Apple Silicon, make sure /usr/local/bin exists and is included in PATH.

Final note

Keep shell configuration small and version-controlled, but never commit credentials, tokens, or private keys. A pretty prompt is useful. A pretty prompt containing an AWS secret is performance art.

References