Copy and self modified from ys.zsh-theme, the one of default themes in master repository
July 2, 2015 · View on GitHub
Clean, simple, compatible and meaningful.
Tested on Linux, Unix and Windows under ANSI colors.
It is recommended to use with a dark background and the font Inconsolata.
Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
http://xiaofan.at
2 Jul 2015 - Xiaofan
Machine name.
function box_name { [ -f ~/.box-name ] && cat ~/.box-name || echo $HOST }
Directory info.
local current_dir='{PWD/#HOME/~}'
VCS
YS_VCS_PROMPT_PREFIX1="%{reset_color%} " YS_VCS_PROMPT_PREFIX2=":%{reset_color%} " YS_VCS_PROMPT_DIRTY=" %{fg[green]%}✔︎"
Git info.
local git_info='(git log --pretty=format:"%h "%s"" -1 2> /dev/null)' ZSH_THEME_GIT_PROMPT_PREFIX="{YS_VCS_PROMPT_PREFIX2}" ZSH_THEME_GIT_PROMPT_SUFFIX="YS_VCS_PROMPT_DIRTY" ZSH_THEME_GIT_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN"
HG info
local hg_info='(ys_hg_prompt_info)' ys_hg_prompt_info() { # make sure this is a hg dir if [ -d '.hg' ]; then echo -n "{YS_VCS_PROMPT_PREFIX1}hg(hg branch 2>/dev/null) if [ -n "YS_VCS_PROMPT_DIRTY" else echo -n "YS_VCS_PROMPT_SUFFIX" fi }
Prompt format: \n # TIME USER at MACHINE in [DIRECTORY] on git:BRANCH STATE \n $
PROMPT="
%{fg[white]%}at
%{(box_name)
%{terminfo[bold]{current_dir}]%{{hg_info}
{git_last_commit}
%{terminfo[bold]reset_color%}"
if [[ "fg[red]%}%*
%{fg[blue]%}#%{bg[yellow]%}%{reset_color%}
%{fg[green]%}fg[white]%}in
%{fg[yellow]%}[reset_color%}
{git_info}
%{fg[red]%}reset_color%}"
fi