Skip to content

Instantly share code, notes, and snippets.

@tonywok
Last active December 20, 2015 21:39
Show Gist options
  • Select an option

  • Save tonywok/6198912 to your computer and use it in GitHub Desktop.

Select an option

Save tonywok/6198912 to your computer and use it in GitHub Desktop.
Simple little bash script for a decent bash prompt
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
GREEN="\033[0;32m"
CYAN="\033[0;36m"
BLUE="\033[0;34m"
RED="\033[0;31m"
RESET="\033[0m"
function git-prompt {
local prompt=""
if [[ -d "./.git" ]]; then
prompt="$prompt$(__git_ps1 '(%s)')"
if test -n "$(git status --porcelain)"; then
local status="$(git status --porcelain | cut -c 1-2 | uniq)"
if [[ $status =~ (A )|(D )|(R )|(M ) ]]; then # staged
prompt="$prompt$CYAN ✔"
fi
if [[ $status =~ ( M) ]]; then # modified
prompt="$prompt$GREEN ●"
fi
if [[ $status =~ (\?\?) ]]; then # untracked
prompt="$prompt$BLUE ●"
fi
if [[ $status =~ (U )|( U) ]]; then # conflict
prompt="$prompt$RED x"
fi
else
prompt="$prompt ✔"
fi
fi
echo -e "$prompt"
}
export PS1="${CYAN}\u@\h: ${RESET}\W ${GREEN}\$(git-prompt) ${RESET} \n→ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment