Skip to content

Instantly share code, notes, and snippets.

@nanoninja
Created November 9, 2016 12:57
Show Gist options
  • Save nanoninja/b4786ff1f07a0979470078b74d9e40d7 to your computer and use it in GitHub Desktop.
Save nanoninja/b4786ff1f07a0979470078b74d9e40d7 to your computer and use it in GitHub Desktop.
Bash Prompt
#!/bin/bash
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
##############
### COLORS ###
##############
BLACK="\[\033[0;30m\]"
BLACKBOLD="\[\033[1;30m\]"
RED="\[\033[0;31m\]"
REDBOLD="\[\033[1;31m\]"
GREEN="\[\033[0;32m\]"
GREENBOLD="\[\033[1;32m\]"
YELLOW="\[\033[0;33m\]"
YELLOWBOLD="\[\033[1;33m\]"
BLUE="\[\033[0;34m\]"
BLUEBOLD="\[\033[1;34m\]"
PURPLE="\[\033[0;35m\]"
PURPLEBOLD="\[\033[1;35m\]"
CYAN="\[\033[0;36m\]"
CYANBOLD="\[\033[1;36m\]"
WHITE="\[\033[0;37m\]"
WHITEBOLD="\[\033[1;37m\]"
GRAY="\[\033[1;30m\]"
RESETCOLOR="\[\e[00m\]"
function parse_git_dirty() {
[[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && echo "*"
}
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
function prompt {
PS1=" \[$GRAY\]\u in \[$GREEN\]\w \[$RESETCOLOR\]"
PS1+="$BLUEBOLD\$(parse_git_branch)"
PS1+="\[$RESETCOLOR\]\n\$ "
export PS1
}
prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment