Test for command type, not architecture
This patch modifies the way available commands are tested; If a Mac user installs and uses GNU ls it is correctly detected and used. the ls_with_file_shortcuts now works on ZSH. It was failing with "command not found" due to parameters passed in $_ll_command which were interpreted as a command name.
This commit is contained in:
@@ -74,18 +74,22 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
# BSD ls is different to Linux (GNU) ls
|
# BSD ls is different to Linux (GNU) ls
|
||||||
_uname="$(uname)"
|
# test for BSD ls
|
||||||
if [ "$_uname" = "Linux" ]; then
|
ls --color=auto > /dev/null 2>&1
|
||||||
# Linux ls commands
|
if [ $? -ne 0 ]; then
|
||||||
_ll_command="ls -lhv --group-directories-first --color"
|
# ls is BSD
|
||||||
_ll_sys_command="ls -v --group-directories-first --color=never"
|
_ls_bsd="BSD"
|
||||||
_abs_path_command="readlink -f"
|
fi
|
||||||
elif [ "$_uname" = "Darwin" ]; then
|
|
||||||
# OS X ls commands
|
# test readlink
|
||||||
_ll_command="CLICOLOR_FORCE=1 ls -l -G"
|
type readlink > /dev/null 2>&1
|
||||||
_ll_sys_command="ls"
|
if [ $? -ne 0 ]; then
|
||||||
|
# no readlink
|
||||||
# Use perl abs_path, since readlink -f isn't available on OS X
|
# Use perl abs_path, since readlink -f isn't available on OS X
|
||||||
_abs_path_command='perl -e "use Cwd "abs_path"; print abs_path(shift)"'
|
_abs_path_command='perl -e "use Cwd "abs_path"; print abs_path(shift)"'
|
||||||
|
else
|
||||||
|
#readlink
|
||||||
|
_abs_path_command="readlink -f"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$_ll_command" ]; then
|
if [ -n "$_ll_command" ]; then
|
||||||
@@ -93,7 +97,13 @@ if [ -n "$_ll_command" ]; then
|
|||||||
# Adds numbered shortcuts to output of ls -l, just like 'git status'
|
# 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
|
unalias ll > /dev/null 2>&1; unset -f ll > /dev/null 2>&1
|
||||||
function ls_with_file_shortcuts {
|
function ls_with_file_shortcuts {
|
||||||
local ll_output="$($_ll_command "$@")"
|
local ll_output=''
|
||||||
|
|
||||||
|
if [ -z $_ls_bsd ]; then
|
||||||
|
ll_output="$(ls -lhv --group-directories-first --color "$@")"
|
||||||
|
else
|
||||||
|
ll_output="$(CLICOLOR_FORCE=1 ls -l -G "$@")"
|
||||||
|
fi
|
||||||
|
|
||||||
# Parse path from args
|
# Parse path from args
|
||||||
OLDIFS="$IFS"; IFS=$'\n'
|
OLDIFS="$IFS"; IFS=$'\n'
|
||||||
@@ -136,7 +146,14 @@ EOF
|
|||||||
|
|
||||||
# Set numbered file shortcut in variable
|
# Set numbered file shortcut in variable
|
||||||
local e=1
|
local e=1
|
||||||
local ll_files="$($_ll_sys_command "$@")"
|
local ll_files=''
|
||||||
|
local file=''
|
||||||
|
|
||||||
|
if [ -z $_ls_bsd ]; then
|
||||||
|
ll_files="$(ls -v --group-directories-first --color=never "$@")"
|
||||||
|
else
|
||||||
|
ll_files="$(ls "$@")"
|
||||||
|
fi
|
||||||
|
|
||||||
OLDIFS="$IFS"; IFS=$'\n'
|
OLDIFS="$IFS"; IFS=$'\n'
|
||||||
for file in $ll_files; do
|
for file in $ll_files; do
|
||||||
|
|||||||
Reference in New Issue
Block a user