nushell; update to 0.94 and clean up of config
664b9cbf86d11e6922caa272c1f432000d7eaaa6
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: a2fa48528001
bugabingas dorkfiles
664b9cbf86d11e6922caa272c1f432000d7eaaa6
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+596 / −651 text lines · all files grouped into 32 bars
+1 / −0 text lines
+7 / −4 text lines
+3 / −0 text lines
+7 / −7 text lines
"indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" }, "lazy.nvim": { "branch": "main", "commit": "24fa2a97085ca8a7220b5b078916f81e316036fd" }, "lazy.nvim": { "branch": "main", "commit": "eab487c2520f0fe9e54eb5e3ea0606e20512492e" }, "nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" }, "nvim-genghis": { "branch": "main", "commit": "7ed82d0d0513946bbc678f326e5750c79a942351" }, "nvim-genghis": { "branch": "main", "commit": "6c3a123dcd355a33f5dd624b0a841e8f88c11f8d" }, "nvim-lint": { "branch": "master", "commit": "e19842a05aae484957ad20710444757bc0a61d63" }, "nvim-lint": { "branch": "master", "commit": "2f90fe977ef21db3bf3b7a1ceaf4a1e3aafb2b26" }, "nvim-lsp-file-operations": { "branch": "master", "commit": "223aca86b737dc66e9c51ebcda8788a8d9cc6cf2" }, "nvim-neoclip.lua": { "branch": "main", "commit": "9b02a625dfa22499089458554be86171a1dfe8b1" }, "nvim-surround": { "branch": "main", "commit": "fa5b365e847909df35cea184e13b7b811f346cda" }, "nvim-surround": { "branch": "main", "commit": "f1f0699a1d49f28e607ffa4361f1bbe757ac5ebc" }, "nvim-treesitter": { "branch": "master", "commit": "5c924407cf110e9da4f3ba02ffed127b4198ad89" }, "nvim-treesitter": { "branch": "master", "commit": "979beffc1a86e7ba19bd6535c0370d8e1aaaad3c" }, "nvim-treesitter-context": { "branch": "master", "commit": "f62bfe19e0fbc13ae95649dfb3cf22f4ff85b683" }, "nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "3557e41418b4a6c5b85d5d64abe94c9c50fa9b14" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "fd41b7ccc5490a3a99c734d1ee418b68d06c48a9" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, "nvim-web-devicons": { "branch": "master", "commit": "b77921fdc44833c994fdb389d658ccbce5490c16" }, "vim-startuptime": { "branch": "master", "commit": "ac2cccb5be617672add1f4f3c0a55ce99ba34e01" }, "vim-vscode-snippets": { "branch": "master", "commit": "812e60d1c648f889328761ec71daff09d1eb3177" }, "virt-column.nvim": { "branch": "master", "commit": "b62b4ef0774d19452d4ed18e473e824c7a756f2f" },+32 / −15 text lines
local download_plugin_into = function ( plugin_tarball_url, plugin_install_path )local download_plugin_into = function ( plugin_name, plugin_tarball_url, plugin_install_path ) vim.fn.mkdir( plugin_install_path, 'p' ) print(curl_handle, curl_handle, tar_handle, tar_pid) vim.print(tmp_dir) local extracted_dir = vim.fs.find( function(name, path) return name:find(plugin_name,0,true) end, { path = tmp_dir, type = 'directory', limit = 1 } ) vim.print(vim.inspect(extracted_dir)) assert(#extracted_dir ~= 0, 'No directory was found in tarball') assert(#extracted_dir == 1, 'Too many directories were found in tarball. Expected one!') -- the libuv way of getting files accross partitions is PITA local ok = vim.fn.rename(extracted_dir[1], plugin_install_path) vim.print(ok) assert(ok, string.format('Failed to move extracted plugin from %s to %s.', extracted_dir[1], plugin_install_path)) local plugin_install_path = vim.fs.normalize( vim.fs.joinpath( puck_root, plugin_name ) ) --TODO unused? local plugin_install_path = vim.fs.normalize( vim.fs.joinpath( puck_root, plugin_name ) ) local plugin_already_exists = plugin_install_path_stat and plugin_install_path_stat.type == 'directory'deleted file mode 100644+0 / −137 text lines
def "complete svn subcommands" [] { ^svn help | lines | skip until { | line | $line | str starts-with "Available subcommands:" } | skip 1 | each { |line| $line | str trim } | take until { |line| $line | empty? } | split column " " | get column1}# TODO: parse xml outputdef "complete svn add paths" [] { ^svn status --depth infinity | lines | parse "{mode} {file}" | str trim | where mode == ? | get file}def "complete svn revert paths" [] { ^svn status --depth infinity | lines | parse "{mode} {file}" | where mode == M | str trim | get file}def "complete svn depth" [] { ['empty', 'files', 'immediates', 'infinity'] }def "complete svn changelists" [] { ^svn status --depth infinity | lines | parse "--- Changelist '{changelist}':" | get --ignore-errors changelist}# FIXME: This is commented out in order to leave unexterne'd commands be.# # Subversion is a tool for version control.# For additional information, see http://subversion.apache.org/#export extern svn [ #subcommand?: string@"complete svn subcommands" # for help on a specific subcommand. #--version # to see the program version and RA modules #--quiet # to see just the version number #--verbose # to see dependency versions as well#]# help (?, h): Describe the usage of this program or its subcommands.# usage: help [SUBCOMMAND...]export extern "svn help" [ subcommand?: string@"complete svn subcommands" # for help on a specific subcommand. --verbose(-v) # also show experimental subcommands and options]# FIXME:# SVN has short options with double dashes: --changelist(--cl).# This is not allowed in nu.# FIXME:# Multiline doccomments will be rendered without the newlines.# Print the status of working copy files and directories.export extern "svn status" [ ...paths: path # PATHs --show-updates(-u) # display update information --verbose(-v) # print extra information --depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity') --revision(-r): string # ARG (some commands also take ARG1:ARG2 range) # A revision argument can be one of: # NUMBER revision number # '{' DATE '}' revision at start of the date # 'HEAD' latest in repository # 'BASE' base rev of item's working copy # 'COMMITTED' last commit at or before BASE # 'PREV' revision just before COMMITTED --quiet(-q) # don't print unversioned items --no-ignore # disregard default and svn:ignore and svn:global-ignores property ignores --incremental # give output suitable for concatenation --xml # output in XML --ignore-externals # ignore externals definitions --changelist:string@"complete svn changelists" # operate only on members of changelist ARG]# FIXME: https://github.com/nushell/nushell/issues/5012# rest parameters do not play well with completions yet# the `paths` parameter should be `...paths`# Put new files and directories under version control.export extern "svn add" [ paths: path@"complete svn add paths" # unversioned PATHs for addition --targets: path # pass contents of file ARG as additional args --non-recursive(-N) # obsolete; same as --depth=empty --depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity') --quiet(-q) # print nothing, or only summary information --force # ignore already versioned paths --no-ignore # disregard default and svn:ignore and svn:global-ignores property ignores --auto-props # enable automatic properties --no-auto-props # disable automatic properties --parents # add intermediate parents]# Restore pristine working copy state (undo local changes).export extern "svn revert" [ paths: path@"complete svn revert paths" --targets: path # pass contents of file as additional args --recursive(-R) # descend recursively, same as --depth=infinity --depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity') --quiet(-q) # print nothing, or only summary information --changelist: string@"complete svn changelists" # operate only on members of changelist ARG --remove-added # reverting an added item will remove it from disk]# FIXME# SVN uses aliases for subcommands. E.g. `co` for `checkout`.# How to express that with nu extern commands?# Check out a working copy from a repository.export extern "svn checkout" [ ...url_with_rev:string # source path: path # destination --revision(-r) # ARG (some commands also take ARG1:ARG2 range) # A revision argument can be one of: # NUMBER revision number # '{' DATE '}' revision at start of the date # 'HEAD' latest in repository # 'BASE' base rev of item's working copy # 'COMMITTED' last commit at or before BASE # 'PREV' revision just before COMMITTED --quiet(-q) # print nothing, or only summary information --depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity') --force # force operation to run --ignore-externals # ignore externals definitions]No final newline+16 / −82 text lines
# Nushell Config Fileuse modules/table.nu *use modules/os.nu *use modules/prompt.nu *use modules/aliases.nu *use modules/todo.nuuse modules/openssl.nu *use modules/md.nuuse external_completer.nulet default_theme = { # color for nushell primitives separator: white leading_trailing_space_bg: { attr: n } # no fg, no bg, attr non effectively turns this off header: green_bold empty: blue bool: white int: white filesize: white duration: white date: white range: white float: white string: white nothing: white binary: white cellpath: white row_index: green_bold record: white list: white block: white hints: dark_gray # shapes are used to change the cli syntax highlighting shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b} shape_binary: purple_bold shape_bool: light_cyan shape_int: purple_bold shape_float: purple_bold shape_range: yellow_bold shape_internalcall: cyan_bold shape_external: cyan shape_externalarg: green_bold shape_literal: blue shape_operator: yellow shape_signature: green_bold shape_string: green shape_string_interpolation: cyan_bold shape_datetime: cyan_bold shape_list: cyan_bold shape_table: blue_bold shape_record: cyan_bold shape_block: blue_bold shape_filepath: cyan shape_globpattern: cyan_bold shape_variable: purple shape_flag: blue_bold shape_custom: green shape_nothing: light_cyan}# The default config record. This is where much of your global configuration is setup. mode: light # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other } ls: { use_ls_colors: true clickable_links: true mode: none+15 / −2 text lines
$env.DOTFILES = ( $env.WORKSPACE | path join 'dotfiles' )$env.NU_LIB_DIRS = [ ($nu.default-config-dir | path join 'scripts')]# generate aliases here and now, so that we can apply conditions.# later, in config.nu, the evaluated aliases will be sourcedsource ($nu.default-config-dir | path join 'gen-aliases.nu')# generate zoxide hooks for sourcing later onif not (which zoxide | is-empty) { zoxide init nushell | save -f ($nu.default-config-dir | path join 'zoxide.nu')}+38 / −13 text lines
aka browse firefoxaka vim nvimaka code nvimaka edit nvim '--clean'aka ed nvim '--clean'aka vi nvim '--clean'# TODO write bak command# aka backup bakaka userctl systemctl '--user'# https://gist.github.com/mullnerz/9fff80593d6b442d5c1baka archive wget "-mpck" "--html-extension" '--user-agent=""' "-e" "robots=off" "--wait" 1 "-P" .# CUSTOM LITTLE JAVA COMMANDSaka aes java ($env.DOTFILES + /tools/ + aes.java)aka download java ($env.DOTFILES + /tools/ + download.java)aka download_jar java ($env.DOTFILES + /tools/ + download_jar.java)new file mode 100644+12 / −0 text lines
use prompt.nu *use commands.nu *use todo.nuuse ssh-keygen-ed.nuuse md.nuuse start.nusource ($nu.default-config-dir | path join 'aliases.nu')# must be done, after defining config, since zoxide mutates it# this will fail if zoxide is not installed yetsource ($nu.default-config-dir | path join "zoxide.nu")deleted file mode 100644+0 / −41 text lines
# Semantic aliases
export alias show = bat
export def list [] { ls --all --long --du --mime-type | where type == dir | append (ls --all --long --du --mime-type | where type != dir) }
export alias walk = yazi
export alias browse = firefox
export alias vim = nvim
export alias edit = nvim --clean
# TODO ewrite bak command
export alias backup = bak
export alias userctl = systemctl --user
# https://gist.github.com/mullnerz/9fff80593d6b442d5c1b
export alias archive = wget -mpck --html-extension --user-agent="" -e robots=off --wait 1 -P .
export def fkill [ query:string ] {
let pid = (^ps -ef | sed 1d | fzf -m --query $query | awk '{print $2}')
if not ($pid | is-empty) {
kill ($pid | into int )
}
}
export def --env yy [...args] {
let tmp = (mktemp -t "yazi-cwd.XXXXXX")
yazi ...$args --cwd-file $tmp
let cwd = (open $tmp)
if $cwd != "" and $cwd != $env.PWD {
cd $cwd
}
rm -fp $tmp
}
# TODO: HOST SPECIFIC ALIASES
# I do not see a way right now the have different aliases per host with nu.
# CUSTOM LITTLE JAVA COMMANDS
export alias aes = java ($env.DOTFILES + /tools/ + aes.java)
export alias download = java ($env.DOTFILES + /tools/ + download.java)
export alias download_jar = java ($env.DOTFILES + /tools/ + download_jar.java)
deleted file mode 100644+0 / −5 text lines
deleted file mode 100644+0 / −6 text lines
deleted file mode 100644+0 / −11 text lines
deleted file mode 100644+0 / −109 text lines
# Map of paths to icons.# These will be used to replace certain path segments in the prompt for example.# Order these paths for precedence.def icons [] { [ [ path icon ]; [ "/home/oli/Notes" (char -u "03C0") ] [ "/home/bugabinga/Notes" (char -u "03C0") ] [ "C:\\Users\\okr\\Notizen" (char -u "03C0") ] [ "/home/oli/Workspace" (char -u "03BB") ] [ "/home/bugabinga/Workspace" (char -u "03BB") ] [ "C:\\Users\\okr\\Workspaces" (char -u "03BB") ] [ "/home/oli" (char home) ] [ "/home/bugabinga" (char home) ] [ "C:\\Users\\okr" (char home) ] ]}# Uses a special escape code to set the window title of the terminal emulator.# This will be ignored in terminal emulator, that do not support that escape code.# The title to be set is derived from the current working directory.# Special types of directories, e.g. HOME, get custom icons.def set-window-title [] { # Some terminals freeze, if they do not support this OSC if ($env | get -i TERM_PROGRAM) == WezTerm { # normalize path let pwd = ( $env.PWD | path expand ) let icon = if (icons | any { |icon| $icon.path == $pwd } ) { ( icons | where path == $pwd | get icon.0 ) } else { $"(char nf_folder1)" } echo ([ (ansi title) $icon " " ( $pwd | path basename ) (ansi reset) ] | str join) }}def prompt-git-branch [] {}def get_vcs_path [] { #normalize path let pwd = ($env.PWD | path expand) let svn_relative_cmd = ( do --ignore-errors { ^svn info --show-item relative-url --no-newline $pwd | complete } ) let svn_relative_path = if ( (not ($svn_relative_cmd | is-empty)) and ($svn_relative_cmd.exit_code == 0)) { $" 🐢 (char nf_branch) ($svn_relative_cmd.stdout)" } let git_branch_cmd = ( do -i { ^git rev-parse --abbrev-ref HEAD | complete } ) let git_path = if (not ($git_branch_cmd | is-empty) and ($git_branch_cmd.exit_code == 0)) { $" (char nf_git) (char nf_branch) ($git_branch_cmd.stdout | str trim -r)" } [ $svn_relative_path $git_path ] | str join}def create_left_prompt [] { set-window-title # normalize path let pwd = ($env.PWD | path expand) let pwd = ( (icons) | reduce --fold $pwd { |item, accumulator| $accumulator | str replace $item.path $item.icon }) let truncate_level = 5 let truncate_symbol = $"…(char path_sep)" let path_segment = if ($pwd | path split | length) >= $truncate_level { ($pwd | path dirname --num-levels 2 --replace $truncate_symbol ) } else { $pwd } let vcs_segment = (get_vcs_path) [ (ansi dark_gray) $path_segment (ansi reset) (ansi green) $vcs_segment (ansi reset) ] | str join}def create_right_prompt [] { let time_segment = ([ (date now | format date '%d.%m %R') ] | str join) let command_status_segment = if $env.LAST_EXIT_CODE == 0 { $" (char -u '2713') " } else { $"(ansi red) (char failed) (ansi reset)" } let command_duration_segment = if ( $env.CMD_DURATION_MS | into int) > 0 { $"($env.CMD_DURATION_MS)ms" | into duration } [ (ansi dark_gray_dimmed) $command_duration_segment (ansi reset) (ansi dark_gray) $command_status_segment (ansi reset) (ansi dark_gray) ( if (sys host).hostname == "x230" { (akku) } else { $time_segment }) (ansi reset) ] | str join}export-env { # Use nushell functions to define your right and left prompt $env.PROMPT_COMMAND = { || create_left_prompt } $env.PROMPT_COMMAND_RIGHT = { || create_right_prompt } # The prompt indicators are environmental variables that represent # the state of the prompt $env.PROMPT_INDICATOR = $"(ansi green) (char prompt) (ansi reset)" $env.PROMPT_INDICATOR_VI_INSERT = $"(ansi magenta) (char pipe) (ansi reset)" $env.PROMPT_INDICATOR_VI_NORMAL = $"(ansi magenta) (char prompt) (ansi reset)" $env.PROMPT_MULTILINE_INDICATOR = $"(ansi magenta) (char prompt)(char prompt) (ansi reset)"}deleted file mode 100644+0 / −48 text lines
export def "conflicts list" [] { fd --hidden --no-ignore sync-conflict $env.HOME | lines | filter { |path| not ($path =~ "/Trash/") }}export def "conflicts merge" [] { (conflicts list) | each { |conflict| merge ( to_original $conflict ) $conflict let input = ( input $"Merge successful? \((ansi pb)Y(ansi reset)/n\) \n" ) let sanitize = ( $input | str trim | str downcase | str substring 0..1 ) if ($sanitize | is-empty) or $sanitize == 'y' { rm --verbose --interactive $conflict } else { $conflict } }}export def "conflicts diff" [] { (conflicts list) | each { |conflict| diff ( to_original $conflict ) $conflict }}def parse-sync-conflict [] { parse -r '(?<filename>.*)\.sync-conflict-(?<date>.\d+)-(?<time>.\d+)-(?<id>\w+)\.?(?<extension>.*)?'}def to_original [ file: path ] { let conflict = ( $file | parse-sync-conflict ) mut filename = ($conflict | get filename.0) let extension = ($conflict | get extension.0) if not ($extension | is-empty) { $filename = $filename + '.' + $extension } $filename}def diff [ a: path, b: path ] { print $"diffing ($a) and ($b)" ^difft $a $b}def merge [ a: path, b: path ] { meld $a $b}deleted file mode 100644+0 / −10 text lines
# Check whether table in pipeline has a column with given nameexport def "has-column?" [ name: string # Name of the column to check for] { transpose | values | get 0 | any { |column| $column == $name }}# Flattens a table into a string separated by a single space character.export def to-string [] { flatten | into string | str join ' ' }deleted file mode 100644+0 / −11 text lines
# Render my To-Do file in the terminalexport def main [] { mdcat ($env.NOTES | path join "TODO.md") }# Open my To-Do file for editingexport def edit [] { hx ($env.NOTES | path join "TODO.md") }# Open a list of commands, that I would like to remember to useexport def commands [] { mdcat ($env.NOTES | path join "COMMANDS.md") }# Open the list of commands to remember for editing.export def "commands edit" [] { vim ($env.NOTES | path join "COMMANDS.md") }new file mode 100644+18 / −0 text lines
export def list [] { ls --all --long --du --mime-type | where type == dir | append (ls --all --long --du --mime-type | where type != dir) }export def fkill [ query:string ] { let pid = (^ps -ef | sed 1d | fzf -m --query $query | awk '{print $2}') if not ($pid | is-empty) { kill ($pid | into int ) }}export def --env yy [...args] { let tmp = (mktemp -t "yazi-cwd.XXXXXX") yazi ...$args --cwd-file $tmp let cwd = (open $tmp) if $cwd != "" and $cwd != $env.PWD { cd $cwd } rm -fp $tmp}new file mode 100644+36 / −0 text lines
export def main [] { let carapace_completer = {|spans: list<string>| carapace $spans.0 nushell ...$spans | from json | if ($in | default [] | where value =~ '^-.*ERR$' | is-empty) { $in } else { null } } let zoxide_completer = {|spans| $spans | skip 1 | zoxide query -l ...$in | lines | where {|x| $x != $env.PWD} } # This completer will use carapace by default let external_completer = {|spans| # https://github.com/nushell/nushell/issues/8483 let expanded_alias = scope aliases | where name == $spans.0 | get -i 0.expansion let spans = if $expanded_alias != null { $spans | skip 1 | prepend ($expanded_alias | split row ' ' | take 1) } else { $spans } match $spans.0 { # use zoxide completions for zoxide commands __zoxide_z | __zoxide_zi => $zoxide_completer _ => $carapace_completer } | do $in $spans } $external_completer}new file mode 100644+5 / −0 text lines
new file mode 100644+109 / −0 text lines
# Map of paths to icons.# These will be used to replace certain path segments in the prompt for example.# Order these paths for precedence.def icons [] { [ [ path icon ]; [ "/home/oli/Notes" (char -u "03C0") ] [ "/home/bugabinga/Notes" (char -u "03C0") ] [ "C:\\Users\\okr\\Notizen" (char -u "03C0") ] [ "/home/oli/Workspace" (char -u "03BB") ] [ "/home/bugabinga/Workspace" (char -u "03BB") ] [ "C:\\Users\\okr\\Workspaces" (char -u "03BB") ] [ "/home/oli" (char home) ] [ "/home/bugabinga" (char home) ] [ "C:\\Users\\okr" (char home) ] ]}# Uses a special escape code to set the window title of the terminal emulator.# This will be ignored in terminal emulator, that do not support that escape code.# The title to be set is derived from the current working directory.# Special types of directories, e.g. HOME, get custom icons.def set-window-title [] { # Some terminals freeze, if they do not support this OSC if ($env | get -i TERM_PROGRAM) == WezTerm { # normalize path let pwd = ( $env.PWD | path expand ) let icon = if (icons | any { |icon| $icon.path == $pwd } ) { ( icons | where path == $pwd | get icon.0 ) } else { $"(char nf_folder1)" } echo ([ (ansi title) $icon " " ( $pwd | path basename ) (ansi reset) ] | str join) }}def prompt-git-branch [] {}def get_vcs_path [] { #normalize path let pwd = ($env.PWD | path expand) let svn_relative_cmd = ( do --ignore-errors { ^svn info --show-item relative-url --no-newline $pwd | complete } ) let svn_relative_path = if ( (not ($svn_relative_cmd | is-empty)) and ($svn_relative_cmd.exit_code == 0)) { $" 🐢 (char nf_branch) ($svn_relative_cmd.stdout)" } let git_branch_cmd = ( do -i { ^git rev-parse --abbrev-ref HEAD | complete } ) let git_path = if (not ($git_branch_cmd | is-empty) and ($git_branch_cmd.exit_code == 0)) { $" (char nf_git) (char nf_branch) ($git_branch_cmd.stdout | str trim -r)" } [ $svn_relative_path $git_path ] | str join}def create_left_prompt [] { set-window-title # normalize path let pwd = ($env.PWD | path expand) let pwd = ( (icons) | reduce --fold $pwd { |item, accumulator| $accumulator | str replace $item.path $item.icon }) let truncate_level = 5 let truncate_symbol = $"…(char path_sep)" let path_segment = if ($pwd | path split | length) >= $truncate_level { ($pwd | path dirname --num-levels 2 --replace $truncate_symbol ) } else { $pwd } let vcs_segment = (get_vcs_path) [ (ansi dark_gray) $path_segment (ansi reset) (ansi green) $vcs_segment (ansi reset) ] | str join}def create_right_prompt [] { let time_segment = ([ (date now | format date '%d.%m %R') ] | str join) let command_status_segment = if $env.LAST_EXIT_CODE == 0 { $" (char -u '2713') " } else { $"(ansi red) (char failed) (ansi reset)" } let command_duration_segment = if ( $env.CMD_DURATION_MS | into int) > 0 { $"($env.CMD_DURATION_MS)ms" | into duration } [ (ansi dark_gray_dimmed) $command_duration_segment (ansi reset) (ansi dark_gray) $command_status_segment (ansi reset) (ansi dark_gray) ( if (sys host).hostname == "x230" { (akku) } else { $time_segment }) (ansi reset) ] | str join}export-env { # Use nushell functions to define your right and left prompt $env.PROMPT_COMMAND = { || create_left_prompt } $env.PROMPT_COMMAND_RIGHT = { || create_right_prompt } # The prompt indicators are environmental variables that represent # the state of the prompt $env.PROMPT_INDICATOR = $"(ansi green) (char prompt) (ansi reset)" $env.PROMPT_INDICATOR_VI_INSERT = $"(ansi magenta) (char pipe) (ansi reset)" $env.PROMPT_INDICATOR_VI_NORMAL = $"(ansi magenta) (char prompt) (ansi reset)" $env.PROMPT_MULTILINE_INDICATOR = $"(ansi magenta) (char prompt)(char prompt) (ansi reset)"}new file mode 100644+6 / −0 text lines
new file mode 100644+11 / −0 text lines
new file mode 100644+48 / −0 text lines
export def "conflicts list" [] { fd --hidden --no-ignore sync-conflict $env.HOME | lines | filter { |path| not ($path =~ "/Trash/") }}export def "conflicts merge" [] { (conflicts list) | each { |conflict| merge ( to_original $conflict ) $conflict let input = ( input $"Merge successful? \((ansi pb)Y(ansi reset)/n\) \n" ) let sanitize = ( $input | str trim | str downcase | str substring 0..1 ) if ($sanitize | is-empty) or $sanitize == 'y' { rm --verbose --interactive $conflict } else { $conflict } }}export def "conflicts diff" [] { (conflicts list) | each { |conflict| diff ( to_original $conflict ) $conflict }}def parse-sync-conflict [] { parse -r '(?<filename>.*)\.sync-conflict-(?<date>.\d+)-(?<time>.\d+)-(?<id>\w+)\.?(?<extension>.*)?'}def to_original [ file: path ] { let conflict = ( $file | parse-sync-conflict ) mut filename = ($conflict | get filename.0) let extension = ($conflict | get extension.0) if not ($extension | is-empty) { $filename = $filename + '.' + $extension } $filename}def diff [ a: path, b: path ] { print $"diffing ($a) and ($b)" ^difft $a $b}def merge [ a: path, b: path ] { meld $a $b}new file mode 100644+11 / −0 text lines
# Render my To-Do file in the terminalexport def main [] { mdcat ($env.NOTES | path join "TODO.md") }# Open my To-Do file for editingexport def edit [] { hx ($env.NOTES | path join "TODO.md") }# Open a list of commands, that I would like to remember to useexport def commands [] { mdcat ($env.NOTES | path join "COMMANDS.md") }# Open the list of commands to remember for editing.export def "commands edit" [] { vim ($env.NOTES | path join "COMMANDS.md") }new file mode 100755+13 / −0 text lines
deleted file mode 100644+0 / −53 text lines
# names of binaries in cargo must not necessarily be equal to the crate name.# this table resolves the binary name of a crate.# also, a crate can have more than one binary, but for the purpose of checking if a crate is# already installed on the system, finding one binary is sufficient.# we also cannot use `cargo install --list` to search for the binary name, in case the crate# is not installed yetlet cargo_crates = [ [ name bin crago_args]; [ "bat" "bat" [] ] [ "bottom" "btm" [] ] [ "cargo-cache" "cargo-cache" [] ] [ "cargo-update" "cargo-install-update" [] ] [ "choose", "choose", [] ] [ "eva" "eva" [] ] [ "eva" "eva" [] ] [ "fd-find" "fd" [] ] [ "git-delta" "delta" [] ] [ "gitu" "gitu" [ "--locked" ] ] [ "hexyl" "hexyl" [] ] [ "hyperfine" "hyperfine" [] ] [ "just" "just" [] ] [ "lms" "lms" [] ] [ "lychee" "lychee" [ "--locked" "--no-default-features" "--features" "rustls-tls,email-check"] ] [ "mdcat" "mdcat" [] ] [ "mdsh" "mdsh" [] ] [ "nu" "nu" [ "--features" "extra" ] ] [ "ouch" "ouch" [] ] [ "pastel" "pastel" [] ] [ "ripgrep" "rg" [] ] [ "sd" "sd" [] ] [ "selene" "selene" [ "--no-default-features" ] ] [ "stylua" "stylua" [ "--features" "lua52" ] ] [ "taplo-cli" "taplo" [] ] [ "tealdeer" "tldr" [] ] [ "tokei" "tokei" [] ] [ "viu" "viu" [] ] [ "vivid" "vivid" [] ] [ "yazi-cli" "ya" [ "--locked" ] ] [ "yazi-fm" "yazi" [ "--locked" ] ] [ "zoxide" "zoxide" [] ]]# install all my favorite crate, only if they are not already in PATH.def main [] { $cargo_crates | each { | crate | if ( which $crate.bin | is-empty ) { echo $'cargo install ($crate.name) ($crate.crago_args)' cargo install $crate.name ...$crate.crago_args } else { echo $"($crate.name) already installed" } }}+1 / −1 text lines
new file mode 100644+141 / −0 text lines
import static java.lang.System.out;import static java.lang.System.err;import java.nio.file.Files;import java.nio.file.Path;import java.nio.file.Paths;import java.util.Arrays;final class install { static final String CARGO_PACKAGES_CSV_FILE = "tools.csv"; public static void main(String[] __) throws Throwable { exec("cargo", "--version"); var csv = Path.of(CARGO_PACKAGES_CSV_FILE); if (!Files.exists(csv)) { throw fail("Expected a CSV file with cargo crates!"); } var lines = Files.lines(csv).toArray(String[]::new); for (int index = 1; index < lines.length; ++index) { var line = lines[index]; var spec = parse(line); if (!which(spec.bin)) { install(spec); } } } static boolean which(String program) { var pathEnv = System.getenv("PATH"); if (pathEnv == null || pathEnv.isEmpty()) { return false; } var paths = pathEnv.split(System.getProperty("path.separator")); var extensions = new String[] { "", ".exe", ".bat", ".cmd", ".com" }; for (var path : paths) { for (var extension : extensions) { var fullPath = Paths.get(path, program + extension); if (Files.exists(fullPath) && Files.isExecutable(fullPath)) { return true; } } } return false; } static void exec(String... command) throws Exception { var proc = new ProcessBuilder(command).inheritIO().start(); proc.waitFor(); var exit = proc.exitValue(); if (exit != 0) { dbg("process failed to exec with code %d.%nproc: %s", exit, emphasize_local(Arrays.toString(command))); } } static void install(Spec spec) throws Throwable { out("cargo install %s (%s) %s", emphasize_global(spec.name), emphasize_local(spec.bin), emphasize_local(Arrays.toString(spec.flags))); var cmd = new String[3 + spec.flags.length]; cmd[0] = "cargo"; cmd[1] = "install"; cmd[2] = spec.name; System.arraycopy(spec.flags, 0, cmd, 3, spec.flags.length); exec(cmd); } record Spec(String name, String bin, String... flags) { }; static Spec parse(String line) throws Throwable { var by_comma = line.split(";"); if (by_comma.length == 0) { throw fail("empty line in CSV"); } if (by_comma.length > 3) { throw fail("line in CSV should have 1-3 fields%nfound: %s", emphasize_local(line)); } var name = by_comma[0].strip(); var bin = name; if (by_comma.length > 1) { bin = by_comma[1].strip(); } var flags = new String[] {}; if (by_comma.length == 3) { flags = by_comma[2].strip().split(" "); } return new Spec(name, bin, flags); } static void out(String fmt, Object... args) { out.printf(fmt, args); out.println(); } static void dbg(String fmt, Object... args) { System.err.print("[DBG]: "); System.err.printf(fmt, args); System.err.println(); } static Throwable exit() { System.exit(0); // abuse control flow to make compiler realize `exit` will never return return new Throwable(); } static String emphasize_global(String message) { return "\033[4m" + message + "\033[0m"; } static String emphasize_local(String message) { return "\033[3m" + message + "\033[0m"; } static Throwable fail(String message, Object... arguments) { err.printf(message, arguments); System.exit(-1); // abuse control flow to make compiler realize `fail` will never return return new Throwable(); } static Throwable fail() { System.exit(-1); // abuse control flow to make compiler realize `fail` will never return return new Throwable(); }}deleted file mode 100755+0 / −4 text lines
deleted file mode 100644+0 / −29 text lines
#!/bin/bashset -eu fail# rewrite this some time...declare -a fonts=( IBMPlexMono VictorMono)version='3.0.2'fonts_dir="${HOME}/.local/share/fonts"if [[ ! -d "$fonts_dir" ]]; then mkdir -p "$fonts_dir"fifor font in "${fonts[@]}"; do zip_file="${font}.zip" download_url="https://github.com/ryanoasis/nerd-fonts/releases/download/v${version}/${zip_file}" echo "Downloading $download_url" wget "$download_url" unzip -d "$fonts_dir" "$zip_file" rm "$zip_file"donefind "$fonts_dir" -name '*Windows Compatible*' -deletefc-cache -fvdeleted file mode 100644+0 / −45 text lines
def main [] { assert-is-a { "" } string assert-is-a { "=" } string assert-is-a { "-" } string assert-is-a { "-=" } string assert-is-a { "-=-" } string assert-is-a { "=-" } string assert-is-a { [""] } list<string> assert-is-a { ["="] } list<string> assert-is-a { ["-"] } list<string> assert-is-a { ["-="] } list<string> # error: unknown command #assert-is-a { ["-=-"] } list<string> #assert-is-a { ["=-"] } list<string> #assert-is-a { ["=-"] } list<string> assert-is-a { ["= "] } list<string> assert-is-a { [ "="] } list<string> assert-is-a { ["=" ] } list<string> assert-is-a { [ "=" ] } list<string> assert-is-a { [ "=OK" ] } list<string>}def assert-is-a [ code: block # some nu expression expected_type: string # expected nu type of given expression, as printed by `describe`] { let span = (metadata $code).span; let actual_type = ( do $code | describe ) if $actual_type == $expected_type { echo $"(char sun)\t(ansi green_bold)OK(ansi reset)\t($actual_type)" } else { error make { msg: $"(char cloud)\t(ansi red_bold)FAIL(ansi reset)", label: { text: $"expected a `($expected_type)` but got a `($actual_type)`", start: $span.start, end: $span.end } } }}No final newlinenew file mode 100644+55 / −0 text lines
name;bin;cargo_argsasm-cli-rust; asm-cli-rust; --git https://github.com/cch123/asm-cli-rustbatbartibbottom; btmbrootcargo-cachecargo-update;cargo-install-updatechoosedu-dust; dustevaexafendfd-find;fdgit-delta;deltagitu;gitu; --lockedhckhexylhyperfineinlynejj-cli; jj; --locked --bin jjjaq;jaq; --lockedjustlemmeknowlmslurk-cli; lurklychee;lychee; --locked --no-default-features --features rustls-tls,email-checkmaskmacchinamdbookmdcatmdshmonolithnetscannernu;nu; --lockedouchpastelpueue;pueue;--lockedripgrep;rgrust-parallelsdsniffnetselene;selene; --no-default-featuresstarshipstylua;stylua; --features lua52taplo-cli;taplotealdeer;tldrtokeiugdbunfviuvividyazi-cli;ya; --lockedyazi-fm;yazi; --lockedzoxidedeleted file mode 100755+0 / −14 text lines
new file mode 100755+4 / −0 text lines
+7 / −4 text lines