Home > Mobile >  Change zsh prompt to only two folders
Change zsh prompt to only two folders

Time:10-21

I am using the oh-my-zsh theme jtriley. The theme code, reproduced below, displays the entire directory path:

PROMPT="%{$fg_bold[cyan]%}%T%{$fg_bold[green]%} %{$fg_bold[green]%}%d
%{$fg_bold[yellow]%}%% %{$reset_color%}"

I know that there are ways to change the displayed directories, using the prompt_dir() function, following instructions like these. However, when I insert this below the code above, I do not get a change.

How can I alter a theme file where the only code in it is the prompt, and its colors?

CodePudding user response:

For this particular use case, you can just replace %d with - in the first line.

However, if you want to do something fancier, you can replace it with \$(prompt_dir) instead, and set the PROMPT_SUBST option. The backslash is important, since that makes it so the function is re-evaluated each time the prompt is displayed, rather than just when $PROMPT is assigned.

  • Related