From 6cd297c91fde494e284b759cb29ceb4df997bae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Natal=20Ng=C3=A9tal?= Date: Fri, 15 Apr 2011 18:01:24 +0200 Subject: [PATCH] [Plugin] Git: Implemente a git info. --- plugins/git/git.plugin.zsh | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 1de77a02b..015bea18c 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -41,6 +41,47 @@ function current_branch() { echo ${ref#refs/heads/} } +function git-info() { + # author: Duane Johnson + # email: duane.johnson@gmail.com + # date: 2008 Jun 12 + # license: MIT + # + # Based on discussion at http://kerneltrap.org/mailarchive/git/2007/11/12/406496 + + pushd . >/dev/null + + # Find base of git directory + while [ ! -d .git ] && [ ! `pwd` = "/" ]; do cd ..; done + + # Show various information about this git directory + if [ -d .git ]; then + echo "== Remote URL: `git remote -v`" + + echo "== Remote Branches: " + git branch -r + echo + + echo "== Local Branches:" + git branch + echo + + echo "== Configuration (.git/config)" + cat .git/config + echo + + echo "== Most Recent Commit" + git log --max-count=1 + echo + + echo "Type 'git log' for more commits, or 'git show' for full commit details." + else + echo "Not a git repository." + fi + + popd >/dev/null +} + # these aliases take advantage of the previous function alias ggpull='git pull origin $(current_branch)' compdef ggpull=git