fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
02a6afd2b
master
1# localization: skip(uses-apropos) 2function ls 3# Make ls use colors and show indicators if we are on a system that supports that feature and writing to stdout. 4# 5 6# BSD, macOS and others support colors with ls -G. 7# GNU ls and FreeBSD ls takes --color=auto. Order of this test is important because ls also takes -G but it has a different meaning. 8# Solaris 11's ls command takes a --color flag. 9# OpenBSD requires the separate colorls program for color support. 10# Also test -F because we'll want to define this function even with an ls that can't do colors (like NetBSD). 11if not set -q __fish_ls_command 12set -g __fish_ls_command ls 13set -g __fish_ls_color_opt 14set -g __fish_ls_indicators_opt 15# OpenBSD ships a command called "colorls" that takes "-G" and "-F", 16# but there's also a ruby implementation that doesn't understand "-F". 17# Since that one's quite different, don't use it. 18if command -sq colorls 19and command colorls -GF> /dev/null2> /dev/null 20set -g __fish_ls_command colorls 21set -g __fish_ls_color_opt -G 22set -g __fish_ls_indicators_opt -F 23else 24for optin --color=auto -G --color 25if command ls$opt /> /dev/null2> /dev/null 26set -g __fish_ls_color_opt$opt 27break 28end 29end 30 31if command ls -F /> /dev/null2> /dev/null 32set -g __fish_ls_indicators_opt -F 33end 34end 35end 36 37set -l indicators_opt 38isatty stdout 39and set -a indicators_opt$__fish_ls_indicators_opt 40 41# TODO(term-workaround) 42# Terminal.app doesn't set $COLORTERM or $CLICOLOR, 43# but the new FreeBSD ls requires either to be set, 44# before it will enable color. 45# See #8309. 46# We don't set $COLORTERM because that should be set to 47# "truecolor" or similar and we don't want to specify that here. 48test " $TERM_PROGRAM " = Apple_Terminal 49and set -lx CLICOLOR1 50 51# If CLICOLOR_FORCE is set, don't colorize `ls` (if piped) because the results 52# might not be what we want; i.e. `ls --color=auto | cat` might still emit color 53# output (e.g. under BSD and macOS). 54# We don't just unset CLICOLOR_FORCE because the user might theoretically *want* 55# this behavior by explicitly including `--color=auto` in $argv themselves. 56set -qx CLICOLOR_FORCE&& not isatty stdout;and set __fish_ls_color_opt 57 58command $__fish_ls_command $__fish_ls_color_opt $indicators_opt $argv 59end