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