From 5929c5965fdfee0c6e67dcc9636e6272ee758da1 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Mon, 8 Feb 2021 11:58:33 -0600 Subject: [PATCH] added some new scripts --- ls-less.nu | 12 ++++++++++++ stdlib_candidate/get-column.nu | 7 +++++++ stdlib_candidate/get-row.nu | 7 +++++++ stdlib_candidate/print.nu | 8 ++++---- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 ls-less.nu create mode 100644 stdlib_candidate/get-column.nu create mode 100644 stdlib_candidate/get-row.nu diff --git a/ls-less.nu b/ls-less.nu new file mode 100644 index 0000000..4309718 --- /dev/null +++ b/ls-less.nu @@ -0,0 +1,12 @@ +# An attempt at trying to put ls into a paging mode +def ls-less [ + --dir(-d):any # The directory you want to list +] { + let is_empty = $(= $dir | empty?) + if $is_empty { + nu -c 'ls' | less -r + } { + let command = $(build-string 'ls ' $dir) + nu -c $command | less -r + } +} \ No newline at end of file diff --git a/stdlib_candidate/get-column.nu b/stdlib_candidate/get-column.nu new file mode 100644 index 0000000..9f5def4 --- /dev/null +++ b/stdlib_candidate/get-column.nu @@ -0,0 +1,7 @@ +# This is a wrapper to get a row +def get-col [ + col_name:any # A 0 indexed row + ] { + + get $col_name +} \ No newline at end of file diff --git a/stdlib_candidate/get-row.nu b/stdlib_candidate/get-row.nu new file mode 100644 index 0000000..97b3fb4 --- /dev/null +++ b/stdlib_candidate/get-row.nu @@ -0,0 +1,7 @@ +# This is a wrapper to get a row +def get-row [ + row_num:int # A 0 indexed row + ] { + + nth $row_num | table -n $row_num +} \ No newline at end of file diff --git a/stdlib_candidate/print.nu b/stdlib_candidate/print.nu index de25bba..035dddf 100644 --- a/stdlib_candidate/print.nu +++ b/stdlib_candidate/print.nu @@ -42,7 +42,7 @@ def print2 [ } # Bring in the logging command -source logging.nu +#source logging.nu # A print command that concatenates arguments together with an optional separator. # This print command will also concatenate tables like [1 2 3] as well as most other primitives @@ -57,13 +57,13 @@ def print3 [ let flat = $(= $flat | empty?) echo $rest | each --numbered { if $sep_empty { - log 'sep is empty' + #log 'sep is empty' if $(echo $it.item | count) > 1 && $flat { - log 'flatten please' + #log 'flatten please' let flatter = $(echo $it.item | flatten | str from | str collect) build-string $flatter } { - log 'no flat' + #log 'no flat' build-string $it.item } } {