Created
January 10, 2012 17:51
-
-
Save oxyc/1590225 to your computer and use it in GitHub Desktop.
Bash 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
# Logic stolen from https://github.com/gf3/dotfiles | |
parse_git_dirty() { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
parse_git_branch() { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" | |
} | |
prompt_desc() { | |
OUTPUT="" | |
if [ -n "$SSH_CLIENT" ] ; then | |
OUTPUT="${OUTPUT}ssh/" | |
fi | |
if [[ -n $(git branch 2> /dev/null) ]] ; then | |
OUTPUT="${OUTPUT}$(parse_git_branch)/" | |
fi | |
[[ -n "$OUTPUT" ]] && echo " ${OUTPUT%?}" | |
} | |
CYAN="\033[0;36m" | |
WHITE="\033[0;37m" | |
RESET="\033[0m" | |
PS1="\[${WHITE}\]\w \[${CYAN}\]${USER}@${HOSTNAME}\[${WHITE}\]\$(prompt_desc) \[${RESET}\]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment