From fea82c6f8575c9eb0d312439a78ae6c13a510bf0 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Fri, 10 Nov 2023 09:31:11 +0100 Subject: [PATCH] Better definition for ls --- nushell/config.nu | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/nushell/config.nu b/nushell/config.nu index f06d4c9..897b5af 100644 --- a/nushell/config.nu +++ b/nushell/config.nu @@ -91,17 +91,29 @@ def _ls_format_mode [mode: string] { } def l [dir?: string] { - _ls (if $dir == null { "" } else { $dir }) + let output = _ls (if $dir == null { "" } else { $dir }) | sort-by type name -i - | grid -c -s " " - | cat + + if ($output | length) == 0 { + "" | cat + } else { + $output + | grid -c -s " " + | cat + } } def ls [dir?: string] { - _ls (if $dir == null { "" } else { $dir }) + let output = _ls (if $dir == null { "" } else { $dir }) | sort-by type name -i - | grid -c -s " " - | cat + + if ($output | length) == 0 { + "" | cat + } else { + $output + | grid -c -s " " + | cat + } } def la [dir?: string] {