Custom command prompt in Terminal
First appeared on munwr · Updated
I prefer a simple command prompt, but the default one is pretty ugly: user name, computer name and folder before every command. A simple $ is enough to tell me where to type.
munawar@MacBook-Pro ~ %
macOS today: zsh
When I wrote this in 2017, macOS used bash. Since macOS Catalina (2019) the default shell is zsh, which reads its settings from ~/.zshrc.
Open the file in nano:
nano ~/.zshrc
Add this line:
PROMPT='$ '
Save with Control + O and Enter, then exit with Control + X. Reload the settings:
source ~/.zshrc
bash (macOS before 2019, and most Linux)
This is what the original post did. The setting goes in ~/.bash_profile on macOS, or ~/.bashrc on most Linux systems:
nano ~/.bash_profile
export PS1="$ "
source ~/.bash_profile
The 2017 post opened the file with sudo nano. You don't need sudo: the file is in your own home folder, and editing it as root can leave it owned by root, so your user can't change it later.
$
Going a bit further
A plain $ hides which folder you are in. If you miss that, show just the current folder name:
# zsh
PROMPT='%1~ $ '
# bash
export PS1='\W $ '
You can go as creative as you like by changing the text in quotes. Tools like Starship give you a fancy prompt with Git status and more, but for me, short and quiet still wins.