Skip to content

Instantly share code, notes, and snippets.

@omame
Created December 5, 2013 18:41
Show Gist options
  • Save omame/7810888 to your computer and use it in GitHub Desktop.
Save omame/7810888 to your computer and use it in GitHub Desktop.
My PS1. Yellow when working on my pc. Blue when working on a remote server. Last $ is red when previous command failed, otherwise is green.
# Check if we're on a ssh connection
if [ ! -z "$SSH_TTY" ]; then
pscolor=94 # Yellow
else
pscolor=33 # Blue
fi
function exitstatus {
# Manage exit status within the coloured prompt
if [ $? -ne 0 ]; then
export PS1="\[\033[01;"$pscolor"m\]\u@\h \t \w\[\033[00m\]\e[31m$ \e[0m"
else
export PS1="\[\033[01;"$pscolor"m\]\u@\h \t \w\[\033[00m\]\e[32m$ \e[0m"
fi
}
PROMPT_COMMAND=exitstatus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment