-
-
Save braveulysses/292407 to your computer and use it in GitHub Desktop.
show git status at bash prompt
This file contains hidden or 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
function _bash_git_status() { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function _bash_git() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/±\1$(_bash_git_status)/' | |
} | |
function prompt() { | |
local BLACK="\[\033[0;30m\]" | |
local DK_GREY="\[\033[1;30m\]" | |
local RED="\[\033[0;31m\]" | |
local LT_RED="\[\033[1;31m\]" | |
local GREEN="\[\033[0;32m\]" | |
local LT_GREEN="\[\033[1;32m\]" | |
local BROWN="\[\033[0;33m\]" | |
local YELLOW="\[\033[1;33m\]" | |
local BLUE="\[\033[0;34m\]" | |
local LT_BLUE="\[\033[1;34m\]" | |
local PURPLE="\[\033[0;35m\]" | |
local LT_PURPLE="\[\033[1;35m\]" | |
local CYAN="\[\033[0;36m\]" | |
local LT_CYAN="\[\033[1;36m\]" | |
local LT_GREY="\[\033[0;37m\]" | |
local WHITE="\[\033[1;37m\]" | |
local NO_COLOR="\[\033[0m\]" | |
PS1="$LT_PURPLE\u$NO_COLOR@$PURPLE\h$NO_COLOR:\e$GREEN\w$LT_RED$(_bash_git)\n$NO_COLOR\$ " | |
} | |
PROMPT_COMMAND=prompt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment