1

I had recently updated Terminal to use zsh, after doing so the prompt on new terminal windows now displays: \[\033[1;92m\]\h:\[\033[0m\] \[\033[0;34m\][\W]\[\033[0m\] \[\033[0;31m\]\u$\[\033[0m\] rather than customized prompt I had set up previously.

Any suggestions for updating the bash profile to display customized prompts again within Terminal or cleaning up the default Terminal prompt to display desired device name, path, etc. using the zsh-based profile?

1
0

Prompt escape sequences are different in bash and zsh. The functionality is similar, but the syntax is completely different. You need to translate your bash setting to zsh syntax.

The prompt goes into the PS1 variable in both cases. (There are other possibilities but you don't need to use them.) The setting goes into .zshrc. So you need to add a line like this to your .zshrc:

PS1=$'%{\e[1;92m%}%m:…'

I started the translation: bash's \[…\] around zero-width constructs becomes zsh's %{…%}, the escape character expressed as \033 in bash is $'\e' in zsh, the host name is \h in bash and %m in zsh...

1
  • In zsh, you'd rather use %B%F{10} or %B%F{#00ff00} to say bold and bright green foreground. May 13 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.