Skip to content

Instantly share code, notes, and snippets.

@bkudria
Created May 12, 2009 05:28
Show Gist options
  • Save bkudria/110327 to your computer and use it in GitHub Desktop.
Save bkudria/110327 to your computer and use it in GitHub Desktop.
HASHSTRING=`hostname`
if [[ $DISTRO = "CentOS" ]]; then
HASHSTRING="`hostname -f`"
fi
HOSTCOLORCODE=$(hosts.rb -d $HASHSTRING)
HOSTCOLORESCAPE=$'%{\e[38;5;%}'$HOSTCOLORCODE$'%{m%}'
function zsh_prompt()
{
local N=$'%{\e[0m%}' # unsets color to term's fg color
local UC=$HOSTCOLORESCAPE # user's color
local O="${UC}(${N}"
local C="${UC})${N}"
local D="${UC}-${N}"
[ $UID -eq "0" ] && O="${UC}[${N}"
[ $UID -eq "0" ] && C="${UC}]${N}"
[ $UID -eq "0" ] && D="${UC}-${N}"
local HO=$HOSTCOLORESCAPE
local HC=$N
PS1="${N}
${O}${UC}%n${N}@${HO}%m${HC}:%~${C}${D}${O}%?${C}${D}${O}"
PS2="${D}${O}"
}
zsh_prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment