From 0d9a163e02eba99c9d9d903c3bf588716d0fbcf4 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Tue, 26 Jan 2021 09:18:30 -0600 Subject: [PATCH] updated with categories --- 256-color.sh => coloring/256-color.sh | 0 coloring/README.md | 5 ++++ .../color_and_formatting.sh | 0 color_table.nu => coloring/color_table.nu | 0 color_tables.nu => coloring/color_tables.nu | 0 color_tables.sh => coloring/color_tables.sh | 0 colors.sh => coloring/colors.sh | 0 gradient.nu => coloring/gradient.nu | 0 gradient.ps1 => coloring/gradient.ps1 | 0 nu_index_bg.nu => coloring/nu_index_bg.nu | 0 nu_index_fg.nu => coloring/nu_index_fg.nu | 0 nu_index_fg2.nu => coloring/nu_index_fg2.nu | 0 .../python_index_table.nu | 0 ref_table.nu => coloring/ref_table.nu | 0 sample.nu => coloring/sample.nu | 0 short_list.nu => coloring/short_list.nu | 0 table.sh => coloring/table.sh | 0 nu_101/README.md | 5 ++++ demo.nu => nu_101/demo.nu | 0 .../inner_outer_loop.nu | 0 parsing/README.md | 5 ++++ .../sample_andres.json | 0 sample_andres.nu => parsing/sample_andres.nu | 0 print.nu | 17 ------------ progress_bar.nu | 22 ++++++++++++++++ prompt/README.md | 5 ++++ myprompt.nu => prompt/myprompt.nu | 0 stdlib_candidate/README.md | 13 ++++++++++ nu_style.nu => stdlib_candidate/nu_style.nu | 0 stdlib_candidate/print.nu | 26 +++++++++++++++++++ 30 files changed, 81 insertions(+), 17 deletions(-) rename 256-color.sh => coloring/256-color.sh (100%) mode change 100755 => 100644 create mode 100644 coloring/README.md rename color_and_formatting.sh => coloring/color_and_formatting.sh (100%) mode change 100755 => 100644 rename color_table.nu => coloring/color_table.nu (100%) rename color_tables.nu => coloring/color_tables.nu (100%) rename color_tables.sh => coloring/color_tables.sh (100%) rename colors.sh => coloring/colors.sh (100%) rename gradient.nu => coloring/gradient.nu (100%) rename gradient.ps1 => coloring/gradient.ps1 (100%) rename nu_index_bg.nu => coloring/nu_index_bg.nu (100%) rename nu_index_fg.nu => coloring/nu_index_fg.nu (100%) rename nu_index_fg2.nu => coloring/nu_index_fg2.nu (100%) rename python_index_table.nu => coloring/python_index_table.nu (100%) rename ref_table.nu => coloring/ref_table.nu (100%) rename sample.nu => coloring/sample.nu (100%) rename short_list.nu => coloring/short_list.nu (100%) rename table.sh => coloring/table.sh (100%) mode change 100755 => 100644 create mode 100644 nu_101/README.md rename demo.nu => nu_101/demo.nu (100%) rename inner_outer_loop.nu => nu_101/inner_outer_loop.nu (100%) create mode 100644 parsing/README.md rename sample_andres.json => parsing/sample_andres.json (100%) rename sample_andres.nu => parsing/sample_andres.nu (100%) delete mode 100644 print.nu create mode 100644 progress_bar.nu create mode 100644 prompt/README.md rename myprompt.nu => prompt/myprompt.nu (100%) create mode 100644 stdlib_candidate/README.md rename nu_style.nu => stdlib_candidate/nu_style.nu (100%) create mode 100644 stdlib_candidate/print.nu diff --git a/256-color.sh b/coloring/256-color.sh old mode 100755 new mode 100644 similarity index 100% rename from 256-color.sh rename to coloring/256-color.sh diff --git a/coloring/README.md b/coloring/README.md new file mode 100644 index 0000000..40b6110 --- /dev/null +++ b/coloring/README.md @@ -0,0 +1,5 @@ +# Coloring Scripts + +### Definition + +These scripts are used to demonstrate the `ansi` command using `ansi` coloring. This is mainly a demo area where we have taken typical `bash` scripts and ported them to nushell scripts. It would be nice if all scripts here showed the "other" version of script and the ported nushell version. We can show "other" flavors of scripts by including them as comments in the nushell scripts or by naming the nushell script and the other script the same basename. diff --git a/color_and_formatting.sh b/coloring/color_and_formatting.sh old mode 100755 new mode 100644 similarity index 100% rename from color_and_formatting.sh rename to coloring/color_and_formatting.sh diff --git a/color_table.nu b/coloring/color_table.nu similarity index 100% rename from color_table.nu rename to coloring/color_table.nu diff --git a/color_tables.nu b/coloring/color_tables.nu similarity index 100% rename from color_tables.nu rename to coloring/color_tables.nu diff --git a/color_tables.sh b/coloring/color_tables.sh similarity index 100% rename from color_tables.sh rename to coloring/color_tables.sh diff --git a/colors.sh b/coloring/colors.sh similarity index 100% rename from colors.sh rename to coloring/colors.sh diff --git a/gradient.nu b/coloring/gradient.nu similarity index 100% rename from gradient.nu rename to coloring/gradient.nu diff --git a/gradient.ps1 b/coloring/gradient.ps1 similarity index 100% rename from gradient.ps1 rename to coloring/gradient.ps1 diff --git a/nu_index_bg.nu b/coloring/nu_index_bg.nu similarity index 100% rename from nu_index_bg.nu rename to coloring/nu_index_bg.nu diff --git a/nu_index_fg.nu b/coloring/nu_index_fg.nu similarity index 100% rename from nu_index_fg.nu rename to coloring/nu_index_fg.nu diff --git a/nu_index_fg2.nu b/coloring/nu_index_fg2.nu similarity index 100% rename from nu_index_fg2.nu rename to coloring/nu_index_fg2.nu diff --git a/python_index_table.nu b/coloring/python_index_table.nu similarity index 100% rename from python_index_table.nu rename to coloring/python_index_table.nu diff --git a/ref_table.nu b/coloring/ref_table.nu similarity index 100% rename from ref_table.nu rename to coloring/ref_table.nu diff --git a/sample.nu b/coloring/sample.nu similarity index 100% rename from sample.nu rename to coloring/sample.nu diff --git a/short_list.nu b/coloring/short_list.nu similarity index 100% rename from short_list.nu rename to coloring/short_list.nu diff --git a/table.sh b/coloring/table.sh old mode 100755 new mode 100644 similarity index 100% rename from table.sh rename to coloring/table.sh diff --git a/nu_101/README.md b/nu_101/README.md new file mode 100644 index 0000000..cb27bca --- /dev/null +++ b/nu_101/README.md @@ -0,0 +1,5 @@ +# Nu_101 Scripts + +### Definition + +These scripts should be used to demonstrate to the beginner how nushell scripting works. Perhaps how it's different from Windows `batch` files and `bash` shell scripts. Also, to show off how nushell pipes commands in and out of one another. diff --git a/demo.nu b/nu_101/demo.nu similarity index 100% rename from demo.nu rename to nu_101/demo.nu diff --git a/inner_outer_loop.nu b/nu_101/inner_outer_loop.nu similarity index 100% rename from inner_outer_loop.nu rename to nu_101/inner_outer_loop.nu diff --git a/parsing/README.md b/parsing/README.md new file mode 100644 index 0000000..712ea15 --- /dev/null +++ b/parsing/README.md @@ -0,0 +1,5 @@ +# Parsing Scripts + +### Definition + +These scripts should be used to demonstrate how to parse any file format, including `json`, `csv`, etc. Also, perhaps parsing of `external` commands. For example, on Windows, perhaps we could wrap `ipconfig.exe` so that the output was more nushell friendly. diff --git a/sample_andres.json b/parsing/sample_andres.json similarity index 100% rename from sample_andres.json rename to parsing/sample_andres.json diff --git a/sample_andres.nu b/parsing/sample_andres.nu similarity index 100% rename from sample_andres.nu rename to parsing/sample_andres.nu diff --git a/print.nu b/print.nu deleted file mode 100644 index f2ac774..0000000 --- a/print.nu +++ /dev/null @@ -1,17 +0,0 @@ -# Not working yet - -# A print command that concatenates arguments together with an optional separator -# By default there will be no newline -def print [ - --separator(-s):any? # Optional separator - ...rest # All of the parameters - ] { - let is_empty = $(empty? $separator) - echo $rest | each { - if $is_empty { - build-string $it - } { - build-string $it $separator - } - } | str collect -} \ No newline at end of file diff --git a/progress_bar.nu b/progress_bar.nu new file mode 100644 index 0000000..88a3828 --- /dev/null +++ b/progress_bar.nu @@ -0,0 +1,22 @@ +# progress bar attempt - not 100% yet +# https://askubuntu.com/questions/747143/create-a-progress-bar-in-bash +# https://www.shellscript.sh/tips/progressbar/ + + + +let fill = "▒" # Fill up to $Len +let arr = [ "▉" "▎" "▌" "▊" ] # UTF-8 left blocks: 7/8, 1/4, 1/2, 3/4 +let pb_len = 10 + +echo $(ansi cursor_off) + +#Move cursor all the way to the left +echo $(ansi -e '1000D') | autoview +echo $fill | str lpad -c $fill -l $pb_len +echo 1..$pb_len | each { + sleep 50ms + echo $arr.0 | str lpad -c $arr.0 -l $it | autoview + echo $(ansi -e '1000D') | autoview +} +echo $(char newline) +echo $(ansi cursor_on) \ No newline at end of file diff --git a/prompt/README.md b/prompt/README.md new file mode 100644 index 0000000..aae382d --- /dev/null +++ b/prompt/README.md @@ -0,0 +1,5 @@ +# Prompt Scripts + +### Definition + +These scripts should be used to draw a custom command prompt in nushell. They can include anything that we think is appropriate for prompts such as `git` commands, `starship`, `oh-my-posh`, etc. diff --git a/myprompt.nu b/prompt/myprompt.nu similarity index 100% rename from myprompt.nu rename to prompt/myprompt.nu diff --git a/stdlib_candidate/README.md b/stdlib_candidate/README.md new file mode 100644 index 0000000..3df4469 --- /dev/null +++ b/stdlib_candidate/README.md @@ -0,0 +1,13 @@ +# Nushell standard library candidate scripts + +### Definition + +Standard library candidates are scripts that should be installed with nushell and be sourced at startup time that add additional functionality to nushell. Some of these scripts could even take the place of some of the current rust code. + +### Why Candidate? + +Since this is really the only documentation of what should be in a standard library for nushell, we need to decide as a community what needs to be included in a standard library. + +### Category + +Standard Library candidates can be any category of script. \ No newline at end of file diff --git a/nu_style.nu b/stdlib_candidate/nu_style.nu similarity index 100% rename from nu_style.nu rename to stdlib_candidate/nu_style.nu diff --git a/stdlib_candidate/print.nu b/stdlib_candidate/print.nu new file mode 100644 index 0000000..833175f --- /dev/null +++ b/stdlib_candidate/print.nu @@ -0,0 +1,26 @@ +# A print command that concatenates arguments together with an optional separator +# By default there will be no newline +def print [ + --separator(-s):any # Optional separator (not yet flagged as optional?) + ...rest # All of the parameters + ] { + let is_empty = $(= $separator | empty?) + let num_of_rest = $(echo $rest | count) + echo $rest | each --numbered { + if $is_empty { + build-string $it.item + } { + if $num_of_rest > $(= $it.index + 1) { + build-string $it.item $separator + } { + build-string $it.item + } + } + } | str collect +} + +# > print 1 2 3 "four" -s '--' +# 1--2--3--four + +# > print 1 2 3 "four" +# 123four \ No newline at end of file