From f1a59e83c50f04585bbf5e2318aab828b27ed0bd Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 12 Jul 2020 14:17:43 -0500 Subject: [PATCH] Move __fish_set_lscolors to ls.fish It's not used anywhere else. [ci skip] --- share/functions/__fish_set_lscolors.fish | 18 ------------------ share/functions/ls.fish | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 share/functions/__fish_set_lscolors.fish diff --git a/share/functions/__fish_set_lscolors.fish b/share/functions/__fish_set_lscolors.fish deleted file mode 100644 index 186741cac..000000000 --- a/share/functions/__fish_set_lscolors.fish +++ /dev/null @@ -1,18 +0,0 @@ -function __fish_set_lscolors --description 'Set $LS_COLORS if possible' - if ! set -qx LS_COLORS && set -l cmd (command -s {g,}dircolors)[1] - set -l colorfile - for file in ~/.dir_colors ~/.dircolors /etc/DIR_COLORS - if test -f $file - set colorfile $file - break - end - end - # Here we rely on the legacy behavior of `dircolors -c` producing output - # suitable for csh in order to extract just the data we're interested in. - set -gx LS_COLORS ($cmd -c $colorfile | string split ' ')[3] - # The value should always be quoted but be conservative and check first. - if string match -qr '^([\'"]).*\1$' -- $LS_COLORS - set LS_COLORS (string match -r '^.(.*).$' $LS_COLORS)[2] - end - end -end diff --git a/share/functions/ls.fish b/share/functions/ls.fish index 1f8246532..678173f66 100644 --- a/share/functions/ls.fish +++ b/share/functions/ls.fish @@ -1,3 +1,22 @@ +function __fish_set_lscolors --description 'Set $LS_COLORS if possible' + if ! set -qx LS_COLORS && set -l cmd (command -s {g,}dircolors)[1] + set -l colorfile + for file in ~/.dir_colors ~/.dircolors /etc/DIR_COLORS + if test -f $file + set colorfile $file + break + end + end + # Here we rely on the legacy behavior of `dircolors -c` producing output + # suitable for csh in order to extract just the data we're interested in. + set -gx LS_COLORS ($cmd -c $colorfile | string split ' ')[3] + # The value should always be quoted but be conservative and check first. + if string match -qr '^([\'"]).*\1$' -- $LS_COLORS + set LS_COLORS (string match -r '^.(.*).$' $LS_COLORS)[2] + end + end +end + function ls --description "List contents of directory" # Make ls use colors and show indicators if we are on a system that supports that feature and writing to stdout. #