Skip to content

Instantly share code, notes, and snippets.

@OddBloke
Created March 25, 2013 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OddBloke/5236935 to your computer and use it in GitHub Desktop.
Save OddBloke/5236935 to your computer and use it in GitHub Desktop.
WIDE_PROMPT="$USERNAME_NORMAL_COLOR%n$RESET_COLOR@%{$HOSTNAME_NORMAL_COLOR%}%m%{$reset_color%}:$DARK_RED%~$RESET_COLOR%# "
NARROW_PROMPT="$USERNAME_NORMAL_COLOR%n$RESET_COLOR@%{$HOSTNAME_NORMAL_COLOR%}%m%{$reset_color%}:$DARK_RED%~$RESET_COLOR
%# "
size_prompt() {
if [ $COLUMNS -lt 85 ]; then
PROMPT=$NARROW_PROMPT
else
PROMPT=$WIDE_PROMPT
fi
}
precmd() {
ref=$(git symbolic-ref HEAD 2> /dev/null || echo "")
ref=${ref#refs/heads/}
RPROMPT="$RESET_COLOR%{$fg_bold[grey]%}$ref$RESET_COLOR %(?..$RED%?$RESET_COLOR) [ %* ]"
if [ $UID -eq 0 ]; then
PROMPT="%{$USERNAME_ROOT_COLOR%}%n@%B%m%b:%~%# "
else
size_prompt
fi
}
TRAPWINCH() {
size_prompt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment