Created
November 5, 2014 08:39
-
-
Save malexandre/4872be41cd475e74fd78 to your computer and use it in GitHub Desktop.
Bash prompt with git information (example: `[6@pts] 09:38:52 marc ~/git/gitg [>master|-0|+0]` (with color))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function promptGit() | |
{ | |
if [[ -d ./.git ]]; then | |
local change_waiting_commit=`if git status | grep -q "nothing to commit (working directory clean)"; then echo ""; else echo ">"; fi` | |
local current_branch=`git rev-parse --symbolic-full-name --abbrev-ref HEAD` | |
local commits_behind=`git rev-list --left-right $current_branch...origin/master | grep -c "^>"` | |
local commits_ahead=`git rev-list --left-right $current_branch...origin/master | grep -c "^<"` | |
echo " [$change_waiting_commit$current_branch|-$commits_behind|+$commits_ahead]" | |
fi | |
} | |
function promptPerso | |
{ | |
local GRAD1=`tty|cut -d/ -f3` | |
PS1="\[\033[01;34m\][\#@$GRAD1] \$(date +%H:%M:%S) \[\033[00m\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[01;34m\] \[\033[01;31m\]\w\[\033[1;33m\]\$(promptGit) \[\033[01;34m\]\$\[\033[00m\] " | |
} | |
promptPerso |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment