Skip to main content

Change Terminal Prompt on Mac

Published: 2019-10-19 • Last updated: 2021-05-03

Your Terminal prompt is controlled via the PS1 Bash environment variable . It’s initially defined in /etc/bashrc, and its default value is:

'\h:\W \u\$ '

See the GNU Bash reference manual for available prompt config options.

Once you find the options you like, update PS1 in your Bash config file, e.g. ~/.bash_profile, for example:

current_git_branch() {
  local branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
  if [[ -n $branch ]]; then
    echo "($branch)"

export PS1='\u @ \h in \w $(current_git_branch)\n\$ '

The above will display a prompt like so:

user @ host in /path/to/current/dir (current_git_branch)