# config.nu # # Installed by: # version = "0.104.1" # # This file is used to override default Nushell settings, define # (or import) custom commands, or run any other startup tasks. # See https://www.nushell.sh/book/configuration.html # # This file is loaded after env.nu and before login.nu # # You can open this file in your default editor using: # config nu # # See `help config nu` for more options # # You can remove these comments if you want or leave # them for future reference. $env.config.show_banner = false $env.EDITOR = 'hx' $env.VISUAL = 'hx' export def lumen-search-content [searchstr = string]: any -> table { let $tmp = $in mut $path = pwd if ($tmp != null) { $path = $tmp } cd $path ls -a **/* | par-each {|i| {file: $i.name, content: (if (($i | get type) == file ) { try {open $i.name --raw | find $searchstr} catch {|err| {}} }) } } | compact content -e } export def lumen-assono-worktime-calc [datestr = string]: nothing -> any { let $datestr = $datestr | str replace ' +' ' ' mut $dateArray = [] let $rawDateArray = $datestr | split row ' ' if (($rawDateArray | length) mod 2 == 1) { mut $spliceCounter = true for $i in $rawDateArray { if ($spliceCounter) { $dateArray = $dateArray | append $i } $spliceCounter = not $spliceCounter } } else { $dateArray = $rawDateArray } if (($dateArray | length) mod 2 == 1) { error make {msg: 'Uneven Times given!'} } mut $dateArrayOutput = [] mut $dateArrayOutputBuilderCounter = true for $i in $dateArray { $dateArrayOutput = $dateArrayOutput | append ($i | date from-human | format date '%H:%M') if ($dateArrayOutputBuilderCounter) { $dateArrayOutput = $dateArrayOutput | append '-' } else { $dateArrayOutput = $dateArrayOutput | append '|' } $dateArrayOutputBuilderCounter = not $dateArrayOutputBuilderCounter } let $dateArrayOutput = ($dateArrayOutput | drop 1) | str join ' ' # $dateArray[0] mut $hours = 0min while (($dateArray | length) > 0) { $hours += ($dateArray | get 1 | into datetime) - ($dateArray | get 0 | into datetime) $dateArray = $dateArray | skip 2 } $"($dateArrayOutput)\n($hours | into string)" }