Created
September 24, 2012 01:59
-
-
Save Ivoz/3773806 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
#!/bin/bash | |
# Color shortcuts | |
co_black='\[\e[30m\]' | |
co_red='\[\e[31m\]' | |
co_green='\[\e[32m\]' | |
co_yellow='\[\e[33m\]' | |
co_blue='\[\e[34m\]' | |
co_purple='\[\e[35m\]' | |
co_cyan='\[\e[36m\]' | |
co_white='\[\e[37m\]' | |
co_reset='\[\e[0m\]' | |
function return_char { | |
if [[ $ret -eq 0 ]]; then | |
echo $co_cyan$ret$co_reset | |
else | |
echo $co_red$ret$co_reset | |
fi | |
} | |
function scm_branch { | |
if git branch &>/dev/null; then | |
git branch | grep '*' | cut -c 3- | |
fi | |
if hg root &>/dev/null; then | |
hg summary | head -n 2 | tail -n 1 | cut -d ' ' -f2 | |
fi | |
} | |
function prompt_char { | |
git branch &>/dev/null && echo '±' && return | |
hg root &>/dev/null && echo '☿' && return | |
echo '○' | |
} | |
function user_color { | |
if [[ $EUID -eq 0 ]]; then | |
echo $co_red$1$co_reset | |
elif [[ -n $SUDO_USER ]]; then | |
echo $co_yellow$1$co_reset | |
else | |
echo $co_purple$1$co_reset | |
fi | |
} | |
# Put the time in the corner | |
#timecorner="\[\033[s\]\[\033[1;\$((COLUMNS-4))f\]\$(date +%H:%M)\[\033[u\]" | |
# Set prompt command | |
PROMPT_COMMAND='ret=$?;PS1="$(return_char) $co_yellow\D{%d-%m} $co_blue\A $co_blue$(scm_branch) $co_green\w\n $(user_color $(whoami))@\h $(user_color $(prompt_char)) "' | |
PS2='> ' | |
PS3='> ' | |
PS4='+ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment