Bash-Prompt mit Infos zu Git-Repository
Folgendes an geeigneter Stelle in die ~/.bashrc einbauen:
function my_prompt { local BLACK="\[\033[0;30m\]" local BLACKBOLD="\[\033[1;30m\]" local RED="\[\033[0;31m\]" local REDBOLD="\[\033[1;31m\]" local GREEN="\[\033[0;32m\]" local GREENBOLD="\[\033[1;32m\]" local YELLOW="\[\033[0;33m\]" local YELLOWBOLD="\[\033[1;33m\]" local BLUE="\[\033[0;34m\]" local BLUEBOLD="\[\033[1;34m\]" local PURPLE="\[\033[0;35m\]" local PURPLEBOLD="\[\033[1;35m\]" local CYAN="\[\033[0;36m\]" local CYANBOLD="\[\033[1;36m\]" local WHITE="\[\033[0;37m\]" local WHITEBOLD="\[\033[1;37m\]" local CLEAR="\[\033[00m\]" if __gitdir > /dev/null; then if ! git diff --no-ext-diff --quiet --exit-code; then # unstaged changes git_branch="$REDBOLD" elif ! git diff --no-ext-diff --quiet --cached --exit-code; then # staged changes git_branch="$YELLOWBOLD" else # no changes git_branch="$GREENBOLD" fi git_branch=${git_branch}$(__git_ps1)"$CLEAR" else git_branch="" fi PS1="$BLUEBOLD[\W]$CLEAR${git_branch} \$ " } PROMPT_COMMAND=my_prompt