From f775ab6ef4eac7915b950da6799f00bff3c317e4 Mon Sep 17 00:00:00 2001 From: Nicholas Rodrigues Lordello Date: Thu, 2 Nov 2023 13:00:58 +0100 Subject: [PATCH] Additional checks for -F support (cherry picked from commit 93b3a0c1f55562354e32856edd45d08c82516e01) --- share/functions/ls.fish | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/share/functions/ls.fish b/share/functions/ls.fish index 369dcb860..7cb16c625 100644 --- a/share/functions/ls.fish +++ b/share/functions/ls.fish @@ -7,16 +7,18 @@ function ls --description "List contents of directory" # Solaris 11's ls command takes a --color flag. # OpenBSD requires the separate colorls program for color support. # Also test -F because we'll want to define this function even with an ls that can't do colors (like NetBSD). - if not set -q __fish_ls_color_opt - set -g __fish_ls_color_opt + if not set -q __fish_ls_command set -g __fish_ls_command ls + set -g __fish_ls_color_opt + set -g __fish_ls_indicators_opt # OpenBSD ships a command called "colorls" that takes "-G" and "-F", # but there's also a ruby implementation that doesn't understand "-F". # Since that one's quite different, don't use it. if command -sq colorls and command colorls -GF >/dev/null 2>/dev/null - set -g __fish_ls_color_opt -G set -g __fish_ls_command colorls + set -g __fish_ls_color_opt -G + set -g __fish_ls_indicators_opt -F else for opt in --color=auto -G --color if command ls $opt / >/dev/null 2>/dev/null @@ -24,12 +26,16 @@ function ls --description "List contents of directory" break end end + + if command ls -F / >/dev/null 2>/dev/null + set -g __fish_ls_indicators_opt -F + end end end - set -l opt + set -l indicators_opt isatty stdout - and set -a opt -F + and set -a indicators_opt $__fish_ls_indicators_opt # Terminal.app doesn't set $COLORTERM or $CLICOLOR, # but the new FreeBSD ls requires either to be set, @@ -40,5 +46,5 @@ function ls --description "List contents of directory" test "$TERM_PROGRAM" = Apple_Terminal and set -lx CLICOLOR 1 - command $__fish_ls_command $__fish_ls_color_opt $opt $argv + command $__fish_ls_command $__fish_ls_color_opt $indicators_opt $argv end