Zsh prompt generator

user@hostname ~/path/to/directory $
export PS1="%{$(tput setaf 226)%}%n%{$(tput setaf 220)%}@%{$(tput setaf 214)%}%m %{$(tput setaf 33)%}%1~ %{$(tput sgr0)%}$ "

zsh prompt PS1

To use the colors you chose, set the PS1 environment variable in your shell:

export PS1="%{$(tput setaf 226)%}%n%{$(tput setaf 220)%}@%{$(tput setaf 214)%}%m %{$(tput setaf 33)%}%1~ %{$(tput sgr0)%}$ "export PS1="%{%F{226}%}%n%{%F{220}%}@%{%F{214}%}%m %{%F{33}%}%1~ %{%f%}$ "

It's up to you to decide between tput and zsh prompt escapes. To persist your customized prompt, export PS1 in ~/.zshrc or ~/.zsh_profile

zsh prompt examples

These are some example color schemes from choosing 4 colors above. Click on the zsh prompt previews to view their tput and ANSI PS1 exports.

user@hostname ~/path/to/directory $
Emerald green
user@hostname ~/path/to/directory $
Lemon line
user@hostname ~/path/to/directory $
Fiery orange
user@hostname ~/path/to/directory $
Autumn leaves
user@hostname ~/path/to/directory $
Desert sand
user@hostname ~/path/to/directory $
Ocean blue
user@hostname ~/path/to/directory $
Blue green yellow
user@hostname ~/path/to/directory $
Violet pink
user@hostname ~/path/to/directory $
Monochromatic

Zsh prompt variables

These are the variable substitutions used above.

%n   The user that is logged in
%m   Hostname up until the first dot. A number after "%m" will indicated how many dots should be included
%1~  Current directory, replacing the home dir with ~

Some more variable substitutions

%d   Current working directory
%M   The full machine hostname
%#   A ‘#’ if the shell is running with privileges, a ‘%’ if not