diff --git a/base16/base16.nu b/base16/base16.nu index c640635..27480df 100644 --- a/base16/base16.nu +++ b/base16/base16.nu @@ -9,8 +9,8 @@ # ...etc. # #base0f-hex # ``` -export def build-nu-config [base-txt: path] { - let b16 = (from-file $base-txt) +export def build-nu-config [base_txt: path] { + let b16 = (from-file $base_txt) { separator: $b16.base03 @@ -56,8 +56,8 @@ export def build-nu-config [base-txt: path] { # Generate Alacritty color config to be included in the main Alacritty config # # It injects the base16 colors into the Alacritty config template -export def build-alacritty-config [base-txt: path] { - let base16 = (from-file-table $base-txt) +export def build-alacritty-config [base_txt: path] { + let base16 = (from-file-table $base_txt) let template = ( open "~/.config/nushell/alacritty_colors.mustache" | decode utf-8 @@ -73,13 +73,13 @@ export def build-alacritty-config [base-txt: path] { } # Generate LS_COLORS value -export def build-lscolors [base-txt: path] { +export def build-lscolors [base_txt: path] { # TODO } # Show the current base16 colors -export def show [base-txt: path] { - from-file $base-txt | each { |it| +export def show [base_txt: path] { + from-file $base_txt | each { |it| { $it.column: $"(ansi -e { fg: ($it.value) bg: ($it.value) })($it.value)(ansi reset)" } } } @@ -92,51 +92,51 @@ export def new-wallpaper [] { } # Get base16 as a record from an input file -export def from-file [base-txt: path] { - let base16-lines = (open $base-txt | lines | where ($it | str length) > 0) +export def from-file [base_txt: path] { + let base16_lines = (open $base_txt | lines | where ($it | str length) > 0) { - base00 : $base16-lines.0 # Default Background - base01 : $base16-lines.1 # Lighter Background (Used for status bars, line number and folding marks) - base02 : $base16-lines.2 # Selection Background - base03 : $base16-lines.3 # Comments, Invisibles, Line Highlighting - base04 : $base16-lines.4 # Dark Foreground (Used for status bars) - base05 : $base16-lines.5 # Default Foreground, Caret, Delimiters, Operators - base06 : $base16-lines.6 # Light Foreground (Not often used) - base07 : $base16-lines.7 # Light Background (Not often used) - base08 : $base16-lines.8 # Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted - base09 : $base16-lines.9 # Integers, Boolean, Constants, XML Attributes, Markup Link Url - base0a : $base16-lines.10 # Classes, Markup Bold, Search Text Background - base0b : $base16-lines.11 # Strings, Inherited Class, Markup Code, Diff Inserted - base0c : $base16-lines.12 # Support, Regular Expressions, Escape Characters, Markup Quotes - base0d : $base16-lines.13 # Functions, Methods, Attribute IDs, Headings - base0e : $base16-lines.14 # Keywords, Storage, Selector, Markup Italic, Diff Changed - base0f : $base16-lines.15 # Deprecated, Opening/Closing Embedded Language Tags, e.g. + base00 : $base16_lines.0 # Default Background + base01 : $base16_lines.1 # Lighter Background (Used for status bars, line number and folding marks) + base02 : $base16_lines.2 # Selection Background + base03 : $base16_lines.3 # Comments, Invisibles, Line Highlighting + base04 : $base16_lines.4 # Dark Foreground (Used for status bars) + base05 : $base16_lines.5 # Default Foreground, Caret, Delimiters, Operators + base06 : $base16_lines.6 # Light Foreground (Not often used) + base07 : $base16_lines.7 # Light Background (Not often used) + base08 : $base16_lines.8 # Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted + base09 : $base16_lines.9 # Integers, Boolean, Constants, XML Attributes, Markup Link Url + base0a : $base16_lines.10 # Classes, Markup Bold, Search Text Background + base0b : $base16_lines.11 # Strings, Inherited Class, Markup Code, Diff Inserted + base0c : $base16_lines.12 # Support, Regular Expressions, Escape Characters, Markup Quotes + base0d : $base16_lines.13 # Functions, Methods, Attribute IDs, Headings + base0e : $base16_lines.14 # Keywords, Storage, Selector, Markup Italic, Diff Changed + base0f : $base16_lines.15 # Deprecated, Opening/Closing Embedded Language Tags, e.g. } } # Get base16 as a table from an input file -export def from-file-table [base-txt: path] { - let base16-lines = (open $base-txt | lines | where ($it | str length) > 0) +export def from-file-table [base_txt: path] { + let base16_lines = (open $base_txt | lines | where ($it | str length) > 0) [ [ name color ]; - [ base00 $base16-lines.0 ] # Default Background - [ base01 $base16-lines.1 ] # Lighter Background (Used for status bars, line number and folding marks) - [ base02 $base16-lines.2 ] # Selection Background - [ base03 $base16-lines.3 ] # Comments, Invisibles, Line Highlighting - [ base04 $base16-lines.4 ] # Dark Foreground (Used for status bars) - [ base05 $base16-lines.5 ] # Default Foreground, Caret, Delimiters, Operators - [ base06 $base16-lines.6 ] # Light Foreground (Not often used) - [ base07 $base16-lines.7 ] # Light Background (Not often used) - [ base08 $base16-lines.8 ] # Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted - [ base09 $base16-lines.9 ] # Integers, Boolean, Constants, XML Attributes, Markup Link Url - [ base0a $base16-lines.10 ] # Classes, Markup Bold, Search Text Background - [ base0b $base16-lines.11 ] # Strings, Inherited Class, Markup Code, Diff Inserted - [ base0c $base16-lines.12 ] # Support, Regular Expressions, Escape Characters, Markup Quotes - [ base0d $base16-lines.13 ] # Functions, Methods, Attribute IDs, Headings - [ base0e $base16-lines.14 ] # Keywords, Storage, Selector, Markup Italic, Diff Changed - [ base0f $base16-lines.15 ] # Deprecated, Opening/Closing Embedded Language Tags, e.g. + [ base00 $base16_lines.0 ] # Default Background + [ base01 $base16_lines.1 ] # Lighter Background (Used for status bars, line number and folding marks) + [ base02 $base16_lines.2 ] # Selection Background + [ base03 $base16_lines.3 ] # Comments, Invisibles, Line Highlighting + [ base04 $base16_lines.4 ] # Dark Foreground (Used for status bars) + [ base05 $base16_lines.5 ] # Default Foreground, Caret, Delimiters, Operators + [ base06 $base16_lines.6 ] # Light Foreground (Not often used) + [ base07 $base16_lines.7 ] # Light Background (Not often used) + [ base08 $base16_lines.8 ] # Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted + [ base09 $base16_lines.9 ] # Integers, Boolean, Constants, XML Attributes, Markup Link Url + [ base0a $base16_lines.10 ] # Classes, Markup Bold, Search Text Background + [ base0b $base16_lines.11 ] # Strings, Inherited Class, Markup Code, Diff Inserted + [ base0c $base16_lines.12 ] # Support, Regular Expressions, Escape Characters, Markup Quotes + [ base0d $base16_lines.13 ] # Functions, Methods, Attribute IDs, Headings + [ base0e $base16_lines.14 ] # Keywords, Storage, Selector, Markup Italic, Diff Changed + [ base0f $base16_lines.15 ] # Deprecated, Opening/Closing Embedded Language Tags, e.g. ] } diff --git a/coloring/256_color_testpattern.nu b/coloring/256_color_testpattern.nu index 8d6887d..255118f 100644 --- a/coloring/256_color_testpattern.nu +++ b/coloring/256_color_testpattern.nu @@ -50,13 +50,13 @@ def print_run [start:int, amount:int] { } | append " " | str collect } -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 collect } | str collect } | str collect diff --git a/custom-completions/auto-generate/parse-fish.nu b/custom-completions/auto-generate/parse-fish.nu index c129cde..cb7e4d1 100644 --- a/custom-completions/auto-generate/parse-fish.nu +++ b/custom-completions/auto-generate/parse-fish.nu @@ -12,8 +12,8 @@ def build-completions-from-pwd [] { } # build a completion form a .fish file and generate a .nu file -def build-completion [fish-file: path, nu-file: path] { - open $fish-file | parse-fish | make-commands-completion | str collect "\n\n" | save $nu-file +def build-completion [fish_file: path, nu_file: path] { + open $fish_file | parse-fish | make-commands-completion | str collect "\n\n" | save $nu_file } # parse a .fish file based on autogenerated complete syntax @@ -38,15 +38,15 @@ def parse-fish [] { # tokenize each line of the fish file into a list of tokens # make use of detect columns -n which with one like properly tokenizers arguments including across quotes def tokenize-complete-lines [] { - lines - | each { |line| + lines + | each { |line| $line - | where $line starts-with complete + | where $line starts-with complete | str replace -a "\\\\'" "" # remove escaped quotes ' which break detect columns | str replace -a "-f " "" # remove -f which is a boolean flag we don't support yet - | detect columns -n + | detect columns -n | transpose -i tokens # turn columns into items, each is a token - } + } | where ($it | length) > 0 # remove any empty lines | get tokens # get the list of tokens } @@ -55,10 +55,10 @@ def tokenize-complete-lines [] { def pair-args [] { where $it != complete # drop complete command as we don't need it | window 2 -s 2 # group by ordered pairs, using window 2 -s 2 instead of group 2 to automatically drop any left overs - | each { |pair| + | each { |pair| [ {$"($pair.0 | str trim -c '-')": ($pair.1 | unquote)} # turn into a [{ :}] removing quotes - ] + ] } | reduce { |it, acc| $acc | merge { $it }} # merge the list of records into one big record } @@ -95,7 +95,7 @@ def make-subcommands-completion [parents: list] { | transpose name args # turn it into a table of name to arguments | each {|subcommand| build-string ( - if ('d' in ($subcommand.args | columns)) && ($subcommand.args.d != "") { + if ('d' in ($subcommand.args | columns)) && ($subcommand.args.d != "") { build-string "# " ($subcommand.args.d.0) "\n" # (sub)command description }) "extern " $quote ($parents | str collect " ") ( if $subcommand.name != "" { @@ -108,7 +108,7 @@ def make-subcommands-completion [parents: list] { } else { where ($it.n == "__fish_use_subcommand") && ($it.a == "") # for root command -> any where n == __fish_use_subcommand and a is empty. otherwise a means a subcommand } - } else { + } else { $fishes # catch all } | build-flags @@ -119,11 +119,11 @@ def make-subcommands-completion [parents: list] { # build the list of flag string in nu syntax def build-flags [] { - each { |subargs| - if ('l' in ($subargs | columns)) && ($subargs.l != "") { + each { |subargs| + if ('l' in ($subargs | columns)) && ($subargs.l != "") { build-string "\t--" $subargs.l (build-string - (if ('s' in ($subargs | columns)) && ($subargs.s != "") { - build-string "(-" $subargs.s ")" + (if ('s' in ($subargs | columns)) && ($subargs.s != "") { + build-string "(-" $subargs.s ")" }) (if ('d' in ($subargs | columns)) && ($subargs.d != "") { build-string "\t\t\t\t\t# " $subargs.d }) diff --git a/custom-completions/auto-generate/parse-help.nu b/custom-completions/auto-generate/parse-help.nu index 7c29c44..cd8e6d8 100644 --- a/custom-completions/auto-generate/parse-help.nu +++ b/custom-completions/auto-generate/parse-help.nu @@ -7,10 +7,10 @@ def parse-help [] { } # takes a table of parsed help commands in format [short? long format? description] -def make-completion [command-name: string] { - build-string "extern \"" $command-name "\" [\n" ($in | each { |it| +def make-completion [command_name: string] { + build-string "extern \"" $command_name "\" [\n" ($in | each { |it| build-string "\t--" $it.long (if ($it.short | empty?) == false { - build-string "(-" $it.short ")" + build-string "(-" $it.short ")" }) (if ($it.description | empty?) == false { build-string "\t\t# " $it.description }) @@ -33,16 +33,16 @@ module tests { ['' config 'KEY=VALUE' 'Override a configuration value (unstable)'] [h help '' 'Print help information'] ] - + let result = (cargo --help | parse-help) - + if $result == $expect { "passed" } else { $result } } - + def test-nu [] { let expect = [ [short long format description]; @@ -59,16 +59,16 @@ module tests { ['' log-level 'String' 'log level for performance logs'] ['t' threads 'Int' 'threads to use for parallel commands'] ] - + let result = (nu --help | parse-help) - + if $result == $expect { "passed" } else { $result } } - + export def run-tests [] { [ [test result]; diff --git a/custom-completions/yarn/yarn-completion.nu b/custom-completions/yarn/yarn-completion.nu index 9eca044..bc1909c 100644 --- a/custom-completions/yarn/yarn-completion.nu +++ b/custom-completions/yarn/yarn-completion.nu @@ -266,7 +266,7 @@ export extern "yarn npm logout" [ export extern "yarn npm publish" [ --access: string # The access level of the published package (public or restricted) --tag: string # The tag on the registry that the package should be attached to - --tolerate-republish # Warn and exit when republishing an already existing version of a package + --tolerate-republish # Warn and exit when republishing an already existing version of a package --opt: string # The OTP token to use with the command ] @@ -327,7 +327,7 @@ export extern "yarn plugin" [] export extern "yarn plugin import from sources" [ --path: string # The path where the repository should be cloned to --repository: string # The repository that should be cloned - --branch: string # The branch of the repository that should be cloned + --branch: string # The branch of the repository that should be cloned --no-minify # Build a plugin for development (debugging) - non-minified and non-mangled --force(-f) # Always clone the repository instead of trying to fetch the latest commits plugin: string @@ -419,7 +419,7 @@ export extern "yarn set resolution" [ export extern "yarn set version from sources" [ --path: string # The path where the repository should be cloned to --repository: string # The repository that should be cloned - --branch: string # The branch of the repository that should be cloned + --branch: string # The branch of the repository that should be cloned --no-minify # Build a plugin for development (debugging) - non-minified and non-mangled --force(-f) # Always clone the repository instead of trying to fetch the latest commits --skip-plugins # Skip updating the contrib plugins @@ -506,7 +506,7 @@ def "nu-complete yarn why" [] { # Display the reason why a package is needed. export extern "yarn why" [ - --recursive(-R) # List, for each workspace, what are all the paths that lead to the dependency + --recursive(-R) # List, for each workspace, what are all the paths that lead to the dependency --json # Format the output as an NDJSON stream --peers # Also print the peer dependencies that match the specified name package: string@"nu-complete yarn why" diff --git a/example-config/init.nu b/example-config/init.nu index e46cebd..704c3f7 100644 --- a/example-config/init.nu +++ b/example-config/init.nu @@ -30,7 +30,7 @@ export env SHOW_USR { "true" } # prompt export env PROMPT_COMMAND { "build-prompt" } export def build-prompt [] { - let usr-str = (if $env.SHOW_USR == "true" { + let usr_str = (if $env.SHOW_USR == "true" { [ $env.USER '@' @@ -41,11 +41,11 @@ export def build-prompt [] { '' }) - let pwd-str = (if (pwd | str starts-with $env.HOME).0 { + let pwd_str = (if (pwd | str starts-with $env.HOME).0 { (pwd | str replace $env.HOME '~' | str trim).0 } else { pwd }) - [ $usr-str $pwd-str ' ' ] | str collect + [ $usr_str $pwd_str ' ' ] | str collect } diff --git a/fehbg.nu b/fehbg.nu index 7cb34f3..09568b6 100755 --- a/fehbg.nu +++ b/fehbg.nu @@ -25,16 +25,16 @@ # * imagemagick # Path definitions -let img-dir = $env.WALLPAPER_DIR -let tmp-image = ([ $env.TMP_DIR "wallpaper.jpg" ] | path join) +let img_dir = $env.WALLPAPER_DIR +let tmp_image = ([ $env.TMP_DIR "wallpaper.jpg" ] | path join) # Monitor resolution -let resolution-y = 1440 -let res-str = ($"x($resolution-y)") +let resolution_y = 1440 +let res_str = ($"x($resolution-y)") # Position of the caption -let pos-x = 5 -let pos-y = (0.995 * $resolution-y | into int) +let pos_x = 5 +let pos_y = (0.995 * $resolution_y | into int) # Select random item from input def select-random [] { @@ -50,20 +50,20 @@ def list-images [dir: path] { } # Set the caption text (just filename for now) -def caption [img-f: string] { - echo $img-f +def caption [img_f: string] { + echo $img_f } # Build the argument for the '-draw' command of the 'convert' utility -def draw-str [img-f: string] { - $"text ($pos-x), ($pos-y) (char dq)(caption $img-f)(char dq) " +def draw-str [img_f: string] { + $"text ($pos_x), ($pos_y) (char dq)(caption $img_f)(char dq) " } # Select random image -let img-name = (list-images $img-dir | select-random | get name) # TODO: change the env var to $img-dir +let img_name = (list-images $img_dir | select-random | get name) # TODO: change the env var to $img-dir # Resize the image to the monitor height, draw the caption and save it -convert -resize $res-str -pointsize 15 -fill 'rgb(255,200,150)' -draw (draw-str $img-name) $img-name $tmp-image +convert -resize $res_str -pointsize 15 -fill 'rgb(255,200,150)' -draw (draw-str $img_name) $img_name $tmp_image # Set the created image as a background feh --no-fehbg --bg-max $tmp-image diff --git a/gitlab/gitlab.nu b/gitlab/gitlab.nu index ab494ea..13967f4 100755 --- a/gitlab/gitlab.nu +++ b/gitlab/gitlab.nu @@ -17,8 +17,8 @@ def main [ --branch: string # branch to scan ] { # /projects endpoint can return up to $page_size items which is why we need multiple calls to retrieve full list - let num-of-pages = ((call-gitlab --query 'page=1&per_page=1&order_by=id&simple=true'|get id.0|into int) / $page_size|math round) - seq 1 $num-of-pages|par-each {|page| + let num_of_pages = ((call-gitlab --query 'page=1&per_page=1&order_by=id&simple=true'|get id.0|into int) / $page_size|math round) + seq 1 $num_of_pages|par-each {|page| call-gitlab --query $"page=($page)&per_page=($page_size)"|select name id } |flatten diff --git a/network/remoting/remoting.nu b/network/remoting/remoting.nu index 2b5f9f0..1235e83 100644 --- a/network/remoting/remoting.nu +++ b/network/remoting/remoting.nu @@ -34,7 +34,7 @@ def get-url [ if 'ip' in ($host|columns) { echo $"ssh://($host.username)@($host.ip):($host.port)" } else { - echo $"ssh://($host.username)@($host.name).($host.domain):($host.port)" + echo $"ssh://($host.username)@($host.name).($host.domain):($host.port)" } } @@ -58,15 +58,15 @@ export def ssh [ # Connect over ssh to one of predefined hosts, execute nushell script with arguments passed from the host export def "ssh script" [ hostname: string@"nu-complete nu" # name of the host you want to connect to - script: string@"nu-complete scripts" # name of the script + script: string@"nu-complete scripts" # name of the 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) { let host = (hosts|where name == $hostname|get 0) - let full-command = (build-string (view-source $script) '; ' $script ' ' ($args|str collect ' ') '|to json -r') - ^ssh (get-url $host) ($full-command)|from json + let full_command = (build-string (view-source $script) '; ' $script ' ' ($args|str collect ' ') '|to json -r') + ^ssh (get-url $host) ($full_command)|from json } else { error make { diff --git a/prompt/panache-git.nu b/prompt/panache-git.nu index 80f9114..b1533eb 100644 --- a/prompt/panache-git.nu +++ b/prompt/panache-git.nu @@ -471,6 +471,6 @@ module panache-plumbing { # An opinionated Git prompt for Nushell, styled after posh-git def panache-git [] { use panache-plumbing * - let prompt = ($'(panache-git dir) (panache-git styled)' | str trim) + let prompt = ($'(panache_git dir) (panache-git styled)' | str trim) $'($prompt)> ' }