From eb0dc27f4a47bfbe03013e158ff90b6d1db45526 Mon Sep 17 00:00:00 2001 From: Eli Flanagan Date: Mon, 1 Nov 2021 09:34:20 -0400 Subject: [PATCH 1/2] ls mod: hidden files I am attempting to list hidden files. But I am unsure how to use where and each together. Any tips appreciated! --- ls_mods/ls-hidden.nu | 1 + 1 file changed, 1 insertion(+) create mode 100644 ls_mods/ls-hidden.nu diff --git a/ls_mods/ls-hidden.nu b/ls_mods/ls-hidden.nu new file mode 100644 index 0000000..529cb84 --- /dev/null +++ b/ls_mods/ls-hidden.nu @@ -0,0 +1 @@ +ls -a | where | { each { echo $it.name | str starts-with '.'} } \ No newline at end of file From 275893f40bd841969dd5a03a42a7b33c2e9c797a Mon Sep 17 00:00:00 2001 From: Eli Flanagan Date: Mon, 1 Nov 2021 11:50:33 -0400 Subject: [PATCH 2/2] finish example thanks to fdncred Pure gold: https://github.com/nushell/nu_scripts/pull/104#issuecomment-956335793 --- ls_mods/ls-hidden.nu | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ls_mods/ls-hidden.nu b/ls_mods/ls-hidden.nu index 529cb84..94eee72 100644 --- a/ls_mods/ls-hidden.nu +++ b/ls_mods/ls-hidden.nu @@ -1 +1,6 @@ -ls -a | where | { each { echo $it.name | str starts-with '.'} } \ No newline at end of file + +def ls-hidden [ + --dir(-d):any # The directory you want to list +] { + ls -a $dir | where { ($it.name | into string | str starts-with '.') } +}