Prompt just enough info in your terminal
If you havenβt set up your shell environment on Mac, please check out π My minimalist shell setup β Bash in Terminal and Zsh in iTerm2
Hereβs what my minimalist prompt setup looks like
The configuration behind the scenes
PROMPT='%(?.π.π±)%(!.%{$fg[red]%}.%{$fg[green]%})%2~%{$fg_bold[blue]%}$(git_prompt_info) %F{205}>%F{196}>%F{220}> %{$reset_color%} 'ZSH_THEME_GIT_PROMPT_PREFIX="("
ZSH_THEME_GIT_PROMPT_SUFFIX=")"
ZSH_THEME_GIT_PROMPT_DIRTY=" β"
ZSH_THEME_GIT_PROMPT_CLEAN=" β"
How should I use your config?
- Install iTerm2, zsh, on-my-zsh (I am using Mac)
2. Create your own theme file in ~/.oh-my-zsh/themes
, e.g. blah.zsh-theme
3. Copy the above config to the theme file you just created
4. Open ~/.zshrc
and change the ZSH_THEME="blah"
5. Restart your Terminal
What it does?
Highlight the return status
%(?.π.π±)
%?
The return status of the last command was executed just before the prompt.
Highlight privileges
%(!.%{$fg[red]%}.%{$fg[green]%})
%(x.true-text.false-text)
True if the shell is running with privileges.
Shorten the path
%2~
show current directory and its parent, use ~
represents $HOME
%2
The value of the first element of the psvar
array parameter.
%~
As %d
and %/
, if the current working directory starts with $HOME
, that part is replaced by a β~
β. Furthermore, if it has a named directory as its prefix, that part is replaced by a β~
β followed by the name of the directory, but only if the result is shorter than the full path;
Show git info
$(git_prompt_info)ZSH_THEME_GIT_PROMPT_PREFIX="("
ZSH_THEME_GIT_PROMPT_SUFFIX=")"
ZSH_THEME_GIT_PROMPT_DIRTY=" β"
ZSH_THEME_GIT_PROMPT_CLEAN=" β"
Prompt input
%F{205}>%F{196}>%F{220}>
show three >
in a different color
%F
Start (stop) using a different foreground colour, if supported by the terminal.