monde (owner)

Revisions

gist: 217120 Download_button fork
public
Description:
verbose dirty git prompt
Public Clone URL: git://gist.github.com/217120.git
Embed All Files: show embed
dirtygitprompt.sh #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# origin of work http://henrik.nyh.se/2008/12/git-dirty-prompt
function parse_git_dirty {
  status=`git status 2> /dev/null`
  dirty=` echo -n "${status}" 2> /dev/null | grep -q "Changed but not updated" 2> /dev/null; echo "$?"`
  untracked=`echo -n "${status}" 2> /dev/null | grep -q "Untracked files" 2> /dev/null; echo "$?"`
  ahead=` echo -n "${status}" 2> /dev/null | grep -q "Your branch is ahead of" 2> /dev/null; echo "$?"`
  newfile=` echo -n "${status}" 2> /dev/null | grep -q "new file:" 2> /dev/null; echo "$?"`
  renamed=` echo -n "${status}" 2> /dev/null | grep -q "renamed:" 2> /dev/null; echo "$?"`
  bits=''
  if [ "${dirty}" == "0" ]; then
bits="${bits}☭"
  fi
if [ "${untracked}" == "0" ]; then
bits="${bits}?"
  fi
if [ "${newfile}" == "0" ]; then
bits="${bits}*"
  fi
if [ "${ahead}" == "0" ]; then
bits="${bits}+"
  fi
if [ "${renamed}" == "0" ]; then
bits="${bits}>"
  fi
echo "${bits}"
}
 
function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
}
 
export PS1='\[\033[00;32m\]\u\[\033[01m\]@\[\033[00;36m\]\h\[\033[01m\] \! \[\033[00;35m\]\w\[\033[00m\]\[\033[01;30m\]$(parse_git_branch)\[\033[00m\]\$ '