News for hackers. Stuff that matters.
Re:Interesting Bash Prompts by ashleyw on Tuesday September 08, 2009 @06:29PM (#812111)

    function parse_git_dirty {
      [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (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 parse_current_dir {
      ruby -e "puts ('../'+Dir.getwd.split('/').last(2).join('/')).gsub('//', '/')"
    }

    export PS1='\[\033[31;40m\]$(parse_current_dir)\[\033[0;33m\]$(parse_git_branch)\[\e[0m\]$ '
I couldn't be bothered to work out how to shorten the path natively, so I hacked it [badly] ]in ruby... :)

http://grab.by/3Gg

There are no comments on this comment yet.