Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # color prompt to include branch information
- function color_my_prompt {
- local __user_and_host="\[\033[01;32m\]\u@\h"
- local __cur_location="\t\w"
- local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\ \(\\\\\1\)\/`'
- local __prompt_tail=">"
- local __last_color="\[\033[00m\]"
- RED="\[\033[0;31m\]"
- YELLOW="\[\033[0;33m\]"
- LPURPLE="\[\033[0;35m\]"
- GREEN="\[\033[0;32m\]"
- LBLUE="\[\033[0;34m\]"
- # Capture the output of the "git status" command.
- git_status="$(git status 2> /dev/null)"
- # Set color based on clean/staged/dirty.
- if [[ ${git_status} =~ "working directory clean" ]]; then
- #state="${GREEN}"
- state="${LBLUE}"
- elif [[ ${git_status} =~ "Changes to be committed" ]]; then
- #state="${YELLOW}"
- state="${LPURPLE}"
- else
- state="${RED}"
- fi
- export PS1="$__cur_location${state}$__git_branch$__last_color$__prompt_tail "
- }
- # Tell bash to execute this function just before displaying its prompt.
- PROMPT_COMMAND=color_my_prompt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement