macOS Terminal shell configuration

macOS Terminal works much like other operating systems, albeit with distinct keybindings from Linux et al.

Under Terminal → Settings → Profile → Shell: “When the shell exists” pick “close if the shell exited cleanly”. This allows Control+D to exit Terminal like on Linux.

To set environment variables across Terminal sessions, put them in file ~/.zshrc. ~/.zshrc even works if one SSH’s into a macOS computer. A typical ~/.zshrc for developers might include:

export PS1="%1~ %# "

This removes the name@machine to declutter the Terminal prompt.

export EDITOR=nano

This sets the default text editor for many programs to nano, which makes operations easy for programs including Git

export CMAKE_GENERATOR=Ninja

This sets the default CMake generator to Ninja.

Matlab path can also be set.