Last active
May 4, 2016 07:25
-
-
Save shanna/f4666cf11d5e4b30cf74fb3cd51a89fe to your computer and use it in GitHub Desktop.
A short, smart, prompt.
This file contains 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
# [ -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