Skip to content

Instantly share code, notes, and snippets.

@ojacobson
Created November 6, 2012 20:30
Show Gist options
  • Save ojacobson/4027314 to your computer and use it in GitHub Desktop.
Save ojacobson/4027314 to your computer and use it in GitHub Desktop.
ps1_status() {
if [ $? -ne 0 ]; then
echo ":("
else
echo ":)"
fi
}
function configure_prompt() {
local PS_RESET="\[\e[00m\]"
local PS_GREEN="\[\e[01;32m\]"
local PS_BLUE="\[\e[01;34m\]"
local PS_PURPLE="\[\e[01;35m\]"
# No \[ \] - makes it too hard to verify the pairing to put them here.
# See TITLEBAR below.
local PS_TITLE_START="\e]0;"
local PS_TITLE_END="\a"
case $TERM in
xterm*|rxvt)
local TITLEBAR="\[$PS_TITLE_START\u@\h:\W$PS_TITLE_END\]"
;;
*)
local TITLEBAR=''
;;
esac
local IDENT="$PS_GREEN\u@\h$PS_RESET"
local CWD="$PS_BLUE\W$PS_RESET"
local SMILEY="$PS_PURPLE"'$(ps1_status)'"$PS_RESET"
local PROMPT="$SMILEY$IDENT:$CWD\$ "
export PS1="$TITLEBAR$PROMPT"
}
configure_prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment