Formatting the Prompt

It is possible to truncate your prompt to fit into a fixed amount of space. man zshmisc for details, and look under the section PROMPT EXPANSION.

Additonal formatting escapes

There are some additional '%' escape sequences that control formatting of the prompt text that zsh displays:

%U Start underline mode
%u Stop underline mode

%B Start boldface mode
%b Stop boldface mode

%S Start standout mode
%s Stop standout mode

%{...%}
        Include a string as a literal escape sequence. The
        string within the braces should not change the cursor
        position. Brace pairs can nest. This can be used to put
	color in your prompt. (See below)

A Quick Note

If you would like to use the current history event number in your prompt without needing a % escape sequence, make sure to turn on the PROMPT_BANG shell option. This allows you to use ! (bang) in your prompt strings for the current history event number. If you would like an actual ! to be displayed in your prompt, use !! in your prompt string.