0

I was wondering how could I write this:

export PS1="\[\033[38;5;51m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\[$(tput sgr0)\]\[\033[38;5;10m\]\h\[$(tput sgr0)\]\[\033[38;5;226m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]\\$\[$(tput sgr0)\]"

in zsh, specifically the colors. This came from my .bashrc file and I want to keep it for my .zshrc file.

1

The key is this:

  • Every occurrence of \[\033[38;5;Nm\] becomes simply %NF.
  • Every occurrence of \[$(tput sgr0)\] becomes simply %f.
  • \u, \h, \w, and \$ become %n, %m, %~, and %#.

And make sure that you have the PROMPT_PERCENT shell option turned on.

You do not need to export this shell variable.

The manual that you should be reading is zshmisc.

2
  • Or info zsh 'Prompt Expansion' Mar 20 '20 at 18:05
  • also look at powerlevel10k and ohmyzsh, great answer @jdeBP
    – Woodstock
    Mar 20 '20 at 18:38

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.