Fixed .logout
[clearscm.git] / rc / git
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:        $RCSfile: git,v $
5 # Revision:    $Revision: 1.0 $ 
6 # Description: This script set up some useful environment variables and aliases
7 #              for git execution. File should be sourced (e.g . git) 
8 # Author:      Andrew@DeFaria.com
9 # Created:     Thu Nov  7 18:00:34 PST 2013
10 # Modified:    $Date: $
11 # Language:    bash
12 #
13 # (c) Copyright 2000-2013, ClearSCM, Inc., all rights reserved.
14 #
15 ################################################################################
16 function in_git_repo {
17   pwd=$PWD
18   
19   while [ "$pwd" != "/" -a "$pwd" != "//" ]; do
20     if [ -d "$pwd/.git" ]; then
21       true;
22       return;
23     fi
24
25     pwd=$(dirname "$pwd")
26   done
27   
28   false
29 } # in_git_repo
30
31 function git () {
32   # Need to reset title since we put the branch name in the titlebar
33   git=$(which git)
34
35   if [ "$1" = "checkout" -o "$1" = "co" ]; then
36     $git $@
37     set_title
38   else
39     $git $@
40   fi
41 } # git