Zsh: Oh My Zsh – customise prompt / PS1


vim +92 ~/.oh-my-zsh/custom/themes/agnoster.zsh-theme

and change prompt from

prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"


prompt_segment black default "%(!.%{%F{yellow}%}.)text-you-want-to-appear"

then source it with:

. ~/.zshrc



I put my custom theme in:





Editing the PS1 means changing the PROMPTvariable which looks like this:

PROMPT='%{%f%b%k%}$(build_prompt) '


From man zshmisc

Include a string as a literal escape sequence. The string within the braces
should not change the cursor position. Brace pairs can nest.

A positive numeric argument between the % and the { is treated as described for
%G below.



%F (%f)
Start (stop) using a different foreground colour, if supported by the terminal.
The colour may be specified two ways: either as a numeric argument, as normal,
or by a sequence in braces following the %F, for example %F{red}. In the lat-
ter case the values allowed are as described for the fg zle_highlight
attribute; see Character Highlighting in zshzle(1). This means that numeric
colours are allowed in the second format also.

%B (%b)
Start (stop) boldface mode

%K (%k)
Start (stop) using a different bacKground colour. The syntax is identical to
that for %F and %f.



I wanted to remove my username which would point to this:





%m The hostname up to the first .'. An integer may follow the %’ to specify how
many components of the hostname are desired. With a negative integer, trailing
components of the hostname are shown.


Leave a Reply

Your email address will not be published. Required fields are marked *