Permalink
Browse files

Copy andrewwatts's bash prompt

  • Loading branch information...
1 parent 1b60f22 commit 14ac2f84f3629bb79d00b3fe6b10d82363aa645c @saltycrane committed Mar 23, 2011
Showing with 44 additions and 4 deletions.
  1. +1 −4 .bashrc
  2. +43 −0 etc/.bash_prompt
View
5 .bashrc
@@ -15,10 +15,6 @@ if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
-# Comment in the above and uncomment this below for a color prompt
-export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\e[33m\e[1m\]\w\[\e[m\e[0m\]
-$ "
-
# If this is an xterm set the title to user@host:dir
# case "$TERM" in
# xterm*|rxvt*|screen)
@@ -28,6 +24,7 @@ $ "
# ;;
# esac
+source $HOME/etc/.bash_prompt
source $HOME/etc/.environvars
source $HOME/etc/.bash_aliases
source $HOME/prv/.bashrc
View
43 etc/.bash_prompt
@@ -0,0 +1,43 @@
+# -------------------------------------------------------------------------
+# FUNCTIONS FOR A GIT PROMPT
+# -------------------------------------------------------------------------
+GIT_PROMPT_PREFIX="("
+GIT_PROMPT_SUFFIX=")"
+GIT_PROMPT_DIRTY="!"
+GIT_PROMPT_CLEAN=""
+
+# get the name of the branch we are on
+function git_prompt_info() {
+ ref=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/git::\1/') || return
+ echo "$GIT_PROMPT_PREFIX$ref$(parse_git_dirty)$GIT_PROMPT_SUFFIX"
+}
+
+parse_git_dirty () {
+ if [[ $((git status 2> /dev/null) | tail -n1) != "nothing to commit (working directory clean)" ]]; then
+ echo "$GIT_PROMPT_DIRTY"
+ else
+ echo "$GIT_PROMPT_CLEAN"
+ fi
+}
+
+# -------------------------------------------------------------------------
+# PROMPT
+# -------------------------------------------------------------------------
+BLACK="\[\033[0;30m\]"
+RED="\[\033[0;31m\]"
+GREEN="\[\033[0;32m\]"
+YELLOW="\[\033[0;33m\]"
+BLUE="\[\033[0;34m\]"
+MAGENTA="\[\033[0;35m\]"
+CYAN="\[\033[0;36m\]"
+LIGHT_RED="\[\033[1;31m\]"
+LIGHT_GREEN="\[\033[1;32m\]"
+LIGHT_YELLOW="\[\033[1;33m\]"
+LIGHT_BLUE="\[\033[1;34m\]"
+LIGHT_MAGENTA="\[\033[1;35m\]"
+LIGHT_CYAN="\[\033[1;36m\]"
+WHITE="\[\033[0;37m\]"
+RESET="\[\033[0m\]"
+
+PS1="${CYAN}\$(git_prompt_info)${RESET}${LIGHT_GREEN}\u@\h${RESET}:${LIGHT_YELLOW}\w${RESET}
+$ "

0 comments on commit 14ac2f8

Please sign in to comment.