repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

update to new nushell version

4a389ef56d92d786b0635a48b8972f201624539d

Oliver Jan Krylow <olver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (7)

nushell/env.nu

Modified
1 1 # GLOBAL VARIABLES
3 -let-env WIN32? = ( $nu.os-info.name =~ "windows" )
3 +let-env WIN32 = ( $nu.os-info.name =~ "windows" )
4 4 let-env NURC_DIR = ( $nu.config-path | path expand | path dirname )
5 5 let-env DOTFILES = ( $env.NURC_DIR | path join ".." | path expand )
6 -let-env WORKSPACE = if $env.WIN32? { "W:/" } else { "~/Workspace" | path expand }
7 -let-env NOTES = if $env.WIN32? { "N:/" } else { "~/Notes" | path expand }
6 +let-env WORKSPACE = if $env.WIN32 { "W:/" } else { "~/Workspace" | path expand }
7 +let-env NOTES = if $env.WIN32 { "N:/" } else { "~/Notes" | path expand }
9 9 # theme for ls and other programs, that use LS_COLORS
10 -let-env LS_COLORS = (vivid generate nord)
10 +let-env LS_COLORS = ( do -i { vivid generate nord } )
12 12 # Specifies how environment variables are:
13 13 # - converted from a string to a value on Nushell startup (from_string)
16 16 let-env ENV_CONVERSIONS = {
17 17 "PATH": {
18 18 from_string: { |s| $s | split row (char esep) }
19 - to_string: { |v| $v | str collect (char esep) }
19 + to_string: { |v| $v | str join (char esep) }
21 21 "Path": {
22 22 from_string: { |s| $s | split row (char esep) }
23 - to_string: { |v| $v | str collect (char esep) }
23 + to_string: { |v| $v | str join (char esep) }

nushell/modules/git.nu

Modified
35 35 echo (build-string "[" ID : $id "]" " key with title " (ansi gb) $title (ansi reset) " was created at " (ansi yi) $created_at (ansi reset) "." (char newline) )
36 36 echo (build-string (ansi wu) "PUBLIC SSH KEY:" (ansi reset))
37 37 echo (char newline)
38 - echo ($key | ansi gradient --fgstart 0xaefe9f --fgend 0xfefefe)
38 + echo ($key | ansi gradient --fgstart "0xaefe9f" --fgend "0xfefefe")
39 39 echo (char newline)
41 41 } else {
48 48 export def glog [
49 49 ...rest: string # Extra arguments to git log
51 - git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 25 $rest | lines | split column "»¦«" commit subject name email date | update date { get date | into datetime} | sort-by date
51 + git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 25 $rest | lines | split column "»¦«" commit subject name email date | update date { || get date | into datetime } | sort-by date
54 54 # Show the effective configuration of git

nushell/modules/os.nu

Modified
4 4 # Opens the given resource in the operating systems preferred application.
5 5 export def start [
6 6 ...rest: string # Paths or URLs the OS should open for you.
8 - if $env.WIN32? {
8 + if $env.WIN32 {
9 9 $rest | each { |thing| ^start $thing}
10 10 } else {
11 11 $rest | each { |thing| ^xdg-open $thing }

nushell/modules/prompt.nu

Modified
6 6 [ path icon ];
7 7 [ "/home/oli/Notes" (char -u "1f4d3") ]
8 + [ "/home/bugabinga/Notes" (char -u "1f4d3") ]
8 9 [ "C:\\Users\\okr\\Notes" (char -u "1f4d3") ]
9 10 [ "/home/oli/Workspace" (char -u "1f4bb") ]
11 + [ "/home/bugabinga/Workspace" (char -u "1f4bb") ]
10 12 [ "C:\\Users\\okr\\Workspaces" (char -u "1f4bb") ]
11 13 [ "/home/oli" (char nf_house2) ]
14 + [ "/home/bugabinga" (char nf_house2) ]
12 15 [ "C:\\Users\\okr" (char nf_house2) ]
23 26 let icon = if (icons | any { |icon| $icon.path == $pwd } ) { ( icons | where path == $pwd | get icon.0 ) } else { $"(char nf_folder1)" }
24 27 # Some terminals freeze, if they do not support this OSC
25 28 if ($env | get -i TERM_PROGRAM) == WezTerm {
26 - echo ([ (ansi title) $icon " " ( $pwd | path basename ) (ansi reset) ] | str collect)
29 + echo ([ (ansi title) $icon " " ( $pwd | path basename ) (ansi reset) ] | str join)
32 35 let pwd = ($env.PWD | path expand)
34 37 let svn_relative_cmd = ( do --ignore-errors { ^svn info --show-item relative-url --no-newline $pwd | complete } )
35 - let svn_relative_path = if ($svn_relative_cmd.exit_code == 0) { $" 🐢 (char nf_branch) ($svn_relative_cmd.stdout)" }
38 + 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)" }
37 - let git_status = ( gstat )
38 - let git_branch = if ( $git_status.branch != "no_branch" ) { $" (char nf_git) (char nf_branch) ($git_status.branch)" }
40 + let git_status = ( do --ignore-errors { gstat } )
41 + let git_branch = if ( ( not ($git_status | is-empty)) and ($git_status.branch != "no_branch") ) { $" (char nf_git) (char nf_branch) ($git_status.branch)" }
41 44 $svn_relative_path
42 45 $git_branch
43 - ] | str collect
46 + ] | str join
46 49 def create_left_prompt [] {
49 52 # normalize path
50 53 let pwd = ($env.PWD | path expand)
51 - let pwd = (icons | reduce --fold $pwd { |item, accumulator| $accumulator | str replace --string $item.path $item.icon })
54 + let pwd = ( (icons) | reduce --fold $pwd { |item, accumulator| $accumulator | str replace --string $item.path $item.icon })
52 55 let truncate_level = 5
53 56 let truncate_symbol = $"…(char path_sep)"
54 57 let path_segment = if ($pwd | path split | length) >= $truncate_level { ($pwd | path dirname --num-levels 2 --replace $truncate_symbol ) } else { $pwd }
56 - let vcs_segment = get_vcs_path
59 + let vcs_segment = (get_vcs_path)
59 62 (ansi dark_gray)
62 65 (ansi green)
63 66 $vcs_segment
64 67 (ansi reset)
65 - ] | str collect
68 + ] | str join
68 71 def create_right_prompt [] {
69 72 let time_segment = ([
70 73 (date now | date format '%d.%m %R')
71 - ] | str collect)
74 + ] | str join)
73 76 let command_status_segment = if $env.LAST_EXIT_CODE == 0 { $" (char -u '2713') " } else { $"(ansi red) (char failed) (ansi reset)" }
74 77 let command_duration_segment = if ( $env.CMD_DURATION_MS | into int) > 0 { $"($env.CMD_DURATION_MS)ms" | into duration }
83 86 (ansi dark_gray)
84 87 $time_segment
85 88 (ansi reset)
86 - ] | str collect
89 + ] | str join
89 92 export-env {
90 93 # Use nushell functions to define your right and left prompt
91 - let-env PROMPT_COMMAND = { create_left_prompt }
92 - let-env PROMPT_COMMAND_RIGHT = { create_right_prompt }
94 + let-env PROMPT_COMMAND = { || create_left_prompt }
95 + let-env PROMPT_COMMAND_RIGHT = { || create_right_prompt }
94 97 # The prompt indicators are environmental variables that represent
95 98 # the state of the prompt

nushell/modules/table.nu

Modified
8 8 # Flattens a table into a string separated by a single space character.
9 -export def to-string [] { flatten | into string | str collect ' ' }
9 +export def to-string [] { flatten | into string | str join ' ' }

nushell/modules/zoxide.nu

Modified
10 10 let-env config = ($env | default {} config).config
11 11 let-env config = ($env.config | default {} hooks)
12 12 let-env config = ($env.config | update hooks ($env.config.hooks | default [] pre_prompt))
13 - let-env config = ($env.config | update hooks.pre_prompt ($env.config.hooks.pre_prompt | append {
13 + let-env config = ($env.config | update hooks.pre_prompt ($env.config.hooks.pre_prompt | append { ||
14 14 zoxide add -- $env.PWD

wezterm/wezterm.lua

Modified
1 1 local wez = require 'wezterm'
2 2 local nugu = require 'bugabinga.nugu'
4 -local color_scheme = 'nugu-dark' -- not there yet ;)
5 4 local color_schemes = nugu
7 6 local hostname = wez.hostname()
13 12 if hostname == 'x230' then
14 13 enable_wayland = true
15 - window_decorations = 'NONE'
14 + window_decorations = 'RESIZE'
16 15 elseif hostname == 'pop-os' then
17 16 font_size = 12
18 17 elseif hostname == 'PC-00625' then
30 29 window:set_right_status(name or '')
32 +-- wezterm.gui is not available to the mux server, so take care to
33 +-- do something reasonable when this config is evaluated by the mux
34 +function get_appearance()
35 + if wez.gui then
36 + return wez.gui.get_appearance()
37 + end
38 + return 'Dark'
39 +end
41 +function scheme_for_appearance(appearance)
42 + if appearance:find 'Dark' then
43 + return 'nugu-dark'
44 + else
45 + return 'nugu-light'
46 + end
47 +end
49 +wez.on("window-config-reloaded", function(window, pane)
50 + local overrides = window:get_config_overrides() or {}
51 + local appearance = window:get_appearance()
52 + local scheme = scheme_for_appearance(appearance)
53 + if overrides.color_scheme ~= scheme then
54 + overrides.color_scheme = scheme
55 + window:set_config_overrides(overrides)
56 + end
57 +end)
33 59 local leader = { key = 'Space', mods = 'CTRL|SHIFT', timeout_milliseconds = 1000 }
34 60 local keys = {
35 61 -- CTRL+SHIFT+Space, followed by 'r' will put us in resize-pane
141 167 return {
142 168 font = font,
143 169 font_size = font_size,
144 - color_scheme = color_scheme,
170 + color_scheme = scheme_for_appearance(get_appearance()),
145 171 color_schemes = color_schemes,
146 172 default_prog = { 'nu' },
147 173 window_decorations = window_decorations,