-
-
Save caligin/038e1a9bb54b56c040de6495c4f064e6 to your computer and use it in GitHub Desktop.
This file contains 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
function __hg_ps1 () | |
{ | |
if [ "$(hg root 2> /dev/null)" ]; then | |
echo -en "(hg:$(hg branch))" | |
fi | |
} | |
function __git_ps1 () | |
{ | |
if [ "$(git rev-parse --show-toplevel 2> /dev/null)" ]; then | |
echo -en "(git:$(git branch | tr '\n' ',' | rev | cut -c 2- | rev | sed 's/,/, /g'))" | |
fi | |
} | |
function hostname_color | |
{ | |
local MIN_COLOR=104 | |
local MAX_COLOR=229 | |
local MD5=$(echo -ne "${HOSTNAME}"|md5sum|awk '{print toupper($1)}') | |
local RES=$(echo "ibase=16; ${MD5}" | bc) | |
local MOD=$(echo "(${RES} % (${MAX_COLOR} - ${MIN_COLOR})) + ${MIN_COLOR}"| bc) | |
echo -en $MOD | |
} | |
function uid_color { | |
if [ "$UID" = "0" ] ; then | |
echo -en "196" | |
else | |
echo -en "118" | |
fi | |
} | |
PS1="\[\e[1m\e[48;5;\$(hostname_color)m\] \[\e[00m\] \ | |
\[\e[1m\e[38;5;\$(hostname_color)m\]\u@\h\[\e[00m\]\ | |
:\ | |
\[\e[1m\e[38;5;111m\]\w\[\e[00m\]\ | |
\[\e[1m\e[38;5;118m\] \$(__hg_ps1)\[\e[00m\]\ | |
\[\e[1m\e[38;5;118m\] \$(__git_ps1)\[\e[00m\]\ | |
\n\ | |
\[\e[1m\e[48;5;\$(hostname_color)m\] \[\e[00m\]\ | |
\[\e[1m\e[38;5;111m\] ↪ \[\e[00m\]\ | |
\[\e[1m\e[38;5;$(uid_color)m\]\$ \[\e[00m\]" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment