From 6607aec25712640337a030df37e12db53372a082 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 20 Oct 2012 09:26:14 +1300 Subject: [PATCH] Fetch rel_path from ll args and prepend to files before setting env variable shortcuts --- lib/git/shell_shortcuts.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/git/shell_shortcuts.sh b/lib/git/shell_shortcuts.sh index c0bf699..ecec785 100644 --- a/lib/git/shell_shortcuts.sh +++ b/lib/git/shell_shortcuts.sh @@ -95,6 +95,13 @@ if [ -n "$_ll_command" ]; then function ll { local ll_output="$($_ll_command "$@")" + # Parse path from args + OLDIFS="$IFS"; IFS=$'\n' + for arg in $@; do + if [ -d "$arg" ]; then local rel_path="${arg%/}"; fi + done + IFS="$OLDIFS" + # Replace user/group with user symbol, if defined at ~/.user_sym # Before : -rw-rw-r-- 1 ndbroadbent ndbroadbent 1.1K Sep 19 21:39 scm_breeze.sh # After : -rw-rw-r-- 1 𝐍 𝐍 1.1K Sep 19 21:39 scm_breeze.sh @@ -130,9 +137,10 @@ EOF # Set numbered file shortcut in variable local e=1 local ll_files="$($_ll_sys_command "$@")" - OLDIFS="$IFS" - IFS=$'\n' + + OLDIFS="$IFS"; IFS=$'\n' for file in $ll_files; do + if [ -n "$rel_path" ]; then file="$rel_path/$file"; fi export $git_env_char$e="$(eval $_abs_path_command \"$file\")" if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi let e++