From 584b211a4a831d254a188d24f5e7feffc79b9c1d Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Tue, 21 Aug 2012 14:01:33 +1200 Subject: [PATCH] Fixed git branch command for OS X --- lib/git/branch_shortcuts.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/git/branch_shortcuts.sh b/lib/git/branch_shortcuts.sh index 2292997..e3d93ea 100644 --- a/lib/git/branch_shortcuts.sh +++ b/lib/git/branch_shortcuts.sh @@ -8,6 +8,8 @@ # Numbered shortcuts for git branch # ------------------------------------------------------------------------------ +_uname="$(uname)" + # Function wrapper around 'll' # Adds numbered shortcuts to output of ls -l, just like 'git status' unalias $git_branch_alias > /dev/null 2>&1; unset -f $git_branch_alias > /dev/null 2>&1 @@ -18,9 +20,20 @@ function _scmb_git_branch_shortcuts { return 1 fi + local git_branch_command="$_git_cmd branch --color=always \\\"$@\\\"" + + if [ "$_uname" = "Linux" ]; then + # Linux + local script_git_branch_command="script -q -c \"$git_branch_command\" /dev/null" + elif [ "$_uname" = "Darwin" ]; then + # OS X + local script_git_branch_command="script -q /dev/null \"$git_branch_command\"" + fi + + # Use ruby to inject numbers into ls output ruby -e "$( cat < 9 && i < 9 ? " " : " ")