Created
May 12, 2009 05:28
-
-
Save bkudria/110327 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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