From 3ddb5a2bdcfabb56d15481d618e5d8fb87d6e100 Mon Sep 17 00:00:00 2001 From: Scott Bonds Date: Tue, 1 Jun 2021 10:46:13 -0700 Subject: [PATCH] Add color to ls output on OpenBSD when colorls is installed (#8035) * add support for colorized ls on openbsd * add changelog line for colorls support * add readme line for colorls support * determine ls command at runtime, don't cache it * eliminate __fish_ls_command function --- CHANGELOG.rst | 1 + README.rst | 1 + share/functions/ls.fish | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0deb6c79b..a12dbb256 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -51,6 +51,7 @@ Interactive improvements - ``wait`` and ``on-process-exit`` work correctly with jobs that have already exited (:issue:`7210`). - Completion scripts are now loaded when calling a command via a relative path (like ``./git``) (:issue:`6001`, :issue:`7992`). - ``__fish_print_help`` (used for ``--help`` output for fish's builtins) now respects $LESS and uses a better default value (:issue:`7997`). +- ls output is colorized on OpenBSD if colorls utility is installed (:issue:`8035`) - The default pager color looks better in terminals with light backgrounds (:issue:`3412`). - Further robustness improvements to the bash history import (:issue:`7874`). diff --git a/README.rst b/README.rst index 39490f881..54f19f140 100644 --- a/README.rst +++ b/README.rst @@ -104,6 +104,7 @@ The following optional features also have specific requirements: ``wl-copy``/``wl-paste`` or ``pbcopy``/``pbpaste`` utilities - full completions for ``yarn`` and ``npm`` require the ``all-the-package-names`` NPM module +- ``colorls`` is used, if its installed, to add color when running ``ls`` Switching to fish ~~~~~~~~~~~~~~~~~ diff --git a/share/functions/ls.fish b/share/functions/ls.fish index 678173f66..74ad2ac10 100644 --- a/share/functions/ls.fish +++ b/share/functions/ls.fish @@ -24,6 +24,7 @@ function ls --description "List contents of directory" # BSD, macOS and others support colors with ls -G. # 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. # 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 @@ -40,5 +41,11 @@ function ls --description "List contents of directory" isatty stdout and set -a opt -F - command ls $__fish_ls_color_opt $argv + + if command -sq colorls + command colorls $__fish_ls_color_opt $argv + else + command ls $__fish_ls_color_opt $argv + end + end