Skip to content

Instantly share code, notes, and snippets.

@bdjnk
Last active November 13, 2015 00:40
Show Gist options
  • Save bdjnk/50676cba04dcc0bea899 to your computer and use it in GitHub Desktop.
Save bdjnk/50676cba04dcc0bea899 to your computer and use it in GitHub Desktop.
_hadsuccess() {
if [ $? -eq 0 ]; then
echo '2';
else
echo '1';
fi
}
_gitbranch() {
if [ -d .git ]; then
git branch | sed -nr '/^\* / s/^\* (.+)/ (\1)/g p';
fi
}
_filecount() {
/bin/ls -1 | /usr/bin/wc -l
}
_getsize() {
/bin/ls -lah | /usr/bin/grep -m 1 total | /bin/sed 's/total //'
}
_isroot() {
if [ ${EUID} -eq 0 ]; then
echo '1';
else
echo '4';
fi
}
c() {
echo "\[\033[${1}m\]"
}
PS1="$n\n\
$(c '1;3$(_hadsuccess);40')*$(c) \
$(c '36;40')\@ \d$(c) \
$(c '35;40')\j$(c) \
$(c '37;40')\u$(c '33')@\h$(c) \
$(c '1;34;40')\w$(c '34;40')\$(_gitbranch)$(c) \
$(c '32;40')\$(_filecount) files, \$(_getsize)$(c) \
\n$(c '1;3$(_isroot);47')>$(c) "
unset -f c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment