We can discuss the details later!

This and that.

minimal zsh prompt

I recently changed my zsh prompt to show only as much information as needed. I don't need to constantly look at the time or date or the battery status of my laptop.

  • if I'm on the local machine, it displays only a "%" on the left side and the current path on the right (disappears when written into)

  • if the current directory is under (git) version control, some git status information is displayed (thanks to zsh-git-prompt, which you need to install, if you want this too)

  • when the last command exited with a nonzero exit code, the exit code is shown on its own line

  • if I have "elevated privileges" (i.e. root), "ROOT" is displayed with a RED background and the machine name

  • if logged in over ssh, user- and hostname are displayed

  • after commands taking longer than 2 seconds some timing statistics are shown (this is not technically part of the prompt…)

Here is the relevant part of my zshrc:

export REPORTTIME=2
setopt prompt_subst
source ~/.zsh/git-prompt/zshrc.sh
if [ $SSH_CONNECTION ]; then SSH="%n@%m"; else SSH=""; fi
PROMPT='%(?..$PR_RED%?\
)%{$reset_color%}%(!.$PR_RED%SROOT%s$PR_NO_COLOUR@%B%m%b.$SSH)$(git_super_status)%# '
RPROMPT='%~'

ps: the colour scheme is the very trendy solarized

update: error correction, before, if logged in as root per ssh it would display root@machineroot@machine