From 1bc6b400c6f31e9907302a4b8403bddeccbd053f Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Wed, 27 Mar 2024 09:22:43 -0300 Subject: [PATCH 1/9] :bug: replace `str collect` for `str join` --- before_v0.60/bin-utils.nu | 2 +- before_v0.60/coloring/256_color_testpattern.nu | 4 ++-- before_v0.60/coloring/color_table.nu | 6 +++--- before_v0.60/coloring/color_tables.nu | 12 ++++++------ before_v0.60/coloring/gradient.nu | 4 ++-- before_v0.60/coloring/nu_index_bg.nu | 2 +- before_v0.60/coloring/nu_index_fg.nu | 4 ++-- before_v0.60/coloring/nu_index_fg2.nu | 4 ++-- before_v0.60/coloring/python_index_table.nu | 8 ++++---- before_v0.60/coloring/ref_table.nu | 8 ++++---- before_v0.60/coloring/sample.nu | 6 +++--- before_v0.60/cool_oneliners/dict.nu | 2 +- before_v0.60/examples/date_in_local_timezones.nu | 2 +- before_v0.60/examples/netstat.nu | 4 ++-- before_v0.60/fun/life.nu | 4 ++-- before_v0.60/fun/nyancat.nu | 4 ++-- before_v0.60/fun/spark.nu | 2 +- before_v0.60/fun/star.nu | 6 +++--- before_v0.60/fuzzy/fuzzy_command_search.nu | 2 +- before_v0.60/language/playground/lib.nu | 2 +- before_v0.60/ls_mods/ls-wide-with-color.nu | 2 +- before_v0.60/ls_mods/ls-wide.nu | 2 +- before_v0.60/make_release/gen-js-ext.nu | 4 ++-- before_v0.60/make_release/gen-ts-ext.nu | 12 ++++++------ .../make_release/this_week_in_nu_release.nu | 8 ++++---- .../make_release/this_week_in_nu_weekly.nu | 8 ++++---- before_v0.60/nu_101/inner_outer_loop.nu | 4 ++-- before_v0.60/prompt/git_status_prompt.nu | 4 ++-- before_v0.60/prompt/left_and_right_prompt.nu | 14 +++++++------- before_v0.60/stdlib_candidate/nu_style.nu | 6 +++--- before_v0.60/stdlib_candidate/print.nu | 16 ++++++++-------- before_v0.60/virtual_environments/conda.nu | 6 +++--- before_v0.60/virtual_environments/venv.nu | 6 +++--- 33 files changed, 90 insertions(+), 90 deletions(-) diff --git a/before_v0.60/bin-utils.nu b/before_v0.60/bin-utils.nu index ae866fae1..e54f5c31a 100644 --- a/before_v0.60/bin-utils.nu +++ b/before_v0.60/bin-utils.nu @@ -67,7 +67,7 @@ export def "test bits" [] { error make { msg: "Test mismatch", label: { - text: $"Expected: ($it), bits: ($bits | str collect ''), result: ($res)" + text: $"Expected: ($it), bits: ($bits | str join ''), result: ($res)" start: $span.start end: $span.end } diff --git a/before_v0.60/coloring/256_color_testpattern.nu b/before_v0.60/coloring/256_color_testpattern.nu index e73b20c2f..e69e4945d 100644 --- a/before_v0.60/coloring/256_color_testpattern.nu +++ b/before_v0.60/coloring/256_color_testpattern.nu @@ -54,7 +54,7 @@ def print_run [start:int, amount:int] { } { "" } - } | append " " | str collect + } | append " " | str join } def print_blocks [start:int, end:int, block-cols:int, block-rows:int, blocks-per-line:int] { @@ -64,7 +64,7 @@ def print_blocks [start:int, end:int, block-cols:int, block-rows:int, blocks-per for row in 0..<$block-rows { for block in 0..<$blocks-per-line { print_run ($start + $block * $block-length + $row * $block-cols + $i * $block-length * $blocks-per-line) $block-cols - } | append (char nl) | str collect | autoview + } | append (char nl) | str join | autoview } char nl | autoview } diff --git a/before_v0.60/coloring/color_table.nu b/before_v0.60/coloring/color_table.nu index 0fae41cde..7abd286da 100644 --- a/before_v0.60/coloring/color_table.nu +++ b/before_v0.60/coloring/color_table.nu @@ -47,7 +47,7 @@ def mk_header [color_range:range] { ($ansi_color | str lpad -l $lo_regular_pad -c ' ') } } - } | str collect + } | str join echo (char newline) } @@ -58,14 +58,14 @@ def color_row_range [num:int bg_rg:range] { let row_name = $"($num);($back)m" let ansi_color = (ansi -e $row_name) $"($ansi_color) ($row_name) ($reset)" - } | append (char newline) | str collect) + } | append (char newline) | str join) $"($row_header)($row_data)" } def create_color_tables [fg_range:range bg_range:range] { echo $fg_range | each { |fg| color_row_range $fg $bg_range - } | str collect + } | str join } def color_table [] { diff --git a/before_v0.60/coloring/color_tables.nu b/before_v0.60/coloring/color_tables.nu index 27018c33e..0e855ee53 100644 --- a/before_v0.60/coloring/color_tables.nu +++ b/before_v0.60/coloring/color_tables.nu @@ -16,11 +16,11 @@ for x in 0..8 { let row = (for a in 40..47 { let color = $"($x);($i);($a)" $"(ansi -e $color)m\e[($color)(ansi -e '0;37;40')m " - } | str collect) + } | str join) $"($row)(char newline)" - } | str collect) + } | str join) $"($row)(char newline)" -} | str collect +} | str join # Nushell 0.31.0 # echo 0..8 | each { |style| @@ -28,8 +28,8 @@ for x in 0..8 { # let row = (echo 40..47 | each { |bg| # let color = $"($style);($fg);($bg)m" # $"(ansi -e $color)($color)(ansi reset) " -# } | str collect) +# } | str join) # $"($row)(char newline)" -# } | str collect) +# } | str join) # $"($row)(char newline)" -# } | str collect \ No newline at end of file +# } | str join \ No newline at end of file diff --git a/before_v0.60/coloring/gradient.nu b/before_v0.60/coloring/gradient.nu index 23cacee5b..3beb9638e 100644 --- a/before_v0.60/coloring/gradient.nu +++ b/before_v0.60/coloring/gradient.nu @@ -14,9 +14,9 @@ seq 0 $height | each { } { $"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')" } - } | str collect) + } | str join) $"($row_data)(char newline)" | autoview -} | str collect +} | str join def iter_inc [incr mult iter] { $incr + $mult * $iter diff --git a/before_v0.60/coloring/nu_index_bg.nu b/before_v0.60/coloring/nu_index_bg.nu index be99e70c5..c805e8850 100644 --- a/before_v0.60/coloring/nu_index_bg.nu +++ b/before_v0.60/coloring/nu_index_bg.nu @@ -9,7 +9,7 @@ def show_index_colors [] { } { $"($color)($padded_number) (ansi -e 0m)" } - } | str collect + } | str join } show_index_colors diff --git a/before_v0.60/coloring/nu_index_fg.nu b/before_v0.60/coloring/nu_index_fg.nu index b69f9155e..a1a78a0f5 100644 --- a/before_v0.60/coloring/nu_index_fg.nu +++ b/before_v0.60/coloring/nu_index_fg.nu @@ -7,10 +7,10 @@ def show_index_colors [] { } { $"(ansi -e $prefix)($fg)m($fg | into string | str lpad -l 3 -c '0') " } - } | str collect + } | str join } show_index_colors #one-liner -#echo 0..255 | each { |fg| echo [(ansi -e '38;5;') ($fg | into string) 'm' ($fg | into string) ' ']} | str collect \ No newline at end of file +#echo 0..255 | each { |fg| echo [(ansi -e '38;5;') ($fg | into string) 'm' ($fg | into string) ' ']} | str join \ No newline at end of file diff --git a/before_v0.60/coloring/nu_index_fg2.nu b/before_v0.60/coloring/nu_index_fg2.nu index d28726673..88d9c4619 100644 --- a/before_v0.60/coloring/nu_index_fg2.nu +++ b/before_v0.60/coloring/nu_index_fg2.nu @@ -13,7 +13,7 @@ def show_index_colors [] { } { $"($color)($padded_number) " } - } | str collect + } | str join } show_index_colors @@ -22,4 +22,4 @@ show_index_colors # it all on one line which wraps in # your terminal -#echo 1..256 | each { |idx| echo [(ansi -e '38;5;') (build-string $idx) 'm' (build-string $idx) ' ']} | str collect \ No newline at end of file +#echo 1..256 | each { |idx| echo [(ansi -e '38;5;') (build-string $idx) 'm' (build-string $idx) ' ']} | str join \ No newline at end of file diff --git a/before_v0.60/coloring/python_index_table.nu b/before_v0.60/coloring/python_index_table.nu index ec127a607..c1869a69a 100644 --- a/before_v0.60/coloring/python_index_table.nu +++ b/before_v0.60/coloring/python_index_table.nu @@ -13,9 +13,9 @@ echo 0..16 | each { |col| if $code < 256 { $"(ansi -e '38;5;')($code | into string)m($code | into string | str lpad -l 4 -c ' ')(ansi reset)" } {} # Do nothing in the else - } | str collect) + } | str join) $"($row)(char newline)" -} | str collect +} | str join # Background Colors echo 0..16 | each { |col| @@ -24,6 +24,6 @@ echo 0..16 | each { |col| if $code < 256 { $"(ansi -e '48;5;')($code | into string)m($code | into string | str lpad -l 4 -c ' ')(ansi reset)" } {} # do nothing in the else - } | str collect) + } | str join) $"($row)(char newline)" -} | str collect +} | str join diff --git a/before_v0.60/coloring/ref_table.nu b/before_v0.60/coloring/ref_table.nu index 7e97acaad..55d6ba420 100644 --- a/before_v0.60/coloring/ref_table.nu +++ b/before_v0.60/coloring/ref_table.nu @@ -4,7 +4,7 @@ # This prints the column headers let nl = (char newline) let plus = $"($nl) + " -let cols = (seq 0 35 | each { |col| $"($col)" | str lpad -c ' ' -l 3 } | str collect) +let cols = (seq 0 35 | each { |col| $"($col)" | str lpad -c ' ' -l 3 } | str join) $"($plus)($cols)" let ansi_bg = (ansi -e '48;5;') @@ -15,7 +15,7 @@ $"($nl)($nl)" let row_header = ' 0 ' let row_data = (seq 0 15 | each { |row| $"($ansi_bg)($row)m ($ansi_reset)" -} | str collect) +} | str join) $"($row_header)($row_data)($nl)($nl)" # This is the meat of the script that prints the little squares of color @@ -25,6 +25,6 @@ seq 0 6 | each { |row_idx| let row_data = (seq 0 35 | each { |row| let val = ($"($r + $row)" | math eval | into string -d 0) $"($ansi_bg)($val)m (ansi -e 'm') " - } | str collect) + } | str join) $"($row_header) ($row_data)($nl)($nl)" -} | str collect +} | str join diff --git a/before_v0.60/coloring/sample.nu b/before_v0.60/coloring/sample.nu index c2e5fd250..88ddb13b4 100644 --- a/before_v0.60/coloring/sample.nu +++ b/before_v0.60/coloring/sample.nu @@ -15,10 +15,10 @@ echo 40..47 100..107 49 | each { |clbg| let row = (echo 0..9 | each { |attr| let ansi_str = $"($attr);($clbg);($clfg)m" $"(ansi -e $ansi_str) ($ansi_str) (ansi reset)" - } | str collect) + } | str join) $"($row)(char newline)" | autoview - } | str collect -} | str collect + } | str join +} | str join # Bash Script # for clbg in {40..47} {100..107} 49 ; do diff --git a/before_v0.60/cool_oneliners/dict.nu b/before_v0.60/cool_oneliners/dict.nu index 3678ffd28..bd12cbd01 100644 --- a/before_v0.60/cool_oneliners/dict.nu +++ b/before_v0.60/cool_oneliners/dict.nu @@ -1,7 +1,7 @@ # Function querying free online English dictionary API for definition of given word(s) def dict [...word #word(s) to query the dictionary API but they have to make sense together like "martial law", not "cats dogs" ] { - let query = ($word | str collect %20) + let query = ($word | str join %20) let link = (build-string 'https://api.dictionaryapi.dev/api/v2/entries/en/' ($query|str find-replace ' ' '%20')) let output = (fetch $link | rename word) diff --git a/before_v0.60/examples/date_in_local_timezones.nu b/before_v0.60/examples/date_in_local_timezones.nu index 2b8eb2c59..1c3815d63 100644 --- a/before_v0.60/examples/date_in_local_timezones.nu +++ b/before_v0.60/examples/date_in_local_timezones.nu @@ -11,7 +11,7 @@ def say [block] { [[name]; [($person.name | str capitalize)]] } ) - } | str collect (char newline) + } | str join (char newline) } $people | say {|person| $"($person.name)'s timezone is ($person.tz)"} diff --git a/before_v0.60/examples/netstat.nu b/before_v0.60/examples/netstat.nu index 596cc9412..056f88db0 100644 --- a/before_v0.60/examples/netstat.nu +++ b/before_v0.60/examples/netstat.nu @@ -1,10 +1,10 @@ let ns = (netstat | lines | skip 1) -let first-batch = ($ns | keep until $it =~ Active | str collect (char nl) | from ssv -m 1) +let first-batch = ($ns | keep until $it =~ Active | str join (char nl) | from ssv -m 1) let second-batch = ($ns | skip until $it =~ Active | skip 1 | - str collect (char nl) | + str join (char nl) | str find-replace "\[ \]" "[]" --all | from ssv -m 1 | default I-Node "" | diff --git a/before_v0.60/fun/life.nu b/before_v0.60/fun/life.nu index bf8dc6003..1651daa9a 100644 --- a/before_v0.60/fun/life.nu +++ b/before_v0.60/fun/life.nu @@ -52,8 +52,8 @@ def print-grid [$grid] { } { "." } - } | append (char nl) | str collect - } | str collect + } | append (char nl) | str join + } | str join } def main [] { diff --git a/before_v0.60/fun/nyancat.nu b/before_v0.60/fun/nyancat.nu index 7c4c6163b..39ec1d131 100644 --- a/before_v0.60/fun/nyancat.nu +++ b/before_v0.60/fun/nyancat.nu @@ -58,10 +58,10 @@ let frames = [ # it's a little slow - maybe 1 fps but still firmly in the 'fun' category ansi cursor_off for x in $frames -n { - $frames | nth $x.index | get frames | split chars | each -n {|char| if $char.index mod 64 == 0 { $"(ansi -e '0m')(char nl)" } {$"(ansi -e ($map | where symbol == $char.item | get color))(char sp)"}} | str collect + $frames | nth $x.index | get frames | split chars | each -n {|char| if $char.index mod 64 == 0 { $"(ansi -e '0m')(char nl)" } {$"(ansi -e ($map | where symbol == $char.item | get color))(char sp)"}} | str join ansi -e '0m' ansi cls -} | str collect +} | str join ansi cursor_on char nl \ No newline at end of file diff --git a/before_v0.60/fun/spark.nu b/before_v0.60/fun/spark.nu index 8678036b5..f27fe57ed 100644 --- a/before_v0.60/fun/spark.nu +++ b/before_v0.60/fun/spark.nu @@ -19,5 +19,5 @@ def spark [v: any] { for e in $v { let i = (($e - $min) / $scale | into int) $"($TICKS | nth $i)" - } | str collect + } | str join } \ No newline at end of file diff --git a/before_v0.60/fun/star.nu b/before_v0.60/fun/star.nu index a922bec8a..7619ae1a4 100644 --- a/before_v0.60/fun/star.nu +++ b/before_v0.60/fun/star.nu @@ -131,10 +131,10 @@ $"(ansi -e '?25h')(ansi -e 'm')(ansi -e 'H')" # $"(ansi -e '38;2;')($c);($c);($c)m*" # }) -# echo $cols | str collect +# echo $cols | str join # }) -# (ansi -e 'H') + (echo $rows | str collect (char nl)) -# } | str collect) +# (ansi -e 'H') + (echo $rows | str join (char nl)) +# } | str join) # (ansi -e "?25l") + $output + $"(ansi -e '?25h')(ansi -e 'm')(ansi -e 'H')" diff --git a/before_v0.60/fuzzy/fuzzy_command_search.nu b/before_v0.60/fuzzy/fuzzy_command_search.nu index 32a8da855..9214771cb 100644 --- a/before_v0.60/fuzzy/fuzzy_command_search.nu +++ b/before_v0.60/fuzzy/fuzzy_command_search.nu @@ -33,6 +33,6 @@ def fuzzy-command-search [] { )( $it.description )" - }) | str collect (char nl) | fzf | split column (char tab)| get Column1 | clip; paste ) + }) | str join (char nl) | fzf | split column (char tab)| get Column1 | clip; paste ) } diff --git a/before_v0.60/language/playground/lib.nu b/before_v0.60/language/playground/lib.nu index b854b682e..4dc456537 100644 --- a/before_v0.60/language/playground/lib.nu +++ b/before_v0.60/language/playground/lib.nu @@ -1,6 +1,6 @@ def playground [topic, block] { with-env [N 5 REJECT slow] { - echo $topic " tests" (char newline) | str collect + echo $topic " tests" (char newline) | str join do $block } diff --git a/before_v0.60/ls_mods/ls-wide-with-color.nu b/before_v0.60/ls_mods/ls-wide-with-color.nu index 32f4ae34b..f3dcf7890 100644 --- a/before_v0.60/ls_mods/ls-wide-with-color.nu +++ b/before_v0.60/ls_mods/ls-wide-with-color.nu @@ -49,7 +49,7 @@ def ls-wide2 [ echo (char newline) | autoview } {} } - } | str collect + } | str join } def colorize [thing:any] { diff --git a/before_v0.60/ls_mods/ls-wide.nu b/before_v0.60/ls_mods/ls-wide.nu index 613c58bd2..304f16e3a 100644 --- a/before_v0.60/ls_mods/ls-wide.nu +++ b/before_v0.60/ls_mods/ls-wide.nu @@ -43,7 +43,7 @@ def run_ls [ echo (char newline) | autoview } {} } - } | str collect + } | str join } # This is a first attempt and some type of logging diff --git a/before_v0.60/make_release/gen-js-ext.nu b/before_v0.60/make_release/gen-js-ext.nu index eeaaf92be..b9059dc31 100644 --- a/before_v0.60/make_release/gen-js-ext.nu +++ b/before_v0.60/make_release/gen-js-ext.nu @@ -1,5 +1,5 @@ def gen_keywords [] { - let cmds = (help commands | where description != '' | get name | str collect '|') + let cmds = (help commands | where description != '' | get name | str join '|') let var_with_dash_or_under_regex = "(([a-zA-Z]+[\\-_]){1,}[a-zA-Z]+\\s)" let preamble = "\\b(" let postamble = ")\\b" @@ -16,7 +16,7 @@ def gen_sub_keywords [] { let postamble = ")\\b" let cmds = (for x in $sub_cmds { $"($x.base)\\s($x.sub)" - } | str collect '|') + } | str join '|') $'"match": "($preamble)($cmds)($postamble)",' } $"Generating sub keywords(char nl)" diff --git a/before_v0.60/make_release/gen-ts-ext.nu b/before_v0.60/make_release/gen-ts-ext.nu index b617e213b..61ae66759 100644 --- a/before_v0.60/make_release/gen-ts-ext.nu +++ b/before_v0.60/make_release/gen-ts-ext.nu @@ -25,9 +25,9 @@ def gen-ts-cmds [] { let line1 = (build-string " const " $it.camel " = new vscode.CompletionItem('" $it.name "');" (char newline)) let line2 = (build-string " " $it.camel ".commitCharacters = [' '];" (char newline) (char newline)) $line1 + $line2 - } | str collect) + } | str join) - build-string (echo $ts) (char nl) " return [ " (echo $updated_cmds | get camel | str collect ', ') " ];" (char nl) ' },' (char nl) ' }' (char nl) ' );' (char nl) (char nl) | str collect + build-string (echo $ts) (char nl) " return [ " (echo $updated_cmds | get camel | str join ', ') " ];" (char nl) ' },' (char nl) ' }' (char nl) ' );' (char nl) (char nl) | str join } # generate typescript from nushell subcommands @@ -57,9 +57,9 @@ def gen-ts-subs [] { let line08 = (build-string ' ' $method '.detail = "' $it.item.description '";' (char nl) (char nl)) $line07 + $line08 } - } | str collect) + } | str join) - let methods = (echo $it.sub_cmds.name | str camel-case | str collect ', ') + let methods = (echo $it.sub_cmds.name | str camel-case | str join ', ') let lines = $" return [ @@ -75,11 +75,11 @@ def gen-ts-subs [] { " build-string $preamble $lines - } | str collect) + } | str join) echo $subs_collection | let post01 = (build-string " context.subscriptions.push(" (char nl)) - let post02 = (build-string " " (echo $updated_cmds | get camelProvider | uniq | str collect ', ') (char nl)) + let post02 = (build-string " " (echo $updated_cmds | get camelProvider | uniq | str join ', ') (char nl)) let post03 = (build-string " );" (char nl) "}" (char nl)) build-string $ts $post01 $post02 $post03 diff --git a/before_v0.60/make_release/this_week_in_nu_release.nu b/before_v0.60/make_release/this_week_in_nu_release.nu index 83dc2c3bf..adc168ec1 100644 --- a/before_v0.60/make_release/this_week_in_nu_release.nu +++ b/before_v0.60/make_release/this_week_in_nu_release.nu @@ -43,10 +43,10 @@ def do-work [] { } { $"(char nl)### [($pr.item.title)](char lparen)($pr.item.html_url)(char rparen)(char nl)(char nl)($pr.item.body)(char nl) and (char nl)" } - } | str collect) + } | str join) $"### **($user_name)**(char nl)(char nl)---(char nl)($user_prs)(char nl)" - } | str collect + } | str join char nl } @@ -56,11 +56,11 @@ def do-work [] { if ($entries | all? (echo $it | empty?)) { } { - $entries | str collect + $entries | str join } } # 2019-08-23 was the release of 0.2.0, the first public release let week_num = (seq date -b '2019-08-23' -n 7 | length) $"# This week in Nushell #($week_num)(char nl)(char nl)" -do-work | str collect +do-work | str join diff --git a/before_v0.60/make_release/this_week_in_nu_weekly.nu b/before_v0.60/make_release/this_week_in_nu_weekly.nu index 4894068a4..68318206b 100644 --- a/before_v0.60/make_release/this_week_in_nu_weekly.nu +++ b/before_v0.60/make_release/this_week_in_nu_weekly.nu @@ -46,17 +46,17 @@ def do-work [] { } { $"[($pr.item.title)](char lparen)($pr.item.html_url)(char rparen), and " } - } | str collect) + } | str join) $"- ($user_name) created ($user_prs) (char nl)" - } | str collect + } | str join char nl } }) if ($entries | all? ($it | empty?)) { } { - $entries | str collect + $entries | str join } } @@ -67,5 +67,5 @@ $"# This week in Nushell #($week_num)(char nl)(char nl)" if ($nu.env | select GITHUB_USERNAME | empty?) or ($nu.env | select GITHUB_PASSWORD | empty?) { echo 'Please set GITHUB_USERNAME and GITHUB_PASSWORD in $nu.env to use this script' } { - do-work | str collect + do-work | str join } diff --git a/before_v0.60/nu_101/inner_outer_loop.nu b/before_v0.60/nu_101/inner_outer_loop.nu index be9722811..f2825e7db 100644 --- a/before_v0.60/nu_101/inner_outer_loop.nu +++ b/before_v0.60/nu_101/inner_outer_loop.nu @@ -6,6 +6,6 @@ seq 30 39 | each { |outer| let row = $"($outer) " let data = (seq 40 49 | each { |inner| $"($inner) " - } | str collect) + } | str join) $"($row)($data)(char newline)" -} | str collect \ No newline at end of file +} | str join \ No newline at end of file diff --git a/before_v0.60/prompt/git_status_prompt.nu b/before_v0.60/prompt/git_status_prompt.nu index 1184b353c..157514c82 100644 --- a/before_v0.60/prompt/git_status_prompt.nu +++ b/before_v0.60/prompt/git_status_prompt.nu @@ -25,7 +25,7 @@ def prompt-pwd [] { $"($part | str substring [0 1])/" } }) - $"~/($short-part | str collect)($path | last)" + $"~/($short-part | str join)($path | last)" } { $"~/($path | last)" } @@ -85,7 +85,7 @@ def git-branch-icon [] { } { "red" }) - $"|(ansi $branch-colour)($branch)(ansi reset):($modified | get status | uniq | str downcase | each { git-prompt-icons $it })" | str collect + $"|(ansi $branch-colour)($branch)(ansi reset):($modified | get status | uniq | str downcase | each { git-prompt-icons $it })" | str join } } { "" diff --git a/before_v0.60/prompt/left_and_right_prompt.nu b/before_v0.60/prompt/left_and_right_prompt.nu index 4b10ad4b5..caddfe67b 100644 --- a/before_v0.60/prompt/left_and_right_prompt.nu +++ b/before_v0.60/prompt/left_and_right_prompt.nu @@ -12,7 +12,7 @@ def construct_prompt [] { # the current bit branch # let git_status = (git -c core.quotepath=false -c color.status=false status -uall --short --branch) - let git_info = (do -i { git rev-parse --abbrev-ref HEAD } | str trim -c (char nl) | str collect ) + let git_info = (do -i { git rev-parse --abbrev-ref HEAD } | str trim -c (char nl) | str join ) # what to put in the title let title_bar = (set_title) @@ -49,7 +49,7 @@ def construct_prompt [] { echo $title_bar # and last, but not least, let's print the prompt - echo $the_prompt | str collect + echo $the_prompt | str join ## put this in your config.toml # prompt = "construct_prompt" @@ -73,7 +73,7 @@ def home_abbrev [] { # Get Git Info custom commands def git_br [] { - $"(ansi gb)(pwd)(ansi reset)(char lparen)(ansi cb)(do -i { git rev-parse --abbrev-ref HEAD } | str trim -c (char nl) | str collect)(ansi reset)(char rparen)(char newline)(ansi yb)(date now | date format '%m/%d/%Y %I:%M:%S%.3f %p')(ansi reset)¯\\_(char lparen)ツ)_/¯(char prompt) " + $"(ansi gb)(pwd)(ansi reset)(char lparen)(ansi cb)(do -i { git rev-parse --abbrev-ref HEAD } | str trim -c (char nl) | str join)(ansi reset)(char rparen)(char newline)(ansi yb)(date now | date format '%m/%d/%Y %I:%M:%S%.3f %p')(ansi reset)¯\\_(char lparen)ツ)_/¯(char prompt) " } # Set Title String custom commands @@ -83,15 +83,15 @@ def set_title_str [str-arg] { } # def get_abbrev_pwd_win [] { -# echo [(pwd | split row '\' | first (pwd | split row '\' | length | each { $it - 1} ) | str substring '0,1' | format '{$it}/' | append (pwd | split row '\' | last ) | str collect)] | str collect +# echo [(pwd | split row '\' | first (pwd | split row '\' | length | each { $it - 1} ) | str substring '0,1' | format '{$it}/' | append (pwd | split row '\' | last ) | str join)] | str join # } def get_abbrev_pwd_lin [] { - # echo [(pwd | split row '/' | first (pwd | split row '/' | length | each { $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append (pwd | split row '/' | last ) | str collect)] | str collect - echo [(home_abbrev | split row '/' | first (home_abbrev | split row '/' | length | each { $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append (home_abbrev | split row '/' | last ) | str collect)] | str collect + # echo [(pwd | split row '/' | first (pwd | split row '/' | length | each { $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append (pwd | split row '/' | last ) | str join)] | str join + echo [(home_abbrev | split row '/' | first (home_abbrev | split row '/' | length | each { $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append (home_abbrev | split row '/' | last ) | str join)] | str join } def set_title [] { - set_title_str (build-string (get_abbrev_pwd_lin) ' ' (term size -w) 'x' (term size -t) | str collect) + set_title_str (build-string (get_abbrev_pwd_lin) ' ' (term size -w) 'x' (term size -t) | str join) } def create_second_line [] { build-string (ansi gb) (char -u "2514") (char -u "2500") ' $ ' (ansi cb) (char prompt) (ansi reset) diff --git a/before_v0.60/stdlib_candidate/nu_style.nu b/before_v0.60/stdlib_candidate/nu_style.nu index cfaf4b873..e57cfabc7 100644 --- a/before_v0.60/stdlib_candidate/nu_style.nu +++ b/before_v0.60/stdlib_candidate/nu_style.nu @@ -2,7 +2,7 @@ # found here https://github.com/PowerShell/PowerShell/blob/5f3dd938b792e1a395fd011ac1461246db7c0e1f/src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs # Example Usage -# echo (fg_blue) Darren (relet) ' ' Schroeder | str collect +# echo (fg_blue) Darren (relet) ' ' Schroeder | str join # More examples in the short_list.nu script alias fmt_error = ansi -e '31;1m' @@ -29,7 +29,7 @@ alias strikethrough_off = ansi -e '29m' alias strikethrough_on = ansi -e '9m' # this doesn't work right. i need to have an (ansi escape) defined but i don't think there is one -#def format_hyperlink [link text] {echo [(ansi -o '8;;') $link '\' $text (ansi -o '8;;') '\'] | str collect } +#def format_hyperlink [link text] {echo [(ansi -o '8;;') $link '\' $text (ansi -o '8;;') '\'] | str join } alias fg_black = ansi -e '30m' alias fg_red = ansi -e '31m' @@ -59,7 +59,7 @@ def fg_from_rgb [ green:int # green component 0-255 blue:int # blue component 0-255 ] { - echo [(ansi -e '38;2;') $red ';' $green ';' $blue 'm'] | str collect + echo [(ansi -e '38;2;') $red ';' $green ';' $blue 'm'] | str join } alias bg_black = ansi -e '40m' diff --git a/before_v0.60/stdlib_candidate/print.nu b/before_v0.60/stdlib_candidate/print.nu index 6e1ac07fa..376af1ff1 100644 --- a/before_v0.60/stdlib_candidate/print.nu +++ b/before_v0.60/stdlib_candidate/print.nu @@ -16,7 +16,7 @@ def print [ $param.item } } - } | into string | str collect + } | into string | str join } # > print 1 2 3 "four" -s '--' @@ -26,7 +26,7 @@ def print [ # 123four # An alternate print command that concatenates arguments together with an optional separator. -# This one uses str collect instead of build-string. +# This one uses str join instead of build-string. # By default there will be no newline def print2 [ --separator(-s):any # Optional separator (not yet flagged as optional?) @@ -35,9 +35,9 @@ def print2 [ let is_empty = ($separator | empty?) let num_of_rest = ($rest | length) if $is_empty { - $rest | into string | str collect + $rest | into string | str join } { - $rest | into string | str collect $separator + $rest | into string | str join $separator } } @@ -60,7 +60,7 @@ def print3 [ #log 'sep is empty' if (echo $param.item | length) > 1 and $flat { #log 'flatten please' - let flatter = ($param.item | flatten | into string | str collect) + let flatter = ($param.item | flatten | into string | str join) $flatter } { #log 'no flat' @@ -69,19 +69,19 @@ def print3 [ } { if $num_of_rest > ($param.index + 1) { if ($param.item | length) > 1 and $flat { - let flatter = ($param.item | flatten | into string | str collect $separator) + let flatter = ($param.item | flatten | into string | str join $separator) $"($flatter)($separator)" } { $"($param.item)($separator)" } } { if ($param.item | length) > 1 and $flat { - let flatter = ($param.item | flatten | into string | str collect $separator) + let flatter = ($param.item | flatten | into string | str join $separator) $flatter } { $param.item } } } - } | str collect + } | str join } diff --git a/before_v0.60/virtual_environments/conda.nu b/before_v0.60/virtual_environments/conda.nu index 7e8740231..ce3eae2b8 100644 --- a/before_v0.60/virtual_environments/conda.nu +++ b/before_v0.60/virtual_environments/conda.nu @@ -2,7 +2,7 @@ def conda-env [env-name] { let conda-info = (conda info --envs --json | from json) let suffix = (if $env-name == "base" {""} {(["envs" $env-name] | path join)}) let env-dir = ([$conda-info.root_prefix $suffix] | path join) - let old-path = ($nu.path | str collect (path-sep)) + let old-path = ($nu.path | str join (path-sep)) let new-path = (if (windows?) { (conda-create-path-windows $env-dir) } { (conda-create-path-unix $env-dir) }) let new-env = [[name, value]; [CONDA_DEFAULT_ENV $env-name] @@ -24,7 +24,7 @@ def conda-create-path-windows [env-dir] { ([$env-dir "Library" "bin"] | path join) ([$env-dir "Library" "usr" "bin"] | path join) ] - let new-path = ([$env-path $nu.path] | flatten | str collect (path-sep)) + let new-path = ([$env-path $nu.path] | flatten | str join (path-sep)) [[name, value]; [Path $new-path]] } @@ -32,7 +32,7 @@ def conda-create-path-unix [env-dir] { let env-path = [ ([$env-dir "bin"] | path join) ] - let new-path = ([$env-path $nu.path] | flatten | str collect (path-sep)) + let new-path = ([$env-path $nu.path] | flatten | str join (path-sep)) [[name, value]; [PATH $new-path]] } diff --git a/before_v0.60/virtual_environments/venv.nu b/before_v0.60/virtual_environments/venv.nu index ba1ab81ff..dad0d6d7f 100644 --- a/before_v0.60/virtual_environments/venv.nu +++ b/before_v0.60/virtual_environments/venv.nu @@ -1,7 +1,7 @@ def venv [venv-dir] { let venv-abs-dir = ($venv-dir | path expand) let venv-name = ($venv-abs-dir | path basename) - let old-path = ($nu.path | str collect (path-sep)) + let old-path = ($nu.path | str join (path-sep)) let new-path = (if (windows?) { (venv-path-windows $venv-abs-dir) } { (venv-path-unix $venv-abs-dir) }) let new-env = [[name, value]; [VENV_OLD_PATH $old-path] @@ -12,7 +12,7 @@ def venv [venv-dir] { def venv-path-unix [venv-dir] { let venv-path = ([$venv-dir "bin"] | path join) - let new-path = ($nu.path | prepend $venv-path | str collect (path-sep)) + let new-path = ($nu.path | prepend $venv-path | str join (path-sep)) [[name, value]; [PATH $new-path]] } @@ -20,7 +20,7 @@ def venv-path-windows [venv-dir] { # 1. Conda on Windows needs a few additional Path elements # 2. The path env var on Windows is called Path (not PATH) let venv-path = ([$venv-dir "Scripts"] | path join) - let new-path = ($nu.path | prepend $venv-path | str collect (path-sep)) + let new-path = ($nu.path | prepend $venv-path | str join (path-sep)) [[name, value]; [Path $new-path]] } From 5db8118f81e2c3b44f3998714ee2377bb368e84d Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Wed, 27 Mar 2024 09:27:09 -0300 Subject: [PATCH 2/9] :bug: change `$nu.scope.commands` for `scope commands` --- make_release/gen-js-ext.nu | 8 ++++---- modules/network/remoting/remoting.nu | 4 ++-- sourced/misc/cmd_stats.nu | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/make_release/gen-js-ext.nu b/make_release/gen-js-ext.nu index 1c0d6ef24..44c3836d0 100644 --- a/make_release/gen-js-ext.nu +++ b/make_release/gen-js-ext.nu @@ -1,5 +1,5 @@ def gen_keywords [] { - let cmds = ($nu.scope.commands + let cmds = (scope commands | where is_extern == false and is_custom == false and category !~ deprecated @@ -18,7 +18,7 @@ char nl char nl def gen_sub_keywords [] { - let sub_cmds = ($nu.scope.commands + let sub_cmds = (scope commands | where is_extern == false and is_custom == false and category !~ deprecated @@ -39,7 +39,7 @@ char nl def gen_keywords_alphabetically [] { let alphabet = [a b c d e f g h i j k l m n o p q r s t u v w x y z] - let cmds = ($nu.scope.commands + let cmds = (scope commands | where is_extern == false and is_custom == false and category !~ deprecated @@ -70,7 +70,7 @@ char nl def gen_sub_keywords_alphabetically [] { let alphabet = [a b c d e f g h i j k l m n o p q r s t u v w x y z] - let sub_cmds = ($nu.scope.commands + let sub_cmds = (scope commands | where is_extern == false and is_custom == false and category !~ deprecated diff --git a/modules/network/remoting/remoting.nu b/modules/network/remoting/remoting.nu index 7ef7733db..2aaba270a 100644 --- a/modules/network/remoting/remoting.nu +++ b/modules/network/remoting/remoting.nu @@ -22,7 +22,7 @@ def "nu-complete hosts" [] { } def "nu-complete scripts" [] { - $nu.scope.commands + scope commands |where is_custom |get -i command } @@ -62,7 +62,7 @@ export def "ssh script" [ ...args # arguments you wish to pass to the script in key=value format ] { let span = (metadata $script).span - if $script in ($nu.scope.commands|where is_custom|get command) { + if $script in (scope commands|where is_custom|get command) { let host = (hosts|where name == $hostname|get 0) let full_command = (build-string (view-source $script) '; ' $script ' ' ($args|str join ' ') '|to json -r') diff --git a/sourced/misc/cmd_stats.nu b/sourced/misc/cmd_stats.nu index 8968ed8e3..756093253 100644 --- a/sourced/misc/cmd_stats.nu +++ b/sourced/misc/cmd_stats.nu @@ -1,10 +1,10 @@ -let builtin = ($nu.scope.commands | where is_builtin == true | length) -let subcmd = ($nu.scope.commands | where is_sub == true | length) -let plugin = ($nu.scope.commands | where is_plugin == true | length) -let custom = ($nu.scope.commands | where is_custom == true | length) -let keyword = ($nu.scope.commands | where is_keyword == true | length) -let extern = ($nu.scope.commands | where is_extern == true | length) -let total = ($nu.scope.commands | length) +let builtin = (scope commands | where is_builtin == true | length) +let subcmd = (scope commands | where is_sub == true | length) +let plugin = (scope commands | where is_plugin == true | length) +let custom = (scope commands | where is_custom == true | length) +let keyword = (scope commands | where is_keyword == true | length) +let extern = (scope commands | where is_extern == true | length) +let total = (scope commands | length) [ [command_type count]; From 185b58ca44de621a943ce3f1a163cb877d592919 Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Wed, 27 Mar 2024 10:45:42 -0300 Subject: [PATCH 3/9] :bug: couple of fixes inside v0.60 folder --- before_v0.60/README.md | 8 +-- .../coloring/256_color_testpattern.nu | 61 ++++++++----------- before_v0.60/coloring/color_table.nu | 50 +++++++-------- before_v0.60/coloring/nu_index_bg.nu | 4 +- before_v0.60/coloring/nu_index_fg.nu | 6 +- before_v0.60/coloring/nu_index_fg2.nu | 4 +- before_v0.60/coloring/python_index_table.nu | 8 +-- before_v0.60/coloring/ref_table.nu | 4 +- before_v0.60/ls_mods/ls-wide-with-color.nu | 14 ++--- before_v0.60/ls_mods/ls-wide.nu | 16 ++--- before_v0.60/make_readme_table.nu | 2 +- before_v0.60/progress_bar/progress_bar.nu | 8 +-- .../progress_bar/progress_bar_no_back.nu | 2 +- before_v0.60/prompt/left_and_right_prompt.nu | 4 +- 14 files changed, 92 insertions(+), 99 deletions(-) diff --git a/before_v0.60/README.md b/before_v0.60/README.md index fc98b7671..09f32aa3e 100644 --- a/before_v0.60/README.md +++ b/before_v0.60/README.md @@ -13,17 +13,17 @@ You can run nushell scripts in a few different ways. | Category | File | Nu Version | Description | | ---------------- | --------------------------------------------------------- | ---------- | ----------- | -| coloring | [color_table.nu](./coloring/color_table.nu) | 0.26 | Produces a color table of ansi foregroupd and background colors. | +| coloring | [color_table.nu](./coloring/color_table.nu) | 0.91.1 | Produces a color table of ansi foregroupd and background colors. | | coloring | [color_tables.nu](./coloring/color_tables.nu) | 0.26 | Produces many tables with ansi foreground and background with styles | | coloring | [gradient.nu](./coloring/gradient.nu) | 0.26 | Draws a simple blue gradient. | | coloring | [nu_index_bg.nu](./coloring/nu_index_bg.nu) | 0.26 | Draws background colors using ansi escape sequences using an index | | coloring | [nu_index_fg.nu](./coloring/nu_index_fg.nu) | 0.26 | Draws foreground colors using ansi escape sequences using an index | | coloring | [nu_index_fg2.nu](./coloring/nu_index_fg2.nu) | 0.26 | Draws foreground colors using ansi escape sequences using an index a different way | -| coloring | [python_index_table.nu](./coloring/python_index_table.nu) | 0.26 | Draws foreground and background colors using ansi escape sequences using an index modeled after a python script | +| coloring | [python_index_table.nu](./coloring/python_index_table.nu) | 0.91.1 | Draws foreground and background colors using ansi escape sequences using an index modeled after a python script | | coloring | [ref_table.nu](./coloring/ref_table.nu) | 0.26 | A table with row and column headers indicating the colors | -| coloring | [sample.nu](./coloring/sample.nu) | 0.26 | An exhaustive list of colors and styles using ansi escape sequences | +| coloring | [sample.nu](./coloring/sample.nu) | 0.91.1 | An exhaustive list of colors and styles using ansi escape sequences | | coloring | [short_list.nu](./coloring/short_list.nu) | 0.26 | A small color sample that uses another nu script to define the colors by name. | -| not assigned yet | [fehbg.nu](./fehbg.nu) | >0.25.1 | Sets a random image from a directory as a wallpaper (Linux only) | +| not assigned yet | [fehbg.nu](./fehbg.nu) | >0.25.1 | Sets a random image from a directory as a wallpaper (Linux only) | | not assigned yet | [maintainer_time.nu](./maintainer_time.nu) | 0.26 | Looks up time by timezone for the nushell maintainers | | not assigned yet | [make_readme_table.nu](./make_readme_table.nu) | 0.26 | Generates this table. | | nu_101 | [demo.nu](./nu_101/demo.nu) | 0.26 | Creates a custom `ls` command | diff --git a/before_v0.60/coloring/256_color_testpattern.nu b/before_v0.60/coloring/256_color_testpattern.nu index e69e4945d..371596d1b 100644 --- a/before_v0.60/coloring/256_color_testpattern.nu +++ b/before_v0.60/coloring/256_color_testpattern.nu @@ -6,36 +6,29 @@ def contrast_colour [ colour:int ] { if $colour < 16 { if $colour == 0 { 15 - } { - 0 } - } { - # The gray colors - if $colour > 231 { - if $colour < 244 { - 15 - } { - 0 - } - } { - # The rest - let r = ($colour - 16) / 36 - let g = (($colour - 16) mod 36) / 6 - let b = ($colour - 16) mod 6 - - # if $g > 2 { - # 0 - # } { - # 15 - # } - - let luminance = ($r * 299) + ($g * 587) + ($b * 114) - if $luminance > 2500 { + } else { 0 - } { + } + # The gray colors + if $colour > 231 { + if $colour < 244 { 15 + } + } else { + 0 } - } + } else { + # The rest + let r = ($colour - 16) / 36 + let g = (($colour - 16) mod 36) / 6 + let b = ($colour - 16) mod 6 + + let luminance = ($r * 299) + ($g * 587) + ($b * 114) + if $luminance > 2500 { + 0 + } else { + 15 } } @@ -43,7 +36,7 @@ def print_colour [ colour:int ] { let contrast = (contrast_colour $colour) let bg_color = $"(ansi idx_bg)($colour)m" # Start block of colour let fg_color = $"(ansi idx_fg)($contrast)m" # In contrast, print number - let text = $"($colour | into string | str lpad -c ' ' -l 3)(ansi reset)" + let text = $"($colour | into string | fill --character ' ' --width 3)(ansi reset)" $bg_color + $fg_color + $text + " " } @@ -51,19 +44,19 @@ def print_run [start:int, amount:int] { for i in $start..<($start + $amount) { if $i < $printable_colours { print_colour $i - } { + } else { "" } } | append " " | str join } -def print_blocks [start:int, end:int, block-cols:int, block-rows:int, blocks-per-line:int] { - let block-length = ($block-cols * $block-rows) - let end = (($end - $start) / (($blocks-per-line) * $block-length)) +def print_blocks [start:int, end:int, block_cols:int, block_rows:int, blocks_per_line:int] { + let block_length = ($block_cols * $block_rows) + let end = (($end - $start) / (($blocks_per_line) * $block_length)) for i in 0..<$end { - for row in 0..<$block-rows { - for block in 0..<$blocks-per-line { - print_run ($start + $block * $block-length + $row * $block-cols + $i * $block-length * $blocks-per-line) $block-cols + for row in 0..<$block_rows { + for block in 0..<$blocks_per_line { + print_run ($start + $block * $block_length + $row * $block_cols + $i * $block_length * $blocks_per_line) $block_cols } | append (char nl) | str join | autoview } char nl | autoview diff --git a/before_v0.60/coloring/color_table.nu b/before_v0.60/coloring/color_table.nu index 7abd286da..7a02d95ca 100644 --- a/before_v0.60/coloring/color_table.nu +++ b/before_v0.60/coloring/color_table.nu @@ -1,23 +1,23 @@ def make_header [hi] { - if $hi == $true { - let ansi100m = ('100m' | str lpad -l 11 -c ' ') - let ansi101m = ('101m' | str lpad -l 9 -c ' ') - let ansi102m = ('102m' | str lpad -l 9 -c ' ') - let ansi103m = ('103m' | str lpad -l 9 -c ' ') - let ansi104m = ('104m' | str lpad -l 9 -c ' ') - let ansi105m = ('105m' | str lpad -l 9 -c ' ') - let ansi106m = ('106m' | str lpad -l 9 -c ' ') - let ansi107m = ('107m' | str lpad -l 9 -c ' ') + if $hi == true { + let ansi100m = ('100m' | fill --width 11 -c ' ') + let ansi101m = ('101m' | fill --width 9 -c ' ') + let ansi102m = ('102m' | fill --width 9 -c ' ') + let ansi103m = ('103m' | fill --width 9 -c ' ') + let ansi104m = ('104m' | fill --width 9 -c ' ') + let ansi105m = ('105m' | fill --width 9 -c ' ') + let ansi106m = ('106m' | fill --width 9 -c ' ') + let ansi107m = ('107m' | fill --width 9 -c ' ') $"(char newline)($ansi100m)($ansi101m)($ansi102m)($ansi103m)($ansi104m)($ansi105m)($ansi106m)($ansi107m)(char newline)" - } { - let ansi40m = ('40m' | str lpad -l 10 -c ' ') - let ansi41m = ('41m' | str lpad -l 8 -c ' ') - let ansi42m = ('42m' | str lpad -l 8 -c ' ') - let ansi43m = ('43m' | str lpad -l 8 -c ' ') - let ansi44m = ('44m' | str lpad -l 8 -c ' ') - let ansi45m = ('45m' | str lpad -l 8 -c ' ') - let ansi46m = ('46m' | str lpad -l 8 -c ' ') - let ansi47m = ('47m' | str lpad -l 8 -c ' ') + } else { + let ansi40m = ('40m' | fill --width 10 -c ' ') + let ansi41m = ('41m' | fill --width 8 -c ' ') + let ansi42m = ('42m' | fill --width 8 -c ' ') + let ansi43m = ('43m' | fill --width 8 -c ' ') + let ansi44m = ('44m' | fill --width 8 -c ' ') + let ansi45m = ('45m' | fill --width 8 -c ' ') + let ansi46m = ('46m' | fill --width 8 -c ' ') + let ansi47m = ('47m' | fill --width 8 -c ' ') $"(char newline)($ansi40m)($ansi41m)($ansi42m)($ansi43m)($ansi44m)($ansi45m)($ansi46m)($ansi47m)(char newline)" } } @@ -36,15 +36,15 @@ def mk_header [color_range:range] { let ansi_color = $"($color)m" if $color == $min_rng { if $min_rng == 100 { - ($ansi_color | str lpad -l $hi_start_pad -c ' ') - } { - ($ansi_color | str lpad -l $lo_start_pad -c ' ') + ($ansi_color | fill --width $hi_start_pad -c ' ') + } else { + ($ansi_color | fill --width $lo_start_pad -c ' ') } - } { + } else { if $min_rng >= 100 { - ($ansi_color | str lpad -l $hi_regular_pad -c ' ') - } { - ($ansi_color | str lpad -l $lo_regular_pad -c ' ') + ($ansi_color | fill --width $hi_regular_pad -c ' ') + } else { + ($ansi_color | fill --width $lo_regular_pad -c ' ') } } } | str join diff --git a/before_v0.60/coloring/nu_index_bg.nu b/before_v0.60/coloring/nu_index_bg.nu index c805e8850..a78bc30aa 100644 --- a/before_v0.60/coloring/nu_index_bg.nu +++ b/before_v0.60/coloring/nu_index_bg.nu @@ -3,10 +3,10 @@ def show_index_colors [] { echo 1..256 | each { |idx| let cr = ($"($idx) % 16" | math eval) let color = $"(ansi -e $prefix)($idx)m" - let padded_number = ($"($idx)" | str lpad -l 3 -c '0') + let padded_number = ($"($idx)" | fill --width 3 -c '0') if $cr == 0 { $"($color)($padded_number) (ansi -e 0m)(char newline)" - } { + } else { $"($color)($padded_number) (ansi -e 0m)" } } | str join diff --git a/before_v0.60/coloring/nu_index_fg.nu b/before_v0.60/coloring/nu_index_fg.nu index a1a78a0f5..291e2836a 100644 --- a/before_v0.60/coloring/nu_index_fg.nu +++ b/before_v0.60/coloring/nu_index_fg.nu @@ -3,9 +3,9 @@ def show_index_colors [] { echo 1..256 | each { |fg| let cr = ($"($fg) % 16" | math eval) if $cr == 0 { - $"(ansi -e $prefix)($fg)m($fg | into string | str lpad -l 3 -c '0') (char newline)" - } { - $"(ansi -e $prefix)($fg)m($fg | into string | str lpad -l 3 -c '0') " + $"(ansi -e $prefix)($fg)m($fg | into string | fill --width 3 -c '0') (char newline)" + } else { + $"(ansi -e $prefix)($fg)m($fg | into string | fill --width 3 -c '0') " } } | str join } diff --git a/before_v0.60/coloring/nu_index_fg2.nu b/before_v0.60/coloring/nu_index_fg2.nu index 88d9c4619..b35e940f0 100644 --- a/before_v0.60/coloring/nu_index_fg2.nu +++ b/before_v0.60/coloring/nu_index_fg2.nu @@ -6,11 +6,11 @@ def show_index_colors [] { echo 1..256 | each { |idx| let cr = ($"($idx) % 16" | math eval) let color = ($"(ansi -e $prefix)($idx)m") - let padded_number = ($"($idx)" | str lpad -l 3 -c '0') + let padded_number = ($"($idx)" | fill --width 3 -c '0') if $cr == 0 { $"($color)($padded_number) (char newline)" - } { + } else { $"($color)($padded_number) " } } | str join diff --git a/before_v0.60/coloring/python_index_table.nu b/before_v0.60/coloring/python_index_table.nu index c1869a69a..a05795cd2 100644 --- a/before_v0.60/coloring/python_index_table.nu +++ b/before_v0.60/coloring/python_index_table.nu @@ -11,8 +11,8 @@ echo 0..16 | each { |col| let row = (echo 0..16 | each { |row| let code = ($col * 16 + $row) if $code < 256 { - $"(ansi -e '38;5;')($code | into string)m($code | into string | str lpad -l 4 -c ' ')(ansi reset)" - } {} # Do nothing in the else + $"(ansi -e '38;5;')($code | into string)m($code | into string | fill --width 4 -c ' ')(ansi reset)" + } else {} # Do nothing in the else } | str join) $"($row)(char newline)" } | str join @@ -22,8 +22,8 @@ echo 0..16 | each { |col| let row = (echo 0..16 | each { |row| let code = ($col * 16 + $row) if $code < 256 { - $"(ansi -e '48;5;')($code | into string)m($code | into string | str lpad -l 4 -c ' ')(ansi reset)" - } {} # do nothing in the else + $"(ansi -e '48;5;')($code | into string)m($code | into string | fill --width 4 -c ' ')(ansi reset)" + } else {} # do nothing in the else } | str join) $"($row)(char newline)" } | str join diff --git a/before_v0.60/coloring/ref_table.nu b/before_v0.60/coloring/ref_table.nu index 55d6ba420..8e3725974 100644 --- a/before_v0.60/coloring/ref_table.nu +++ b/before_v0.60/coloring/ref_table.nu @@ -4,7 +4,7 @@ # This prints the column headers let nl = (char newline) let plus = $"($nl) + " -let cols = (seq 0 35 | each { |col| $"($col)" | str lpad -c ' ' -l 3 } | str join) +let cols = (seq 0 35 | each { |col| $"($col)" | fill -c ' ' --width 3 } | str join) $"($plus)($cols)" let ansi_bg = (ansi -e '48;5;') @@ -21,7 +21,7 @@ $"($row_header)($row_data)($nl)($nl)" # This is the meat of the script that prints the little squares of color seq 0 6 | each { |row_idx| let r = ($"($row_idx) * 36 + 16" | math eval) - let row_header = (echo $r | into string -d 0 | str lpad -c ' ' -l 4) + let row_header = (echo $r | into string -d 0 | fill -c ' ' --width 4) let row_data = (seq 0 35 | each { |row| let val = ($"($r + $row)" | math eval | into string -d 0) $"($ansi_bg)($val)m (ansi -e 'm') " diff --git a/before_v0.60/ls_mods/ls-wide-with-color.nu b/before_v0.60/ls_mods/ls-wide-with-color.nu index f3dcf7890..c76a41ff8 100644 --- a/before_v0.60/ls_mods/ls-wide-with-color.nu +++ b/before_v0.60/ls_mods/ls-wide-with-color.nu @@ -29,7 +29,7 @@ def ls-wide2 [ ] { let is_dir_empty = ($dir | empty?) let is_columns_empty = ($columns | empty?) - let ls_data = (if $is_dir_empty { ls } { ls $dir }) + let ls_data = (if $is_dir_empty { ls } else { ls $dir }) let ansi_size = 9 # \x1b[36m + string + \x1b[0m, ~9 characters are added to each string for coloring let max_fname_size = ((echo $ls_data | get name | into string | str length | math max) + $ansi_size) let max_fsize_size = (echo $ls_data | get size | into string | str length | math max) @@ -39,15 +39,15 @@ def ls-wide2 [ # log (build-string $clr_file ' ' $max_fname_size) let clr_size = (echo $file.item.size | into string) # log (build-string $clr_size ' ' $max_fsize_size) - $"($clr_file | str rpad -c ' ' -l $max_fname_size) ($clr_size | str lpad -c ' ' -l $max_fsize_size) " | autoview + $"($clr_file | fill --alignment r -c ' ' --width $max_fname_size) ($clr_size | fill -c ' ' --width $max_fsize_size) " | autoview if $is_columns_empty { if ($file.index + 1) mod 3 == 0 { echo (char newline) | autoview - } {} - } { + } else {} + } else { if ($file.index + 1) mod $columns == 0 { echo (char newline) | autoview - } {} + } else {} } } | str join } @@ -61,12 +61,12 @@ def colorize [thing:any] { # build-string (ansi -e '36m') $thing (ansi -e '0m') $"(fg_cyan)($thing)(relet)" # build-string 'e[36m' $thing 'e[0m' - } { + } else { if $ext == "nu" { # build-string (ansi -e '95m') $thing (ansi -e '0m') $"(fg_light_magenta)($thing)(relet)" # build-string 'e[95m' $thing 'e[0m' - } { + } else { # build-string (ansi -e '92m') $thing (ansi -e '0m') $"(fg_light_green)($thing)(relet)" # build-string 'e[92m' $thing 'e[0m' diff --git a/before_v0.60/ls_mods/ls-wide.nu b/before_v0.60/ls_mods/ls-wide.nu index 304f16e3a..0bd684bc7 100644 --- a/before_v0.60/ls_mods/ls-wide.nu +++ b/before_v0.60/ls_mods/ls-wide.nu @@ -10,13 +10,13 @@ def ls-wide [ if $is_path_empty { if $is_columns_empty { run_ls "." $columns_default - } { + } else { run_ls "." $columns } - } { + } else { if $is_columns_empty { run_ls $path $columns_default - } { + } else { run_ls $path $columns } } @@ -30,18 +30,18 @@ def run_ls [ let max_fsize_size = (ls $path | get size | into string | str length | math max) ls $path | each -n { |file| - let the_file = ($file.item.name | into string | str rpad -c ' ' -l $max_fname_size) - let the_size = ($file.item.size | into string | str lpad -c ' ' -l $max_fsize_size) + let the_file = ($file.item.name | into string | fill --alignment r -c ' ' --width $max_fname_size) + let the_size = ($file.item.size | into string | fill --alignment l -c ' ' --width $max_fsize_size) $"($the_file) ($the_size) " | autoview if $is_columns_empty { if ($file.index + 1) mod 3 == 0 { echo (char newline) | autoview - } {} - } { + } else {} + } else { if ($file.index + 1) mod $columns == 0 { echo (char newline) | autoview - } {} + } else {} } } | str join } diff --git a/before_v0.60/make_readme_table.nu b/before_v0.60/make_readme_table.nu index 8f713bc32..7cd3fe91c 100644 --- a/before_v0.60/make_readme_table.nu +++ b/before_v0.60/make_readme_table.nu @@ -17,7 +17,7 @@ let nu_table = ($nu_files | let cat = ($it.File | path dirname) if $cat == "" { "not assigned yet" - } { + } else { $cat } } | where Category !~ ".git" | select Category File | sort-by Category) diff --git a/before_v0.60/progress_bar/progress_bar.nu b/before_v0.60/progress_bar/progress_bar.nu index c5f9b5aa3..2ba6c0c65 100644 --- a/before_v0.60/progress_bar/progress_bar.nu +++ b/before_v0.60/progress_bar/progress_bar.nu @@ -24,24 +24,24 @@ ansi cursor_off # Move cursor all the way to the left $"(ansi -e '1000D')" | autoview # Draw the background for the progress bar -$bg_fill | str lpad -c $bg_fill -l $pb_len +$bg_fill | fill -c $bg_fill -l $pb_len echo 1..<$pb_len | each { |cur_progress| # This is kind of a hack because it's not incrementally drawing a new box # It's drawing the entire row every time with a different padding amount - # echo $blocks.7 | str lpad -c $blocks.7 -l $it | autoview + # echo $blocks.7 | fill -c $blocks.7 -l $it | autoview echo 0..7 | each { |tick| let cur_idx = ($tick mod 8) let cur_block = (echo $blocks | nth $cur_idx) - $"($cur_block | str lpad -c $blocks.7 -l $cur_progress)" | autoview + $"($cur_block | fill -c $blocks.7 -l $cur_progress)" | autoview $"(ansi -e '1000D')" | autoview sleep 5ms } $"(ansi -e '1000D')" | autoview } # Fill in the last background block -$"($blocks.7 | str lpad -c $blocks.7 -l $pb_len)" | autoview +$"($blocks.7 | fill -c $blocks.7 -l $pb_len)" | autoview char newline "Done" ansi cursor_on diff --git a/before_v0.60/progress_bar/progress_bar_no_back.nu b/before_v0.60/progress_bar/progress_bar_no_back.nu index 43f1ff922..5a0c2abc3 100644 --- a/before_v0.60/progress_bar/progress_bar_no_back.nu +++ b/before_v0.60/progress_bar/progress_bar_no_back.nu @@ -5,7 +5,7 @@ echo 1..<$pb_size | each { |cur_size| echo 0..7 | each { |tick| let idx = ($tick mod 8) let cur_block = (echo $blocks | nth $idx) - $"($cur_block | str lpad -c $blocks.7 -l $cur_size)" | autoview + $"($cur_block | fill -c $blocks.7 -l $cur_size)" | autoview $"(ansi -e '1000D')" | autoview sleep 5ms } diff --git a/before_v0.60/prompt/left_and_right_prompt.nu b/before_v0.60/prompt/left_and_right_prompt.nu index caddfe67b..23a7b8f48 100644 --- a/before_v0.60/prompt/left_and_right_prompt.nu +++ b/before_v0.60/prompt/left_and_right_prompt.nu @@ -43,7 +43,7 @@ def construct_prompt [] { let calculated_right_len = ($term_width - $left_len + ($right_colored_len - $right_len)) # finally, let's make the prompt - let the_prompt = $"($left_colored)($right_colored | str lpad -c ' ' -l $calculated_right_len)(char newline)($decorator) " + let the_prompt = $"($left_colored)($right_colored | fill -c ' ' -l $calculated_right_len)(char newline)($decorator) " # let's update the title bar now echo $title_bar @@ -65,7 +65,7 @@ def home_abbrev [] { let lin-home = ($nu.home-dir | into string | str find-replace -a '\\' '/' | str downcase) let lin-pwd = (pwd | into string | str find-replace -a '\\' '/' | str downcase) $lin-pwd | str find-replace $lin-home '~' - } { + } else { pwd } } From afb35e765c82aba16515f6ee224704bb899dcb82 Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Wed, 27 Mar 2024 10:53:19 -0300 Subject: [PATCH 4/9] :bug: `$true` for `true and same with `false` --- before_v0.60/coloring/color_table.nu | 4 ++-- before_v0.60/fun/life.nu | 4 ++-- before_v0.60/language/playground/lib.nu | 4 ++-- before_v0.60/nu_101/nothing.nu | 8 ++++---- before_v0.60/weather/get-weather.nu | 8 ++++---- before_v0.60/weather/timed_weather_run.nu | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/before_v0.60/coloring/color_table.nu b/before_v0.60/coloring/color_table.nu index 7a02d95ca..48c243fd7 100644 --- a/before_v0.60/coloring/color_table.nu +++ b/before_v0.60/coloring/color_table.nu @@ -69,14 +69,14 @@ def create_color_tables [fg_range:range bg_range:range] { } def color_table [] { - # make_header $false + # make_header false mk_header 40..47 create_color_tables 30..37 40..47 # put a line between tables char newline - #make_header $true + #make_header true mk_header 100..107 create_color_tables 90..97 100..107 } diff --git a/before_v0.60/fun/life.nu b/before_v0.60/fun/life.nu index 1651daa9a..865e72bae 100644 --- a/before_v0.60/fun/life.nu +++ b/before_v0.60/fun/life.nu @@ -22,9 +22,9 @@ def alive [x-pos: int, y-pos: int, $grid] { let $curr = ($data | nth ($x-pos + $y-pos * $width)) if ($total == 3) or ($total == 2 and $curr) { - $true + true } { - $false + false } } diff --git a/before_v0.60/language/playground/lib.nu b/before_v0.60/language/playground/lib.nu index 4dc456537..e2a86a6f5 100644 --- a/before_v0.60/language/playground/lib.nu +++ b/before_v0.60/language/playground/lib.nu @@ -23,7 +23,7 @@ def play [ let title = $topic; let is_tag_empty = ($tag | empty?); - let should_run_all = ($nu.env | default RUN_ALL $false | get RUN_ALL); + let should_run_all = ($nu.env | default RUN_ALL false | get RUN_ALL); if $is_tag_empty { do $block @@ -45,7 +45,7 @@ def expect [ } | all? $it) and (($actual | get | length) == ($to-be | get | length)); - let line = (if $true == $are_equal { + let line = (if true == $are_equal { $"(ansi green)ok(ansi reset)(char newline)" } { $"(ansi red)failed(ansi reset)(char newline)" diff --git a/before_v0.60/nu_101/nothing.nu b/before_v0.60/nu_101/nothing.nu index 21b353602..ae1cb88d3 100644 --- a/before_v0.60/nu_101/nothing.nu +++ b/before_v0.60/nu_101/nothing.nu @@ -4,9 +4,9 @@ def nada [ --flat(-f) ] { if $flat == $nothing { - echo $true + echo true } { - echo $false + echo false } } @@ -17,8 +17,8 @@ def nada2 [ let flat = ($flat | empty?) if $flat { - echo $true + echo true } { - echo $false + echo false } } \ No newline at end of file diff --git a/before_v0.60/weather/get-weather.nu b/before_v0.60/weather/get-weather.nu index f0ff5ebf9..a36c14084 100644 --- a/before_v0.60/weather/get-weather.nu +++ b/before_v0.60/weather/get-weather.nu @@ -114,10 +114,10 @@ def get_weather [ let is_loc_empty = ($locIdx | empty?) let is_units_empty = ($units | empty?) - let no_loc_no_unit = ($is_loc_empty == $true and $is_units_empty == $true) - let no_loc_with_unit = ($is_loc_empty == $true and $is_units_empty == $false) - let with_loc_no_unit = ($is_loc_empty == $false and $is_units_empty == $true) - let with_loc_with_unit = ($is_loc_empty == $false and $is_units_empty == $false) + let no_loc_no_unit = ($is_loc_empty == true and $is_units_empty == true) + let no_loc_with_unit = ($is_loc_empty == true and $is_units_empty == false) + let with_loc_no_unit = ($is_loc_empty == false and $is_units_empty == true) + let with_loc_with_unit = ($is_loc_empty == false and $is_units_empty == false) # This is a cautionary tale, the commented out code below is returning # and autoview is viewing the data, so no structured data is being returned. diff --git a/before_v0.60/weather/timed_weather_run.nu b/before_v0.60/weather/timed_weather_run.nu index 50f8b73ec..79a490625 100644 --- a/before_v0.60/weather/timed_weather_run.nu +++ b/before_v0.60/weather/timed_weather_run.nu @@ -23,7 +23,7 @@ def timed_weather_run [ # generate temp file name let weather_runtime_file = (($nu.env.TMP) | path join weather_runtime_file.json) # does the temp file already exist, meaning we've written it previously - if ($weather_runtime_file | path exists) == $true { + if ($weather_runtime_file | path exists) == true { # $"Weather path exists [($weather_runtime_file)](char nl)" # open the file and get the last weather data and run time out of it let last_runtime_data = (open $weather_runtime_file) From 95d2e51585b38e2794e5b6c8c6ef214c0c75c3f9 Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Sun, 21 Apr 2024 12:12:01 -0300 Subject: [PATCH 5/9] :bug: fix for loops into `each` blocks --- make_release/gen-js-ext.nu | 13 +++++++------ sourced/misc/cmd_stats.nu | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/make_release/gen-js-ext.nu b/make_release/gen-js-ext.nu index 44c3836d0..eed65926e 100644 --- a/make_release/gen-js-ext.nu +++ b/make_release/gen-js-ext.nu @@ -27,7 +27,7 @@ def gen_sub_keywords [] { let preamble = '\\b(' let postamble = ')\\b' - let cmds = (for x in $sub_cmds { + let cmds = ( $sub_cmds | each {|$x| let parts = ($x | split row ' ') $'($parts.0)\\s($parts.1)' } | str join '|') @@ -49,9 +49,9 @@ def gen_keywords_alphabetically [] { let preamble = '\\b(' let postamble = ')\\b' - - for alpha in $alphabet { - let letter_cmds = (for cmd in $cmds { + $alphabet | each { |$alpha| + let letter_cmds = ( + $cmds | each {|$cmd| if ($cmd | str starts-with $alpha) { $cmd } else { @@ -81,8 +81,9 @@ def gen_sub_keywords_alphabetically [] { let postamble = ')\\b' - for alpha in $alphabet { - let letter_cmds = (for cmd in $sub_cmds { + $alphabet | each { |$alpha| + let letter_cmds = ( + $sub_cmds | each {|$cmd| if ($cmd | str starts-with $alpha) { let parts = ($cmd | split row ' ') $'($parts.0)\\s($parts.1)' diff --git a/sourced/misc/cmd_stats.nu b/sourced/misc/cmd_stats.nu index 756093253..deecb4366 100644 --- a/sourced/misc/cmd_stats.nu +++ b/sourced/misc/cmd_stats.nu @@ -15,4 +15,4 @@ let total = (scope commands | length) [keyword $keyword] [extern $extern] [total_cmds $total] -] \ No newline at end of file +] From 2a826fbf0136b8f09bb4656b208dabe93a83d029 Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Sun, 28 Apr 2024 08:48:24 -0300 Subject: [PATCH 6/9] Revert ":bug: `$true` for `true and same with `false`" This reverts commit afb35e765c82aba16515f6ee224704bb899dcb82. --- before_v0.60/coloring/color_table.nu | 4 ++-- before_v0.60/fun/life.nu | 4 ++-- before_v0.60/language/playground/lib.nu | 4 ++-- before_v0.60/nu_101/nothing.nu | 8 ++++---- before_v0.60/weather/get-weather.nu | 8 ++++---- before_v0.60/weather/timed_weather_run.nu | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/before_v0.60/coloring/color_table.nu b/before_v0.60/coloring/color_table.nu index 48c243fd7..7a02d95ca 100644 --- a/before_v0.60/coloring/color_table.nu +++ b/before_v0.60/coloring/color_table.nu @@ -69,14 +69,14 @@ def create_color_tables [fg_range:range bg_range:range] { } def color_table [] { - # make_header false + # make_header $false mk_header 40..47 create_color_tables 30..37 40..47 # put a line between tables char newline - #make_header true + #make_header $true mk_header 100..107 create_color_tables 90..97 100..107 } diff --git a/before_v0.60/fun/life.nu b/before_v0.60/fun/life.nu index 865e72bae..1651daa9a 100644 --- a/before_v0.60/fun/life.nu +++ b/before_v0.60/fun/life.nu @@ -22,9 +22,9 @@ def alive [x-pos: int, y-pos: int, $grid] { let $curr = ($data | nth ($x-pos + $y-pos * $width)) if ($total == 3) or ($total == 2 and $curr) { - true + $true } { - false + $false } } diff --git a/before_v0.60/language/playground/lib.nu b/before_v0.60/language/playground/lib.nu index e2a86a6f5..4dc456537 100644 --- a/before_v0.60/language/playground/lib.nu +++ b/before_v0.60/language/playground/lib.nu @@ -23,7 +23,7 @@ def play [ let title = $topic; let is_tag_empty = ($tag | empty?); - let should_run_all = ($nu.env | default RUN_ALL false | get RUN_ALL); + let should_run_all = ($nu.env | default RUN_ALL $false | get RUN_ALL); if $is_tag_empty { do $block @@ -45,7 +45,7 @@ def expect [ } | all? $it) and (($actual | get | length) == ($to-be | get | length)); - let line = (if true == $are_equal { + let line = (if $true == $are_equal { $"(ansi green)ok(ansi reset)(char newline)" } { $"(ansi red)failed(ansi reset)(char newline)" diff --git a/before_v0.60/nu_101/nothing.nu b/before_v0.60/nu_101/nothing.nu index ae1cb88d3..21b353602 100644 --- a/before_v0.60/nu_101/nothing.nu +++ b/before_v0.60/nu_101/nothing.nu @@ -4,9 +4,9 @@ def nada [ --flat(-f) ] { if $flat == $nothing { - echo true + echo $true } { - echo false + echo $false } } @@ -17,8 +17,8 @@ def nada2 [ let flat = ($flat | empty?) if $flat { - echo true + echo $true } { - echo false + echo $false } } \ No newline at end of file diff --git a/before_v0.60/weather/get-weather.nu b/before_v0.60/weather/get-weather.nu index a36c14084..f0ff5ebf9 100644 --- a/before_v0.60/weather/get-weather.nu +++ b/before_v0.60/weather/get-weather.nu @@ -114,10 +114,10 @@ def get_weather [ let is_loc_empty = ($locIdx | empty?) let is_units_empty = ($units | empty?) - let no_loc_no_unit = ($is_loc_empty == true and $is_units_empty == true) - let no_loc_with_unit = ($is_loc_empty == true and $is_units_empty == false) - let with_loc_no_unit = ($is_loc_empty == false and $is_units_empty == true) - let with_loc_with_unit = ($is_loc_empty == false and $is_units_empty == false) + let no_loc_no_unit = ($is_loc_empty == $true and $is_units_empty == $true) + let no_loc_with_unit = ($is_loc_empty == $true and $is_units_empty == $false) + let with_loc_no_unit = ($is_loc_empty == $false and $is_units_empty == $true) + let with_loc_with_unit = ($is_loc_empty == $false and $is_units_empty == $false) # This is a cautionary tale, the commented out code below is returning # and autoview is viewing the data, so no structured data is being returned. diff --git a/before_v0.60/weather/timed_weather_run.nu b/before_v0.60/weather/timed_weather_run.nu index 79a490625..50f8b73ec 100644 --- a/before_v0.60/weather/timed_weather_run.nu +++ b/before_v0.60/weather/timed_weather_run.nu @@ -23,7 +23,7 @@ def timed_weather_run [ # generate temp file name let weather_runtime_file = (($nu.env.TMP) | path join weather_runtime_file.json) # does the temp file already exist, meaning we've written it previously - if ($weather_runtime_file | path exists) == true { + if ($weather_runtime_file | path exists) == $true { # $"Weather path exists [($weather_runtime_file)](char nl)" # open the file and get the last weather data and run time out of it let last_runtime_data = (open $weather_runtime_file) From 0d939e5eefc0ed59aa3654b8fa7419c9c3e5e855 Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Sun, 28 Apr 2024 08:48:56 -0300 Subject: [PATCH 7/9] Revert ":bug: couple of fixes inside v0.60 folder" This reverts commit 185b58ca44de621a943ce3f1a163cb877d592919. --- before_v0.60/README.md | 8 +-- .../coloring/256_color_testpattern.nu | 61 +++++++++++-------- before_v0.60/coloring/color_table.nu | 50 +++++++-------- before_v0.60/coloring/nu_index_bg.nu | 4 +- before_v0.60/coloring/nu_index_fg.nu | 6 +- before_v0.60/coloring/nu_index_fg2.nu | 4 +- before_v0.60/coloring/python_index_table.nu | 8 +-- before_v0.60/coloring/ref_table.nu | 4 +- before_v0.60/ls_mods/ls-wide-with-color.nu | 14 ++--- before_v0.60/ls_mods/ls-wide.nu | 16 ++--- before_v0.60/make_readme_table.nu | 2 +- before_v0.60/progress_bar/progress_bar.nu | 8 +-- .../progress_bar/progress_bar_no_back.nu | 2 +- before_v0.60/prompt/left_and_right_prompt.nu | 4 +- 14 files changed, 99 insertions(+), 92 deletions(-) diff --git a/before_v0.60/README.md b/before_v0.60/README.md index 09f32aa3e..fc98b7671 100644 --- a/before_v0.60/README.md +++ b/before_v0.60/README.md @@ -13,17 +13,17 @@ You can run nushell scripts in a few different ways. | Category | File | Nu Version | Description | | ---------------- | --------------------------------------------------------- | ---------- | ----------- | -| coloring | [color_table.nu](./coloring/color_table.nu) | 0.91.1 | Produces a color table of ansi foregroupd and background colors. | +| coloring | [color_table.nu](./coloring/color_table.nu) | 0.26 | Produces a color table of ansi foregroupd and background colors. | | coloring | [color_tables.nu](./coloring/color_tables.nu) | 0.26 | Produces many tables with ansi foreground and background with styles | | coloring | [gradient.nu](./coloring/gradient.nu) | 0.26 | Draws a simple blue gradient. | | coloring | [nu_index_bg.nu](./coloring/nu_index_bg.nu) | 0.26 | Draws background colors using ansi escape sequences using an index | | coloring | [nu_index_fg.nu](./coloring/nu_index_fg.nu) | 0.26 | Draws foreground colors using ansi escape sequences using an index | | coloring | [nu_index_fg2.nu](./coloring/nu_index_fg2.nu) | 0.26 | Draws foreground colors using ansi escape sequences using an index a different way | -| coloring | [python_index_table.nu](./coloring/python_index_table.nu) | 0.91.1 | Draws foreground and background colors using ansi escape sequences using an index modeled after a python script | +| coloring | [python_index_table.nu](./coloring/python_index_table.nu) | 0.26 | Draws foreground and background colors using ansi escape sequences using an index modeled after a python script | | coloring | [ref_table.nu](./coloring/ref_table.nu) | 0.26 | A table with row and column headers indicating the colors | -| coloring | [sample.nu](./coloring/sample.nu) | 0.91.1 | An exhaustive list of colors and styles using ansi escape sequences | +| coloring | [sample.nu](./coloring/sample.nu) | 0.26 | An exhaustive list of colors and styles using ansi escape sequences | | coloring | [short_list.nu](./coloring/short_list.nu) | 0.26 | A small color sample that uses another nu script to define the colors by name. | -| not assigned yet | [fehbg.nu](./fehbg.nu) | >0.25.1 | Sets a random image from a directory as a wallpaper (Linux only) | +| not assigned yet | [fehbg.nu](./fehbg.nu) | >0.25.1 | Sets a random image from a directory as a wallpaper (Linux only) | | not assigned yet | [maintainer_time.nu](./maintainer_time.nu) | 0.26 | Looks up time by timezone for the nushell maintainers | | not assigned yet | [make_readme_table.nu](./make_readme_table.nu) | 0.26 | Generates this table. | | nu_101 | [demo.nu](./nu_101/demo.nu) | 0.26 | Creates a custom `ls` command | diff --git a/before_v0.60/coloring/256_color_testpattern.nu b/before_v0.60/coloring/256_color_testpattern.nu index 371596d1b..e69e4945d 100644 --- a/before_v0.60/coloring/256_color_testpattern.nu +++ b/before_v0.60/coloring/256_color_testpattern.nu @@ -6,29 +6,36 @@ def contrast_colour [ colour:int ] { if $colour < 16 { if $colour == 0 { 15 - } - } else { + } { 0 } - # The gray colors - if $colour > 231 { - if $colour < 244 { - 15 - } - } else { + } { + # The gray colors + if $colour > 231 { + if $colour < 244 { + 15 + } { + 0 + } + } { + # The rest + let r = ($colour - 16) / 36 + let g = (($colour - 16) mod 36) / 6 + let b = ($colour - 16) mod 6 + + # if $g > 2 { + # 0 + # } { + # 15 + # } + + let luminance = ($r * 299) + ($g * 587) + ($b * 114) + if $luminance > 2500 { 0 + } { + 15 } - } else { - # The rest - let r = ($colour - 16) / 36 - let g = (($colour - 16) mod 36) / 6 - let b = ($colour - 16) mod 6 - - let luminance = ($r * 299) + ($g * 587) + ($b * 114) - if $luminance > 2500 { - 0 - } else { - 15 + } } } @@ -36,7 +43,7 @@ def print_colour [ colour:int ] { let contrast = (contrast_colour $colour) let bg_color = $"(ansi idx_bg)($colour)m" # Start block of colour let fg_color = $"(ansi idx_fg)($contrast)m" # In contrast, print number - let text = $"($colour | into string | fill --character ' ' --width 3)(ansi reset)" + let text = $"($colour | into string | str lpad -c ' ' -l 3)(ansi reset)" $bg_color + $fg_color + $text + " " } @@ -44,19 +51,19 @@ def print_run [start:int, amount:int] { for i in $start..<($start + $amount) { if $i < $printable_colours { print_colour $i - } else { + } { "" } } | append " " | str join } -def print_blocks [start:int, end:int, block_cols:int, block_rows:int, blocks_per_line:int] { - let block_length = ($block_cols * $block_rows) - let end = (($end - $start) / (($blocks_per_line) * $block_length)) +def print_blocks [start:int, end:int, block-cols:int, block-rows:int, blocks-per-line:int] { + let block-length = ($block-cols * $block-rows) + let end = (($end - $start) / (($blocks-per-line) * $block-length)) for i in 0..<$end { - for row in 0..<$block_rows { - for block in 0..<$blocks_per_line { - print_run ($start + $block * $block_length + $row * $block_cols + $i * $block_length * $blocks_per_line) $block_cols + for row in 0..<$block-rows { + for block in 0..<$blocks-per-line { + print_run ($start + $block * $block-length + $row * $block-cols + $i * $block-length * $blocks-per-line) $block-cols } | append (char nl) | str join | autoview } char nl | autoview diff --git a/before_v0.60/coloring/color_table.nu b/before_v0.60/coloring/color_table.nu index 7a02d95ca..7abd286da 100644 --- a/before_v0.60/coloring/color_table.nu +++ b/before_v0.60/coloring/color_table.nu @@ -1,23 +1,23 @@ def make_header [hi] { - if $hi == true { - let ansi100m = ('100m' | fill --width 11 -c ' ') - let ansi101m = ('101m' | fill --width 9 -c ' ') - let ansi102m = ('102m' | fill --width 9 -c ' ') - let ansi103m = ('103m' | fill --width 9 -c ' ') - let ansi104m = ('104m' | fill --width 9 -c ' ') - let ansi105m = ('105m' | fill --width 9 -c ' ') - let ansi106m = ('106m' | fill --width 9 -c ' ') - let ansi107m = ('107m' | fill --width 9 -c ' ') + if $hi == $true { + let ansi100m = ('100m' | str lpad -l 11 -c ' ') + let ansi101m = ('101m' | str lpad -l 9 -c ' ') + let ansi102m = ('102m' | str lpad -l 9 -c ' ') + let ansi103m = ('103m' | str lpad -l 9 -c ' ') + let ansi104m = ('104m' | str lpad -l 9 -c ' ') + let ansi105m = ('105m' | str lpad -l 9 -c ' ') + let ansi106m = ('106m' | str lpad -l 9 -c ' ') + let ansi107m = ('107m' | str lpad -l 9 -c ' ') $"(char newline)($ansi100m)($ansi101m)($ansi102m)($ansi103m)($ansi104m)($ansi105m)($ansi106m)($ansi107m)(char newline)" - } else { - let ansi40m = ('40m' | fill --width 10 -c ' ') - let ansi41m = ('41m' | fill --width 8 -c ' ') - let ansi42m = ('42m' | fill --width 8 -c ' ') - let ansi43m = ('43m' | fill --width 8 -c ' ') - let ansi44m = ('44m' | fill --width 8 -c ' ') - let ansi45m = ('45m' | fill --width 8 -c ' ') - let ansi46m = ('46m' | fill --width 8 -c ' ') - let ansi47m = ('47m' | fill --width 8 -c ' ') + } { + let ansi40m = ('40m' | str lpad -l 10 -c ' ') + let ansi41m = ('41m' | str lpad -l 8 -c ' ') + let ansi42m = ('42m' | str lpad -l 8 -c ' ') + let ansi43m = ('43m' | str lpad -l 8 -c ' ') + let ansi44m = ('44m' | str lpad -l 8 -c ' ') + let ansi45m = ('45m' | str lpad -l 8 -c ' ') + let ansi46m = ('46m' | str lpad -l 8 -c ' ') + let ansi47m = ('47m' | str lpad -l 8 -c ' ') $"(char newline)($ansi40m)($ansi41m)($ansi42m)($ansi43m)($ansi44m)($ansi45m)($ansi46m)($ansi47m)(char newline)" } } @@ -36,15 +36,15 @@ def mk_header [color_range:range] { let ansi_color = $"($color)m" if $color == $min_rng { if $min_rng == 100 { - ($ansi_color | fill --width $hi_start_pad -c ' ') - } else { - ($ansi_color | fill --width $lo_start_pad -c ' ') + ($ansi_color | str lpad -l $hi_start_pad -c ' ') + } { + ($ansi_color | str lpad -l $lo_start_pad -c ' ') } - } else { + } { if $min_rng >= 100 { - ($ansi_color | fill --width $hi_regular_pad -c ' ') - } else { - ($ansi_color | fill --width $lo_regular_pad -c ' ') + ($ansi_color | str lpad -l $hi_regular_pad -c ' ') + } { + ($ansi_color | str lpad -l $lo_regular_pad -c ' ') } } } | str join diff --git a/before_v0.60/coloring/nu_index_bg.nu b/before_v0.60/coloring/nu_index_bg.nu index a78bc30aa..c805e8850 100644 --- a/before_v0.60/coloring/nu_index_bg.nu +++ b/before_v0.60/coloring/nu_index_bg.nu @@ -3,10 +3,10 @@ def show_index_colors [] { echo 1..256 | each { |idx| let cr = ($"($idx) % 16" | math eval) let color = $"(ansi -e $prefix)($idx)m" - let padded_number = ($"($idx)" | fill --width 3 -c '0') + let padded_number = ($"($idx)" | str lpad -l 3 -c '0') if $cr == 0 { $"($color)($padded_number) (ansi -e 0m)(char newline)" - } else { + } { $"($color)($padded_number) (ansi -e 0m)" } } | str join diff --git a/before_v0.60/coloring/nu_index_fg.nu b/before_v0.60/coloring/nu_index_fg.nu index 291e2836a..a1a78a0f5 100644 --- a/before_v0.60/coloring/nu_index_fg.nu +++ b/before_v0.60/coloring/nu_index_fg.nu @@ -3,9 +3,9 @@ def show_index_colors [] { echo 1..256 | each { |fg| let cr = ($"($fg) % 16" | math eval) if $cr == 0 { - $"(ansi -e $prefix)($fg)m($fg | into string | fill --width 3 -c '0') (char newline)" - } else { - $"(ansi -e $prefix)($fg)m($fg | into string | fill --width 3 -c '0') " + $"(ansi -e $prefix)($fg)m($fg | into string | str lpad -l 3 -c '0') (char newline)" + } { + $"(ansi -e $prefix)($fg)m($fg | into string | str lpad -l 3 -c '0') " } } | str join } diff --git a/before_v0.60/coloring/nu_index_fg2.nu b/before_v0.60/coloring/nu_index_fg2.nu index b35e940f0..88d9c4619 100644 --- a/before_v0.60/coloring/nu_index_fg2.nu +++ b/before_v0.60/coloring/nu_index_fg2.nu @@ -6,11 +6,11 @@ def show_index_colors [] { echo 1..256 | each { |idx| let cr = ($"($idx) % 16" | math eval) let color = ($"(ansi -e $prefix)($idx)m") - let padded_number = ($"($idx)" | fill --width 3 -c '0') + let padded_number = ($"($idx)" | str lpad -l 3 -c '0') if $cr == 0 { $"($color)($padded_number) (char newline)" - } else { + } { $"($color)($padded_number) " } } | str join diff --git a/before_v0.60/coloring/python_index_table.nu b/before_v0.60/coloring/python_index_table.nu index a05795cd2..c1869a69a 100644 --- a/before_v0.60/coloring/python_index_table.nu +++ b/before_v0.60/coloring/python_index_table.nu @@ -11,8 +11,8 @@ echo 0..16 | each { |col| let row = (echo 0..16 | each { |row| let code = ($col * 16 + $row) if $code < 256 { - $"(ansi -e '38;5;')($code | into string)m($code | into string | fill --width 4 -c ' ')(ansi reset)" - } else {} # Do nothing in the else + $"(ansi -e '38;5;')($code | into string)m($code | into string | str lpad -l 4 -c ' ')(ansi reset)" + } {} # Do nothing in the else } | str join) $"($row)(char newline)" } | str join @@ -22,8 +22,8 @@ echo 0..16 | each { |col| let row = (echo 0..16 | each { |row| let code = ($col * 16 + $row) if $code < 256 { - $"(ansi -e '48;5;')($code | into string)m($code | into string | fill --width 4 -c ' ')(ansi reset)" - } else {} # do nothing in the else + $"(ansi -e '48;5;')($code | into string)m($code | into string | str lpad -l 4 -c ' ')(ansi reset)" + } {} # do nothing in the else } | str join) $"($row)(char newline)" } | str join diff --git a/before_v0.60/coloring/ref_table.nu b/before_v0.60/coloring/ref_table.nu index 8e3725974..55d6ba420 100644 --- a/before_v0.60/coloring/ref_table.nu +++ b/before_v0.60/coloring/ref_table.nu @@ -4,7 +4,7 @@ # This prints the column headers let nl = (char newline) let plus = $"($nl) + " -let cols = (seq 0 35 | each { |col| $"($col)" | fill -c ' ' --width 3 } | str join) +let cols = (seq 0 35 | each { |col| $"($col)" | str lpad -c ' ' -l 3 } | str join) $"($plus)($cols)" let ansi_bg = (ansi -e '48;5;') @@ -21,7 +21,7 @@ $"($row_header)($row_data)($nl)($nl)" # This is the meat of the script that prints the little squares of color seq 0 6 | each { |row_idx| let r = ($"($row_idx) * 36 + 16" | math eval) - let row_header = (echo $r | into string -d 0 | fill -c ' ' --width 4) + let row_header = (echo $r | into string -d 0 | str lpad -c ' ' -l 4) let row_data = (seq 0 35 | each { |row| let val = ($"($r + $row)" | math eval | into string -d 0) $"($ansi_bg)($val)m (ansi -e 'm') " diff --git a/before_v0.60/ls_mods/ls-wide-with-color.nu b/before_v0.60/ls_mods/ls-wide-with-color.nu index c76a41ff8..f3dcf7890 100644 --- a/before_v0.60/ls_mods/ls-wide-with-color.nu +++ b/before_v0.60/ls_mods/ls-wide-with-color.nu @@ -29,7 +29,7 @@ def ls-wide2 [ ] { let is_dir_empty = ($dir | empty?) let is_columns_empty = ($columns | empty?) - let ls_data = (if $is_dir_empty { ls } else { ls $dir }) + let ls_data = (if $is_dir_empty { ls } { ls $dir }) let ansi_size = 9 # \x1b[36m + string + \x1b[0m, ~9 characters are added to each string for coloring let max_fname_size = ((echo $ls_data | get name | into string | str length | math max) + $ansi_size) let max_fsize_size = (echo $ls_data | get size | into string | str length | math max) @@ -39,15 +39,15 @@ def ls-wide2 [ # log (build-string $clr_file ' ' $max_fname_size) let clr_size = (echo $file.item.size | into string) # log (build-string $clr_size ' ' $max_fsize_size) - $"($clr_file | fill --alignment r -c ' ' --width $max_fname_size) ($clr_size | fill -c ' ' --width $max_fsize_size) " | autoview + $"($clr_file | str rpad -c ' ' -l $max_fname_size) ($clr_size | str lpad -c ' ' -l $max_fsize_size) " | autoview if $is_columns_empty { if ($file.index + 1) mod 3 == 0 { echo (char newline) | autoview - } else {} - } else { + } {} + } { if ($file.index + 1) mod $columns == 0 { echo (char newline) | autoview - } else {} + } {} } } | str join } @@ -61,12 +61,12 @@ def colorize [thing:any] { # build-string (ansi -e '36m') $thing (ansi -e '0m') $"(fg_cyan)($thing)(relet)" # build-string 'e[36m' $thing 'e[0m' - } else { + } { if $ext == "nu" { # build-string (ansi -e '95m') $thing (ansi -e '0m') $"(fg_light_magenta)($thing)(relet)" # build-string 'e[95m' $thing 'e[0m' - } else { + } { # build-string (ansi -e '92m') $thing (ansi -e '0m') $"(fg_light_green)($thing)(relet)" # build-string 'e[92m' $thing 'e[0m' diff --git a/before_v0.60/ls_mods/ls-wide.nu b/before_v0.60/ls_mods/ls-wide.nu index 0bd684bc7..304f16e3a 100644 --- a/before_v0.60/ls_mods/ls-wide.nu +++ b/before_v0.60/ls_mods/ls-wide.nu @@ -10,13 +10,13 @@ def ls-wide [ if $is_path_empty { if $is_columns_empty { run_ls "." $columns_default - } else { + } { run_ls "." $columns } - } else { + } { if $is_columns_empty { run_ls $path $columns_default - } else { + } { run_ls $path $columns } } @@ -30,18 +30,18 @@ def run_ls [ let max_fsize_size = (ls $path | get size | into string | str length | math max) ls $path | each -n { |file| - let the_file = ($file.item.name | into string | fill --alignment r -c ' ' --width $max_fname_size) - let the_size = ($file.item.size | into string | fill --alignment l -c ' ' --width $max_fsize_size) + let the_file = ($file.item.name | into string | str rpad -c ' ' -l $max_fname_size) + let the_size = ($file.item.size | into string | str lpad -c ' ' -l $max_fsize_size) $"($the_file) ($the_size) " | autoview if $is_columns_empty { if ($file.index + 1) mod 3 == 0 { echo (char newline) | autoview - } else {} - } else { + } {} + } { if ($file.index + 1) mod $columns == 0 { echo (char newline) | autoview - } else {} + } {} } } | str join } diff --git a/before_v0.60/make_readme_table.nu b/before_v0.60/make_readme_table.nu index 7cd3fe91c..8f713bc32 100644 --- a/before_v0.60/make_readme_table.nu +++ b/before_v0.60/make_readme_table.nu @@ -17,7 +17,7 @@ let nu_table = ($nu_files | let cat = ($it.File | path dirname) if $cat == "" { "not assigned yet" - } else { + } { $cat } } | where Category !~ ".git" | select Category File | sort-by Category) diff --git a/before_v0.60/progress_bar/progress_bar.nu b/before_v0.60/progress_bar/progress_bar.nu index 2ba6c0c65..c5f9b5aa3 100644 --- a/before_v0.60/progress_bar/progress_bar.nu +++ b/before_v0.60/progress_bar/progress_bar.nu @@ -24,24 +24,24 @@ ansi cursor_off # Move cursor all the way to the left $"(ansi -e '1000D')" | autoview # Draw the background for the progress bar -$bg_fill | fill -c $bg_fill -l $pb_len +$bg_fill | str lpad -c $bg_fill -l $pb_len echo 1..<$pb_len | each { |cur_progress| # This is kind of a hack because it's not incrementally drawing a new box # It's drawing the entire row every time with a different padding amount - # echo $blocks.7 | fill -c $blocks.7 -l $it | autoview + # echo $blocks.7 | str lpad -c $blocks.7 -l $it | autoview echo 0..7 | each { |tick| let cur_idx = ($tick mod 8) let cur_block = (echo $blocks | nth $cur_idx) - $"($cur_block | fill -c $blocks.7 -l $cur_progress)" | autoview + $"($cur_block | str lpad -c $blocks.7 -l $cur_progress)" | autoview $"(ansi -e '1000D')" | autoview sleep 5ms } $"(ansi -e '1000D')" | autoview } # Fill in the last background block -$"($blocks.7 | fill -c $blocks.7 -l $pb_len)" | autoview +$"($blocks.7 | str lpad -c $blocks.7 -l $pb_len)" | autoview char newline "Done" ansi cursor_on diff --git a/before_v0.60/progress_bar/progress_bar_no_back.nu b/before_v0.60/progress_bar/progress_bar_no_back.nu index 5a0c2abc3..43f1ff922 100644 --- a/before_v0.60/progress_bar/progress_bar_no_back.nu +++ b/before_v0.60/progress_bar/progress_bar_no_back.nu @@ -5,7 +5,7 @@ echo 1..<$pb_size | each { |cur_size| echo 0..7 | each { |tick| let idx = ($tick mod 8) let cur_block = (echo $blocks | nth $idx) - $"($cur_block | fill -c $blocks.7 -l $cur_size)" | autoview + $"($cur_block | str lpad -c $blocks.7 -l $cur_size)" | autoview $"(ansi -e '1000D')" | autoview sleep 5ms } diff --git a/before_v0.60/prompt/left_and_right_prompt.nu b/before_v0.60/prompt/left_and_right_prompt.nu index 23a7b8f48..caddfe67b 100644 --- a/before_v0.60/prompt/left_and_right_prompt.nu +++ b/before_v0.60/prompt/left_and_right_prompt.nu @@ -43,7 +43,7 @@ def construct_prompt [] { let calculated_right_len = ($term_width - $left_len + ($right_colored_len - $right_len)) # finally, let's make the prompt - let the_prompt = $"($left_colored)($right_colored | fill -c ' ' -l $calculated_right_len)(char newline)($decorator) " + let the_prompt = $"($left_colored)($right_colored | str lpad -c ' ' -l $calculated_right_len)(char newline)($decorator) " # let's update the title bar now echo $title_bar @@ -65,7 +65,7 @@ def home_abbrev [] { let lin-home = ($nu.home-dir | into string | str find-replace -a '\\' '/' | str downcase) let lin-pwd = (pwd | into string | str find-replace -a '\\' '/' | str downcase) $lin-pwd | str find-replace $lin-home '~' - } else { + } { pwd } } From 2d0b097aeaf85201bb047118c2a22d98bfc1b9ca Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Sun, 28 Apr 2024 08:49:36 -0300 Subject: [PATCH 8/9] Revert ":bug: replace `str collect` for `str join`" This reverts commit 1bc6b400c6f31e9907302a4b8403bddeccbd053f. --- before_v0.60/bin-utils.nu | 2 +- before_v0.60/coloring/256_color_testpattern.nu | 4 ++-- before_v0.60/coloring/color_table.nu | 6 +++--- before_v0.60/coloring/color_tables.nu | 12 ++++++------ before_v0.60/coloring/gradient.nu | 4 ++-- before_v0.60/coloring/nu_index_bg.nu | 2 +- before_v0.60/coloring/nu_index_fg.nu | 4 ++-- before_v0.60/coloring/nu_index_fg2.nu | 4 ++-- before_v0.60/coloring/python_index_table.nu | 8 ++++---- before_v0.60/coloring/ref_table.nu | 8 ++++---- before_v0.60/coloring/sample.nu | 6 +++--- before_v0.60/cool_oneliners/dict.nu | 2 +- before_v0.60/examples/date_in_local_timezones.nu | 2 +- before_v0.60/examples/netstat.nu | 4 ++-- before_v0.60/fun/life.nu | 4 ++-- before_v0.60/fun/nyancat.nu | 4 ++-- before_v0.60/fun/spark.nu | 2 +- before_v0.60/fun/star.nu | 6 +++--- before_v0.60/fuzzy/fuzzy_command_search.nu | 2 +- before_v0.60/language/playground/lib.nu | 2 +- before_v0.60/ls_mods/ls-wide-with-color.nu | 2 +- before_v0.60/ls_mods/ls-wide.nu | 2 +- before_v0.60/make_release/gen-js-ext.nu | 4 ++-- before_v0.60/make_release/gen-ts-ext.nu | 12 ++++++------ .../make_release/this_week_in_nu_release.nu | 8 ++++---- .../make_release/this_week_in_nu_weekly.nu | 8 ++++---- before_v0.60/nu_101/inner_outer_loop.nu | 4 ++-- before_v0.60/prompt/git_status_prompt.nu | 4 ++-- before_v0.60/prompt/left_and_right_prompt.nu | 14 +++++++------- before_v0.60/stdlib_candidate/nu_style.nu | 6 +++--- before_v0.60/stdlib_candidate/print.nu | 16 ++++++++-------- before_v0.60/virtual_environments/conda.nu | 6 +++--- before_v0.60/virtual_environments/venv.nu | 6 +++--- 33 files changed, 90 insertions(+), 90 deletions(-) diff --git a/before_v0.60/bin-utils.nu b/before_v0.60/bin-utils.nu index e54f5c31a..ae866fae1 100644 --- a/before_v0.60/bin-utils.nu +++ b/before_v0.60/bin-utils.nu @@ -67,7 +67,7 @@ export def "test bits" [] { error make { msg: "Test mismatch", label: { - text: $"Expected: ($it), bits: ($bits | str join ''), result: ($res)" + text: $"Expected: ($it), bits: ($bits | str collect ''), result: ($res)" start: $span.start end: $span.end } diff --git a/before_v0.60/coloring/256_color_testpattern.nu b/before_v0.60/coloring/256_color_testpattern.nu index e69e4945d..e73b20c2f 100644 --- a/before_v0.60/coloring/256_color_testpattern.nu +++ b/before_v0.60/coloring/256_color_testpattern.nu @@ -54,7 +54,7 @@ def print_run [start:int, amount:int] { } { "" } - } | append " " | str join + } | append " " | str collect } def print_blocks [start:int, end:int, block-cols:int, block-rows:int, blocks-per-line:int] { @@ -64,7 +64,7 @@ def print_blocks [start:int, end:int, block-cols:int, block-rows:int, blocks-per for row in 0..<$block-rows { for block in 0..<$blocks-per-line { print_run ($start + $block * $block-length + $row * $block-cols + $i * $block-length * $blocks-per-line) $block-cols - } | append (char nl) | str join | autoview + } | append (char nl) | str collect | autoview } char nl | autoview } diff --git a/before_v0.60/coloring/color_table.nu b/before_v0.60/coloring/color_table.nu index 7abd286da..0fae41cde 100644 --- a/before_v0.60/coloring/color_table.nu +++ b/before_v0.60/coloring/color_table.nu @@ -47,7 +47,7 @@ def mk_header [color_range:range] { ($ansi_color | str lpad -l $lo_regular_pad -c ' ') } } - } | str join + } | str collect echo (char newline) } @@ -58,14 +58,14 @@ def color_row_range [num:int bg_rg:range] { let row_name = $"($num);($back)m" let ansi_color = (ansi -e $row_name) $"($ansi_color) ($row_name) ($reset)" - } | append (char newline) | str join) + } | append (char newline) | str collect) $"($row_header)($row_data)" } def create_color_tables [fg_range:range bg_range:range] { echo $fg_range | each { |fg| color_row_range $fg $bg_range - } | str join + } | str collect } def color_table [] { diff --git a/before_v0.60/coloring/color_tables.nu b/before_v0.60/coloring/color_tables.nu index 0e855ee53..27018c33e 100644 --- a/before_v0.60/coloring/color_tables.nu +++ b/before_v0.60/coloring/color_tables.nu @@ -16,11 +16,11 @@ for x in 0..8 { let row = (for a in 40..47 { let color = $"($x);($i);($a)" $"(ansi -e $color)m\e[($color)(ansi -e '0;37;40')m " - } | str join) + } | str collect) $"($row)(char newline)" - } | str join) + } | str collect) $"($row)(char newline)" -} | str join +} | str collect # Nushell 0.31.0 # echo 0..8 | each { |style| @@ -28,8 +28,8 @@ for x in 0..8 { # let row = (echo 40..47 | each { |bg| # let color = $"($style);($fg);($bg)m" # $"(ansi -e $color)($color)(ansi reset) " -# } | str join) +# } | str collect) # $"($row)(char newline)" -# } | str join) +# } | str collect) # $"($row)(char newline)" -# } | str join \ No newline at end of file +# } | str collect \ No newline at end of file diff --git a/before_v0.60/coloring/gradient.nu b/before_v0.60/coloring/gradient.nu index 3beb9638e..23cacee5b 100644 --- a/before_v0.60/coloring/gradient.nu +++ b/before_v0.60/coloring/gradient.nu @@ -14,9 +14,9 @@ seq 0 $height | each { } { $"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')" } - } | str join) + } | str collect) $"($row_data)(char newline)" | autoview -} | str join +} | str collect def iter_inc [incr mult iter] { $incr + $mult * $iter diff --git a/before_v0.60/coloring/nu_index_bg.nu b/before_v0.60/coloring/nu_index_bg.nu index c805e8850..be99e70c5 100644 --- a/before_v0.60/coloring/nu_index_bg.nu +++ b/before_v0.60/coloring/nu_index_bg.nu @@ -9,7 +9,7 @@ def show_index_colors [] { } { $"($color)($padded_number) (ansi -e 0m)" } - } | str join + } | str collect } show_index_colors diff --git a/before_v0.60/coloring/nu_index_fg.nu b/before_v0.60/coloring/nu_index_fg.nu index a1a78a0f5..b69f9155e 100644 --- a/before_v0.60/coloring/nu_index_fg.nu +++ b/before_v0.60/coloring/nu_index_fg.nu @@ -7,10 +7,10 @@ def show_index_colors [] { } { $"(ansi -e $prefix)($fg)m($fg | into string | str lpad -l 3 -c '0') " } - } | str join + } | str collect } show_index_colors #one-liner -#echo 0..255 | each { |fg| echo [(ansi -e '38;5;') ($fg | into string) 'm' ($fg | into string) ' ']} | str join \ No newline at end of file +#echo 0..255 | each { |fg| echo [(ansi -e '38;5;') ($fg | into string) 'm' ($fg | into string) ' ']} | str collect \ No newline at end of file diff --git a/before_v0.60/coloring/nu_index_fg2.nu b/before_v0.60/coloring/nu_index_fg2.nu index 88d9c4619..d28726673 100644 --- a/before_v0.60/coloring/nu_index_fg2.nu +++ b/before_v0.60/coloring/nu_index_fg2.nu @@ -13,7 +13,7 @@ def show_index_colors [] { } { $"($color)($padded_number) " } - } | str join + } | str collect } show_index_colors @@ -22,4 +22,4 @@ show_index_colors # it all on one line which wraps in # your terminal -#echo 1..256 | each { |idx| echo [(ansi -e '38;5;') (build-string $idx) 'm' (build-string $idx) ' ']} | str join \ No newline at end of file +#echo 1..256 | each { |idx| echo [(ansi -e '38;5;') (build-string $idx) 'm' (build-string $idx) ' ']} | str collect \ No newline at end of file diff --git a/before_v0.60/coloring/python_index_table.nu b/before_v0.60/coloring/python_index_table.nu index c1869a69a..ec127a607 100644 --- a/before_v0.60/coloring/python_index_table.nu +++ b/before_v0.60/coloring/python_index_table.nu @@ -13,9 +13,9 @@ echo 0..16 | each { |col| if $code < 256 { $"(ansi -e '38;5;')($code | into string)m($code | into string | str lpad -l 4 -c ' ')(ansi reset)" } {} # Do nothing in the else - } | str join) + } | str collect) $"($row)(char newline)" -} | str join +} | str collect # Background Colors echo 0..16 | each { |col| @@ -24,6 +24,6 @@ echo 0..16 | each { |col| if $code < 256 { $"(ansi -e '48;5;')($code | into string)m($code | into string | str lpad -l 4 -c ' ')(ansi reset)" } {} # do nothing in the else - } | str join) + } | str collect) $"($row)(char newline)" -} | str join +} | str collect diff --git a/before_v0.60/coloring/ref_table.nu b/before_v0.60/coloring/ref_table.nu index 55d6ba420..7e97acaad 100644 --- a/before_v0.60/coloring/ref_table.nu +++ b/before_v0.60/coloring/ref_table.nu @@ -4,7 +4,7 @@ # This prints the column headers let nl = (char newline) let plus = $"($nl) + " -let cols = (seq 0 35 | each { |col| $"($col)" | str lpad -c ' ' -l 3 } | str join) +let cols = (seq 0 35 | each { |col| $"($col)" | str lpad -c ' ' -l 3 } | str collect) $"($plus)($cols)" let ansi_bg = (ansi -e '48;5;') @@ -15,7 +15,7 @@ $"($nl)($nl)" let row_header = ' 0 ' let row_data = (seq 0 15 | each { |row| $"($ansi_bg)($row)m ($ansi_reset)" -} | str join) +} | str collect) $"($row_header)($row_data)($nl)($nl)" # This is the meat of the script that prints the little squares of color @@ -25,6 +25,6 @@ seq 0 6 | each { |row_idx| let row_data = (seq 0 35 | each { |row| let val = ($"($r + $row)" | math eval | into string -d 0) $"($ansi_bg)($val)m (ansi -e 'm') " - } | str join) + } | str collect) $"($row_header) ($row_data)($nl)($nl)" -} | str join +} | str collect diff --git a/before_v0.60/coloring/sample.nu b/before_v0.60/coloring/sample.nu index 88ddb13b4..c2e5fd250 100644 --- a/before_v0.60/coloring/sample.nu +++ b/before_v0.60/coloring/sample.nu @@ -15,10 +15,10 @@ echo 40..47 100..107 49 | each { |clbg| let row = (echo 0..9 | each { |attr| let ansi_str = $"($attr);($clbg);($clfg)m" $"(ansi -e $ansi_str) ($ansi_str) (ansi reset)" - } | str join) + } | str collect) $"($row)(char newline)" | autoview - } | str join -} | str join + } | str collect +} | str collect # Bash Script # for clbg in {40..47} {100..107} 49 ; do diff --git a/before_v0.60/cool_oneliners/dict.nu b/before_v0.60/cool_oneliners/dict.nu index bd12cbd01..3678ffd28 100644 --- a/before_v0.60/cool_oneliners/dict.nu +++ b/before_v0.60/cool_oneliners/dict.nu @@ -1,7 +1,7 @@ # Function querying free online English dictionary API for definition of given word(s) def dict [...word #word(s) to query the dictionary API but they have to make sense together like "martial law", not "cats dogs" ] { - let query = ($word | str join %20) + let query = ($word | str collect %20) let link = (build-string 'https://api.dictionaryapi.dev/api/v2/entries/en/' ($query|str find-replace ' ' '%20')) let output = (fetch $link | rename word) diff --git a/before_v0.60/examples/date_in_local_timezones.nu b/before_v0.60/examples/date_in_local_timezones.nu index 1c3815d63..2b8eb2c59 100644 --- a/before_v0.60/examples/date_in_local_timezones.nu +++ b/before_v0.60/examples/date_in_local_timezones.nu @@ -11,7 +11,7 @@ def say [block] { [[name]; [($person.name | str capitalize)]] } ) - } | str join (char newline) + } | str collect (char newline) } $people | say {|person| $"($person.name)'s timezone is ($person.tz)"} diff --git a/before_v0.60/examples/netstat.nu b/before_v0.60/examples/netstat.nu index 056f88db0..596cc9412 100644 --- a/before_v0.60/examples/netstat.nu +++ b/before_v0.60/examples/netstat.nu @@ -1,10 +1,10 @@ let ns = (netstat | lines | skip 1) -let first-batch = ($ns | keep until $it =~ Active | str join (char nl) | from ssv -m 1) +let first-batch = ($ns | keep until $it =~ Active | str collect (char nl) | from ssv -m 1) let second-batch = ($ns | skip until $it =~ Active | skip 1 | - str join (char nl) | + str collect (char nl) | str find-replace "\[ \]" "[]" --all | from ssv -m 1 | default I-Node "" | diff --git a/before_v0.60/fun/life.nu b/before_v0.60/fun/life.nu index 1651daa9a..bf8dc6003 100644 --- a/before_v0.60/fun/life.nu +++ b/before_v0.60/fun/life.nu @@ -52,8 +52,8 @@ def print-grid [$grid] { } { "." } - } | append (char nl) | str join - } | str join + } | append (char nl) | str collect + } | str collect } def main [] { diff --git a/before_v0.60/fun/nyancat.nu b/before_v0.60/fun/nyancat.nu index 39ec1d131..7c4c6163b 100644 --- a/before_v0.60/fun/nyancat.nu +++ b/before_v0.60/fun/nyancat.nu @@ -58,10 +58,10 @@ let frames = [ # it's a little slow - maybe 1 fps but still firmly in the 'fun' category ansi cursor_off for x in $frames -n { - $frames | nth $x.index | get frames | split chars | each -n {|char| if $char.index mod 64 == 0 { $"(ansi -e '0m')(char nl)" } {$"(ansi -e ($map | where symbol == $char.item | get color))(char sp)"}} | str join + $frames | nth $x.index | get frames | split chars | each -n {|char| if $char.index mod 64 == 0 { $"(ansi -e '0m')(char nl)" } {$"(ansi -e ($map | where symbol == $char.item | get color))(char sp)"}} | str collect ansi -e '0m' ansi cls -} | str join +} | str collect ansi cursor_on char nl \ No newline at end of file diff --git a/before_v0.60/fun/spark.nu b/before_v0.60/fun/spark.nu index f27fe57ed..8678036b5 100644 --- a/before_v0.60/fun/spark.nu +++ b/before_v0.60/fun/spark.nu @@ -19,5 +19,5 @@ def spark [v: any] { for e in $v { let i = (($e - $min) / $scale | into int) $"($TICKS | nth $i)" - } | str join + } | str collect } \ No newline at end of file diff --git a/before_v0.60/fun/star.nu b/before_v0.60/fun/star.nu index 7619ae1a4..a922bec8a 100644 --- a/before_v0.60/fun/star.nu +++ b/before_v0.60/fun/star.nu @@ -131,10 +131,10 @@ $"(ansi -e '?25h')(ansi -e 'm')(ansi -e 'H')" # $"(ansi -e '38;2;')($c);($c);($c)m*" # }) -# echo $cols | str join +# echo $cols | str collect # }) -# (ansi -e 'H') + (echo $rows | str join (char nl)) -# } | str join) +# (ansi -e 'H') + (echo $rows | str collect (char nl)) +# } | str collect) # (ansi -e "?25l") + $output + $"(ansi -e '?25h')(ansi -e 'm')(ansi -e 'H')" diff --git a/before_v0.60/fuzzy/fuzzy_command_search.nu b/before_v0.60/fuzzy/fuzzy_command_search.nu index 9214771cb..32a8da855 100644 --- a/before_v0.60/fuzzy/fuzzy_command_search.nu +++ b/before_v0.60/fuzzy/fuzzy_command_search.nu @@ -33,6 +33,6 @@ def fuzzy-command-search [] { )( $it.description )" - }) | str join (char nl) | fzf | split column (char tab)| get Column1 | clip; paste ) + }) | str collect (char nl) | fzf | split column (char tab)| get Column1 | clip; paste ) } diff --git a/before_v0.60/language/playground/lib.nu b/before_v0.60/language/playground/lib.nu index 4dc456537..b854b682e 100644 --- a/before_v0.60/language/playground/lib.nu +++ b/before_v0.60/language/playground/lib.nu @@ -1,6 +1,6 @@ def playground [topic, block] { with-env [N 5 REJECT slow] { - echo $topic " tests" (char newline) | str join + echo $topic " tests" (char newline) | str collect do $block } diff --git a/before_v0.60/ls_mods/ls-wide-with-color.nu b/before_v0.60/ls_mods/ls-wide-with-color.nu index f3dcf7890..32f4ae34b 100644 --- a/before_v0.60/ls_mods/ls-wide-with-color.nu +++ b/before_v0.60/ls_mods/ls-wide-with-color.nu @@ -49,7 +49,7 @@ def ls-wide2 [ echo (char newline) | autoview } {} } - } | str join + } | str collect } def colorize [thing:any] { diff --git a/before_v0.60/ls_mods/ls-wide.nu b/before_v0.60/ls_mods/ls-wide.nu index 304f16e3a..613c58bd2 100644 --- a/before_v0.60/ls_mods/ls-wide.nu +++ b/before_v0.60/ls_mods/ls-wide.nu @@ -43,7 +43,7 @@ def run_ls [ echo (char newline) | autoview } {} } - } | str join + } | str collect } # This is a first attempt and some type of logging diff --git a/before_v0.60/make_release/gen-js-ext.nu b/before_v0.60/make_release/gen-js-ext.nu index b9059dc31..eeaaf92be 100644 --- a/before_v0.60/make_release/gen-js-ext.nu +++ b/before_v0.60/make_release/gen-js-ext.nu @@ -1,5 +1,5 @@ def gen_keywords [] { - let cmds = (help commands | where description != '' | get name | str join '|') + let cmds = (help commands | where description != '' | get name | str collect '|') let var_with_dash_or_under_regex = "(([a-zA-Z]+[\\-_]){1,}[a-zA-Z]+\\s)" let preamble = "\\b(" let postamble = ")\\b" @@ -16,7 +16,7 @@ def gen_sub_keywords [] { let postamble = ")\\b" let cmds = (for x in $sub_cmds { $"($x.base)\\s($x.sub)" - } | str join '|') + } | str collect '|') $'"match": "($preamble)($cmds)($postamble)",' } $"Generating sub keywords(char nl)" diff --git a/before_v0.60/make_release/gen-ts-ext.nu b/before_v0.60/make_release/gen-ts-ext.nu index 61ae66759..b617e213b 100644 --- a/before_v0.60/make_release/gen-ts-ext.nu +++ b/before_v0.60/make_release/gen-ts-ext.nu @@ -25,9 +25,9 @@ def gen-ts-cmds [] { let line1 = (build-string " const " $it.camel " = new vscode.CompletionItem('" $it.name "');" (char newline)) let line2 = (build-string " " $it.camel ".commitCharacters = [' '];" (char newline) (char newline)) $line1 + $line2 - } | str join) + } | str collect) - build-string (echo $ts) (char nl) " return [ " (echo $updated_cmds | get camel | str join ', ') " ];" (char nl) ' },' (char nl) ' }' (char nl) ' );' (char nl) (char nl) | str join + build-string (echo $ts) (char nl) " return [ " (echo $updated_cmds | get camel | str collect ', ') " ];" (char nl) ' },' (char nl) ' }' (char nl) ' );' (char nl) (char nl) | str collect } # generate typescript from nushell subcommands @@ -57,9 +57,9 @@ def gen-ts-subs [] { let line08 = (build-string ' ' $method '.detail = "' $it.item.description '";' (char nl) (char nl)) $line07 + $line08 } - } | str join) + } | str collect) - let methods = (echo $it.sub_cmds.name | str camel-case | str join ', ') + let methods = (echo $it.sub_cmds.name | str camel-case | str collect ', ') let lines = $" return [ @@ -75,11 +75,11 @@ def gen-ts-subs [] { " build-string $preamble $lines - } | str join) + } | str collect) echo $subs_collection | let post01 = (build-string " context.subscriptions.push(" (char nl)) - let post02 = (build-string " " (echo $updated_cmds | get camelProvider | uniq | str join ', ') (char nl)) + let post02 = (build-string " " (echo $updated_cmds | get camelProvider | uniq | str collect ', ') (char nl)) let post03 = (build-string " );" (char nl) "}" (char nl)) build-string $ts $post01 $post02 $post03 diff --git a/before_v0.60/make_release/this_week_in_nu_release.nu b/before_v0.60/make_release/this_week_in_nu_release.nu index adc168ec1..83dc2c3bf 100644 --- a/before_v0.60/make_release/this_week_in_nu_release.nu +++ b/before_v0.60/make_release/this_week_in_nu_release.nu @@ -43,10 +43,10 @@ def do-work [] { } { $"(char nl)### [($pr.item.title)](char lparen)($pr.item.html_url)(char rparen)(char nl)(char nl)($pr.item.body)(char nl) and (char nl)" } - } | str join) + } | str collect) $"### **($user_name)**(char nl)(char nl)---(char nl)($user_prs)(char nl)" - } | str join + } | str collect char nl } @@ -56,11 +56,11 @@ def do-work [] { if ($entries | all? (echo $it | empty?)) { } { - $entries | str join + $entries | str collect } } # 2019-08-23 was the release of 0.2.0, the first public release let week_num = (seq date -b '2019-08-23' -n 7 | length) $"# This week in Nushell #($week_num)(char nl)(char nl)" -do-work | str join +do-work | str collect diff --git a/before_v0.60/make_release/this_week_in_nu_weekly.nu b/before_v0.60/make_release/this_week_in_nu_weekly.nu index 68318206b..4894068a4 100644 --- a/before_v0.60/make_release/this_week_in_nu_weekly.nu +++ b/before_v0.60/make_release/this_week_in_nu_weekly.nu @@ -46,17 +46,17 @@ def do-work [] { } { $"[($pr.item.title)](char lparen)($pr.item.html_url)(char rparen), and " } - } | str join) + } | str collect) $"- ($user_name) created ($user_prs) (char nl)" - } | str join + } | str collect char nl } }) if ($entries | all? ($it | empty?)) { } { - $entries | str join + $entries | str collect } } @@ -67,5 +67,5 @@ $"# This week in Nushell #($week_num)(char nl)(char nl)" if ($nu.env | select GITHUB_USERNAME | empty?) or ($nu.env | select GITHUB_PASSWORD | empty?) { echo 'Please set GITHUB_USERNAME and GITHUB_PASSWORD in $nu.env to use this script' } { - do-work | str join + do-work | str collect } diff --git a/before_v0.60/nu_101/inner_outer_loop.nu b/before_v0.60/nu_101/inner_outer_loop.nu index f2825e7db..be9722811 100644 --- a/before_v0.60/nu_101/inner_outer_loop.nu +++ b/before_v0.60/nu_101/inner_outer_loop.nu @@ -6,6 +6,6 @@ seq 30 39 | each { |outer| let row = $"($outer) " let data = (seq 40 49 | each { |inner| $"($inner) " - } | str join) + } | str collect) $"($row)($data)(char newline)" -} | str join \ No newline at end of file +} | str collect \ No newline at end of file diff --git a/before_v0.60/prompt/git_status_prompt.nu b/before_v0.60/prompt/git_status_prompt.nu index 157514c82..1184b353c 100644 --- a/before_v0.60/prompt/git_status_prompt.nu +++ b/before_v0.60/prompt/git_status_prompt.nu @@ -25,7 +25,7 @@ def prompt-pwd [] { $"($part | str substring [0 1])/" } }) - $"~/($short-part | str join)($path | last)" + $"~/($short-part | str collect)($path | last)" } { $"~/($path | last)" } @@ -85,7 +85,7 @@ def git-branch-icon [] { } { "red" }) - $"|(ansi $branch-colour)($branch)(ansi reset):($modified | get status | uniq | str downcase | each { git-prompt-icons $it })" | str join + $"|(ansi $branch-colour)($branch)(ansi reset):($modified | get status | uniq | str downcase | each { git-prompt-icons $it })" | str collect } } { "" diff --git a/before_v0.60/prompt/left_and_right_prompt.nu b/before_v0.60/prompt/left_and_right_prompt.nu index caddfe67b..4b10ad4b5 100644 --- a/before_v0.60/prompt/left_and_right_prompt.nu +++ b/before_v0.60/prompt/left_and_right_prompt.nu @@ -12,7 +12,7 @@ def construct_prompt [] { # the current bit branch # let git_status = (git -c core.quotepath=false -c color.status=false status -uall --short --branch) - let git_info = (do -i { git rev-parse --abbrev-ref HEAD } | str trim -c (char nl) | str join ) + let git_info = (do -i { git rev-parse --abbrev-ref HEAD } | str trim -c (char nl) | str collect ) # what to put in the title let title_bar = (set_title) @@ -49,7 +49,7 @@ def construct_prompt [] { echo $title_bar # and last, but not least, let's print the prompt - echo $the_prompt | str join + echo $the_prompt | str collect ## put this in your config.toml # prompt = "construct_prompt" @@ -73,7 +73,7 @@ def home_abbrev [] { # Get Git Info custom commands def git_br [] { - $"(ansi gb)(pwd)(ansi reset)(char lparen)(ansi cb)(do -i { git rev-parse --abbrev-ref HEAD } | str trim -c (char nl) | str join)(ansi reset)(char rparen)(char newline)(ansi yb)(date now | date format '%m/%d/%Y %I:%M:%S%.3f %p')(ansi reset)¯\\_(char lparen)ツ)_/¯(char prompt) " + $"(ansi gb)(pwd)(ansi reset)(char lparen)(ansi cb)(do -i { git rev-parse --abbrev-ref HEAD } | str trim -c (char nl) | str collect)(ansi reset)(char rparen)(char newline)(ansi yb)(date now | date format '%m/%d/%Y %I:%M:%S%.3f %p')(ansi reset)¯\\_(char lparen)ツ)_/¯(char prompt) " } # Set Title String custom commands @@ -83,15 +83,15 @@ def set_title_str [str-arg] { } # def get_abbrev_pwd_win [] { -# echo [(pwd | split row '\' | first (pwd | split row '\' | length | each { $it - 1} ) | str substring '0,1' | format '{$it}/' | append (pwd | split row '\' | last ) | str join)] | str join +# echo [(pwd | split row '\' | first (pwd | split row '\' | length | each { $it - 1} ) | str substring '0,1' | format '{$it}/' | append (pwd | split row '\' | last ) | str collect)] | str collect # } def get_abbrev_pwd_lin [] { - # echo [(pwd | split row '/' | first (pwd | split row '/' | length | each { $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append (pwd | split row '/' | last ) | str join)] | str join - echo [(home_abbrev | split row '/' | first (home_abbrev | split row '/' | length | each { $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append (home_abbrev | split row '/' | last ) | str join)] | str join + # echo [(pwd | split row '/' | first (pwd | split row '/' | length | each { $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append (pwd | split row '/' | last ) | str collect)] | str collect + echo [(home_abbrev | split row '/' | first (home_abbrev | split row '/' | length | each { $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append (home_abbrev | split row '/' | last ) | str collect)] | str collect } def set_title [] { - set_title_str (build-string (get_abbrev_pwd_lin) ' ' (term size -w) 'x' (term size -t) | str join) + set_title_str (build-string (get_abbrev_pwd_lin) ' ' (term size -w) 'x' (term size -t) | str collect) } def create_second_line [] { build-string (ansi gb) (char -u "2514") (char -u "2500") ' $ ' (ansi cb) (char prompt) (ansi reset) diff --git a/before_v0.60/stdlib_candidate/nu_style.nu b/before_v0.60/stdlib_candidate/nu_style.nu index e57cfabc7..cfaf4b873 100644 --- a/before_v0.60/stdlib_candidate/nu_style.nu +++ b/before_v0.60/stdlib_candidate/nu_style.nu @@ -2,7 +2,7 @@ # found here https://github.com/PowerShell/PowerShell/blob/5f3dd938b792e1a395fd011ac1461246db7c0e1f/src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs # Example Usage -# echo (fg_blue) Darren (relet) ' ' Schroeder | str join +# echo (fg_blue) Darren (relet) ' ' Schroeder | str collect # More examples in the short_list.nu script alias fmt_error = ansi -e '31;1m' @@ -29,7 +29,7 @@ alias strikethrough_off = ansi -e '29m' alias strikethrough_on = ansi -e '9m' # this doesn't work right. i need to have an (ansi escape) defined but i don't think there is one -#def format_hyperlink [link text] {echo [(ansi -o '8;;') $link '\' $text (ansi -o '8;;') '\'] | str join } +#def format_hyperlink [link text] {echo [(ansi -o '8;;') $link '\' $text (ansi -o '8;;') '\'] | str collect } alias fg_black = ansi -e '30m' alias fg_red = ansi -e '31m' @@ -59,7 +59,7 @@ def fg_from_rgb [ green:int # green component 0-255 blue:int # blue component 0-255 ] { - echo [(ansi -e '38;2;') $red ';' $green ';' $blue 'm'] | str join + echo [(ansi -e '38;2;') $red ';' $green ';' $blue 'm'] | str collect } alias bg_black = ansi -e '40m' diff --git a/before_v0.60/stdlib_candidate/print.nu b/before_v0.60/stdlib_candidate/print.nu index 376af1ff1..6e1ac07fa 100644 --- a/before_v0.60/stdlib_candidate/print.nu +++ b/before_v0.60/stdlib_candidate/print.nu @@ -16,7 +16,7 @@ def print [ $param.item } } - } | into string | str join + } | into string | str collect } # > print 1 2 3 "four" -s '--' @@ -26,7 +26,7 @@ def print [ # 123four # An alternate print command that concatenates arguments together with an optional separator. -# This one uses str join instead of build-string. +# This one uses str collect instead of build-string. # By default there will be no newline def print2 [ --separator(-s):any # Optional separator (not yet flagged as optional?) @@ -35,9 +35,9 @@ def print2 [ let is_empty = ($separator | empty?) let num_of_rest = ($rest | length) if $is_empty { - $rest | into string | str join + $rest | into string | str collect } { - $rest | into string | str join $separator + $rest | into string | str collect $separator } } @@ -60,7 +60,7 @@ def print3 [ #log 'sep is empty' if (echo $param.item | length) > 1 and $flat { #log 'flatten please' - let flatter = ($param.item | flatten | into string | str join) + let flatter = ($param.item | flatten | into string | str collect) $flatter } { #log 'no flat' @@ -69,19 +69,19 @@ def print3 [ } { if $num_of_rest > ($param.index + 1) { if ($param.item | length) > 1 and $flat { - let flatter = ($param.item | flatten | into string | str join $separator) + let flatter = ($param.item | flatten | into string | str collect $separator) $"($flatter)($separator)" } { $"($param.item)($separator)" } } { if ($param.item | length) > 1 and $flat { - let flatter = ($param.item | flatten | into string | str join $separator) + let flatter = ($param.item | flatten | into string | str collect $separator) $flatter } { $param.item } } } - } | str join + } | str collect } diff --git a/before_v0.60/virtual_environments/conda.nu b/before_v0.60/virtual_environments/conda.nu index ce3eae2b8..7e8740231 100644 --- a/before_v0.60/virtual_environments/conda.nu +++ b/before_v0.60/virtual_environments/conda.nu @@ -2,7 +2,7 @@ def conda-env [env-name] { let conda-info = (conda info --envs --json | from json) let suffix = (if $env-name == "base" {""} {(["envs" $env-name] | path join)}) let env-dir = ([$conda-info.root_prefix $suffix] | path join) - let old-path = ($nu.path | str join (path-sep)) + let old-path = ($nu.path | str collect (path-sep)) let new-path = (if (windows?) { (conda-create-path-windows $env-dir) } { (conda-create-path-unix $env-dir) }) let new-env = [[name, value]; [CONDA_DEFAULT_ENV $env-name] @@ -24,7 +24,7 @@ def conda-create-path-windows [env-dir] { ([$env-dir "Library" "bin"] | path join) ([$env-dir "Library" "usr" "bin"] | path join) ] - let new-path = ([$env-path $nu.path] | flatten | str join (path-sep)) + let new-path = ([$env-path $nu.path] | flatten | str collect (path-sep)) [[name, value]; [Path $new-path]] } @@ -32,7 +32,7 @@ def conda-create-path-unix [env-dir] { let env-path = [ ([$env-dir "bin"] | path join) ] - let new-path = ([$env-path $nu.path] | flatten | str join (path-sep)) + let new-path = ([$env-path $nu.path] | flatten | str collect (path-sep)) [[name, value]; [PATH $new-path]] } diff --git a/before_v0.60/virtual_environments/venv.nu b/before_v0.60/virtual_environments/venv.nu index dad0d6d7f..ba1ab81ff 100644 --- a/before_v0.60/virtual_environments/venv.nu +++ b/before_v0.60/virtual_environments/venv.nu @@ -1,7 +1,7 @@ def venv [venv-dir] { let venv-abs-dir = ($venv-dir | path expand) let venv-name = ($venv-abs-dir | path basename) - let old-path = ($nu.path | str join (path-sep)) + let old-path = ($nu.path | str collect (path-sep)) let new-path = (if (windows?) { (venv-path-windows $venv-abs-dir) } { (venv-path-unix $venv-abs-dir) }) let new-env = [[name, value]; [VENV_OLD_PATH $old-path] @@ -12,7 +12,7 @@ def venv [venv-dir] { def venv-path-unix [venv-dir] { let venv-path = ([$venv-dir "bin"] | path join) - let new-path = ($nu.path | prepend $venv-path | str join (path-sep)) + let new-path = ($nu.path | prepend $venv-path | str collect (path-sep)) [[name, value]; [PATH $new-path]] } @@ -20,7 +20,7 @@ def venv-path-windows [venv-dir] { # 1. Conda on Windows needs a few additional Path elements # 2. The path env var on Windows is called Path (not PATH) let venv-path = ([$venv-dir "Scripts"] | path join) - let new-path = ($nu.path | prepend $venv-path | str join (path-sep)) + let new-path = ($nu.path | prepend $venv-path | str collect (path-sep)) [[name, value]; [Path $new-path]] } From 77268e4945043ea4e4ac93dc9a3366db30c8a943 Mon Sep 17 00:00:00 2001 From: Auca Maillot Date: Sun, 21 Jul 2024 09:35:12 -0300 Subject: [PATCH 9/9] :bug: fix obtaining commands by wrong columns --- sourced/misc/cmd_stats.nu | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sourced/misc/cmd_stats.nu b/sourced/misc/cmd_stats.nu index deecb4366..1dbcbd9b1 100644 --- a/sourced/misc/cmd_stats.nu +++ b/sourced/misc/cmd_stats.nu @@ -1,18 +1,18 @@ -let builtin = (scope commands | where is_builtin == true | length) -let subcmd = (scope commands | where is_sub == true | length) -let plugin = (scope commands | where is_plugin == true | length) -let custom = (scope commands | where is_custom == true | length) -let keyword = (scope commands | where is_keyword == true | length) -let extern = (scope commands | where is_extern == true | length) -let total = (scope commands | length) +export def main [] { + let builtin = (scope commands | where type == "built-in" | length) + let external = (scope commands | where type == "external" | length) + let custom = (scope commands | where type == "custom" | length) + let keyword = (scope commands | where type == "keyword" | length) + let plugin = (scope commands | where type == "plugin" | length) + let total = (scope commands | length) -[ - [command_type count]; - [builtin $builtin] - [sub_command $subcmd] - [plugin $plugin] - [custom $custom] - [keyword $keyword] - [extern $extern] - [total_cmds $total] -] + [ + [command_type count]; + [builtin $builtin] + [external $external] + [custom $custom] + [keyword $keyword] + [plugin $plugin] + [total_cmds $total] + ] +} \ No newline at end of file