Skip to content

Instantly share code, notes, and snippets.

@shanna
Last active May 4, 2016 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanna/f4666cf11d5e4b30cf74fb3cd51a89fe to your computer and use it in GitHub Desktop.
Save shanna/f4666cf11d5e4b30cf74fb3cd51a89fe to your computer and use it in GitHub Desktop.
A short, smart, prompt.
# [ -e ~/.config/short-prompt.sh ] && source ~/.config/short-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=true
__git_ps1() { PS1="$1$2"; }
[ -e ~/.config/git-prompt.sh ] && source ~/.config/git-prompt.sh
__short_ps1() {
local exit=$?
local __short_ps1_host=""
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
__short_ps1_host="\[\e[34m\]\u\[\e[0m\]@\[\e[0;33m\]\h\[\e[0m\] "
elif [ -n "$SUDO_USER" ]; then
__short_ps1_host="\[\e[34m\]\u\[\e[0m\] "
fi
if [ "$exit" -eq "0" ]; then
__git_ps1 "${__short_ps1_host}\w" "\[\e[1;33m\] λ \[\e[0m\]"
else
__git_ps1 "${__short_ps1_host}\w" "\[\e[1;31m\] λ \[\e[0m\]"
fi
}
PROMPT_COMMAND='__short_ps1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment