From 4ac4cba757af9f59e6f1fb0c5e7b37e2c3662f0e Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Tue, 21 Aug 2012 13:22:03 +1200 Subject: [PATCH] Support both BSD and GNU ls commands (for OS X and Linux, respectively) --- lib/git/shell_shortcuts.sh | 55 ++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/lib/git/shell_shortcuts.sh b/lib/git/shell_shortcuts.sh index 78e9384..51d71af 100644 --- a/lib/git/shell_shortcuts.sh +++ b/lib/git/shell_shortcuts.sh @@ -34,10 +34,10 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e unset -f $cmd # Create wrapped alias for old function alias "$cmd"="exec_scmb_expand_args __original_$cmd";; - *'is a shell builtin'*) + *'is a shell builtin'*) # Handle shell builtin commands alias $cmd="exec_scmb_expand_args builtin $cmd";; - *) + *) # Otherwise, command is a regular script or binary, # and the full path can be found from 'which' alias $cmd="exec_scmb_expand_args $(\which $cmd)";; @@ -49,24 +49,39 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e _git_wrap_commands fi -# Function wrapper around 'll' -# Adds numbered shortcuts to output of ls -l, just like 'git status' -unalias ll > /dev/null 2>&1; unset -f ll > /dev/null 2>&1 -function ll { - # Use ruby to inject numbers into ls output - ruby -e "$( cat < /dev/null 2>&1; unset -f ll > /dev/null 2>&1 + function ll { + # Use ruby to inject numbers into ls output + ruby -e "$( cat < $file"; fi - let e++ - done -} + # Set numbered file shortcut in variable + local e=1 + for file in $($_ll_sys_command); do + export $git_env_char$e="$(readlink -f $file)" + if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi + let e++ + done + } +fi \ No newline at end of file