Skip to content

Instantly share code, notes, and snippets.

@johanmeiring
Last active October 2, 2015 02:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johanmeiring/2157285 to your computer and use it in GitHub Desktop.
Save johanmeiring/2157285 to your computer and use it in GitHub Desktop.
Colour *nix prompt with git status
# Ubuntu / Debian:
export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]`[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "\[\e[31m\]" || echo "\[\e[32m\]"`$(__git_ps1 " (%s)\[\e[00m\]") \[\e[00m\]\$ '
# OSX:
export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]`[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "\[\e[31m\]" || echo "\[\e[32m\]"`$(__git_ps1 " (%s)\[\e[00m\]") \[\e[00m\]\$ '
@puttyq
Copy link

puttyq commented Mar 12, 2014

Works a charm. 👍
Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment