The macOS Monterey system uses zsh shell instead of bash, and I want to convert this bash command which you'd normally store in a .bash_profile file

export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$"

into a zsh command to store in a .zshrc file in the home directory.
Does anyone have any suggestions?

2 Answers 2


It took me a while to figure this out, but I thought I'd post the answer here in case someone finds this helpful. This is the zsh equivalent to the above bash prompt

export PS1=$'\033[36m%n\033[m@\033[32m%m:\033[33;1m%~\033[m\$'
  • zsh doesn't require you to identify the non-printable bits? Dec 28, 2021 at 0:56
  • Appreciate you coming back and posting this.
    – MEMark
    Apr 5 at 7:16

With zsh you can use percent expansions in the prompt, which may be a bit easier to read than the terminal escape sequences:

PROMPT='%F{cyan}%n%f@%F{green}%m:%F{yellow}%~%f$ '

Here %F is 'start foreground color', and %f is 'stop color'. %n, %m and %~ are replaced with the user name, host name, and current directory. The full set of % substitutions is listed in the zshmisc man page.

You can also use xterm color numbers if you get tired of the small set of named colors:

PROMPT='%F{39}%n%f@%F{119}%m:%F{227}%~%f %F{240}[%*]%f%# ' 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .