repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

Modernize Nushell startup layout

6490c478e1aaf43e4a82e354f50ccb5cdd7b7e27

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (4)

nushell/autoload/30-completion.nu

Added
new file mode 100644
1 +source ($nu.default-config-dir | path join modules completion.nu)

nushell/config.nu

Modified
1 -$env.config = {
2 - edit_mode: vi
3 - show_banner: false
4 - buffer_editor: "nvim"
5 - table: {mode: markdown}
6 - rm: {
7 - always_trash: (not $env.TERMUX)
8 - }
9 - cursor_shape: {vi_insert: line, vi_normal: block}
10 - float_precision: 3
11 - shell_integration: {
12 - # osc9_9: true
13 - # unfortunately, this seems to be buggy on win32 with wezterm
14 - osc133: ($nu.os-info.family | str contains "unix")
15 - }
16 - highlight_resolved_externals: true
17 - use_kitty_protocol: (not $env.WIN32)
18 - color_config: {
1 +use std/util "path add"
20 - # -- primitives (data types) --
21 - int: green
22 - float: green
23 - bool: green_bold
24 - string: blue
25 - nothing: dark_gray
26 - binary: dark_gray
27 - duration: green
28 - range: dark_gray
29 - cell-path: dark_gray
3 +const NU_LIB_DIRS = [
4 + ($nu.default-config-dir | path join modules)
5 +]
31 - # -- table / presentation --
32 - separator: light_green
33 - header: light_blue_bold
34 - row_index: light_green
35 - leading_trailing_space_bg: dark_gray
36 - hints: cyan
37 - empty: dark_gray
38 - search_result: green_bold
7 +$env.WIN32 = ($nu.os-info.name =~ "windows")
8 +$env.TERMUX = ($nu.os-info.name =~ "android")
40 - # -- shapes (syntax highlighting, Nugu philosophy) --
41 - # human meaning → prominent (important_local / focus)
42 - shape_string: blue
43 - shape_raw_string: blue
44 - shape_string_interpolation: green_bold
45 - shape_int: green_bold
46 - shape_float: green_bold
47 - shape_bool: green_bold
48 - shape_filepath: green
49 - shape_directory: green
50 - shape_globpattern: green
51 - shape_glob_interpolation: green_bold
52 - shape_record: green
53 - shape_list: green
54 - shape_table: green
55 - shape_datetime: green_bold
56 - shape_match_pattern: blue
57 - shape_signature: blue
58 - shape_literal: white
59 - shape_custom: magenta_bold
60 - shape_closure: blue_bold
61 - shape_block: blue_bold
62 - shape_range: dark_gray
64 - # structural / plumbing → receded (minor)
65 - shape_keyword: dark_gray
66 - shape_operator: dark_gray
67 - shape_pipe: dark_gray
68 - shape_redirection: dark_gray
69 - shape_flag: light_cyan
70 - shape_binary: dark_gray
71 - shape_nothing: dark_gray
72 - shape_matching_brackets: dark_gray_bold
73 - shape_vardecl: white
74 - shape_variable: white
76 - # externals
77 - shape_external: light_magenta
78 - shape_externalarg: green_bold
79 - shape_external_resolved: magenta_bold
80 - shape_internalcall: light_cyan_bold
82 - # errors
83 - shape_garbage: {fg: white, bg: red, attr: b}
84 - }
85 - history: {file_format: "sqlite", isolation: true}
10 +$env.WORKSPACE = if $env.WIN32 { "~/Workspace" } else {
11 + "~/Workspace" | path expand
13 +$env.DOTFILES = ($env.WORKSPACE | path join "dotfiles" | path expand)
14 +$env.NOTES = ("~/Notes" | path expand)
15 +$env.TOOLS = ("~/Tools" | path expand)
16 +$env.CARGO_HOME = ("~/.cargo" | path expand)
17 +$env.GO_HOME = ("~/.go" | path expand)
18 +$env.DOT_LOCAL = ("~/.local" | path expand)
19 +$env.DIFFTOOL = "zeditor --wait --diff"
20 +$env.BUN_HOME = ("~/.bun" | path expand)
22 +path add --append ($env.CARGO_HOME | path join bin)
23 +path add --append ($env.GO_HOME | path join bin)
24 +path add --append ($env.TOOLS | path join bin)
25 +path add --append ($env.BUN_HOME | path join bin)
26 +if not $env.WIN32 {
27 + path add --append ($env.DOT_LOCAL | path join bin)
30 +if (not $env.WIN32) and ($env.XDG_RUNTIME_DIR? != null) {
31 + # make sure to start ssh-agent user service: userctl enable --now ssh-agent
32 + $env.SSH_AUTH_SOCK = $"($env.XDG_RUNTIME_DIR)/ssh-agent.socket"
35 +$env.PI_SKIP_VERSION_CHECK = true
36 +$env.PI_TELEMETRY = true
37 +# this seems to be ignored! duplicated in settings for now...
38 +$env.PI_CODING_AGENT_SESSION_DIR = "~/.local/state/pi/sessions" | path expand
39 +$env.PI_CACHE_RETENTION = "long"
41 +if (which sccache | is-not-empty) {
42 + $env.RUSTC_WRAPPER = "sccache"
45 +if (which nvim | is-not-empty) {
46 + $env.EDITOR = "nvim"
47 + $env.GIT_EDITOR = "nvim"
50 +if (which neovide | is-not-empty) {
51 + $env.VISUAL = "neovide"
54 +$env.LS_COLORS = "rs=0:di=1;34:ln=1;35:ex=1;32:bd=1;33;40:cd=1;33;40:pi=33:so=35:do=35:or=1;31:mi=1;37;41:su=37;41:sg=30;43:tw=30;41:ow=37;41:st=37;44:*.tar=1;31:*.tgz=1;31:*.zip=1;31:*.gz=1;31:*.xz=1;31:*.7z=1;31:*.rar=1;31:*.jpg=1;35:*.png=1;35:*.gif=1;35:*.bmp=1;35:*.mp4=1;33:*.mp3=1;33:*.flac=1;33:*.pdf=1;33:*.doc=1;33:*.docx=1;33:*.txt=0:*.md=0:*.c=1;34:*.cpp=1;34:*.h=1;34:*.java=1;34:*.py=1;34:*.sh=1;34:"
56 +# Carapace bridges available on this system: bash.
57 +# fish/zsh/inshellisense executables are not installed, so those bridges add no completions.
58 +$env.CARAPACE_BRIDGES = "bash"
59 +$env.CARAPACE_LENIENT = 1
61 +$env.config.show_banner = false
62 +$env.config.edit_mode = "vi"
63 +$env.config.buffer_editor = "nvim"
64 +$env.config.table.mode = "markdown"
65 +$env.config.rm.always_trash = (not $env.TERMUX)
66 +$env.config.cursor_shape.vi_insert = "line"
67 +$env.config.cursor_shape.vi_normal = "block"
68 +$env.config.float_precision = 3
69 +# unfortunately, osc9_9 seems to be buggy on win32 with wezterm
70 +$env.config.shell_integration.osc133 = ($nu.os-info.family | str contains "unix")
71 +$env.config.highlight_resolved_externals = true
72 +$env.config.use_kitty_protocol = (not $env.WIN32)
73 +$env.config.history.file_format = "sqlite"
74 +$env.config.history.isolation = true
76 +$env.config.color_config = {
77 + # primitives (data types)
78 + int: green
79 + float: green
80 + bool: green_bold
81 + string: blue
82 + nothing: dark_gray
83 + binary: dark_gray
84 + duration: green
85 + range: dark_gray
86 + cell-path: dark_gray
88 + # table / presentation
89 + separator: light_green
90 + header: light_blue_bold
91 + row_index: light_green
92 + leading_trailing_space_bg: dark_gray
93 + hints: cyan
94 + empty: dark_gray
95 + search_result: green_bold
97 + # shapes (syntax highlighting, Nugu philosophy)
98 + # human meaning -> prominent (important_local / focus)
99 + shape_string: blue
100 + shape_raw_string: blue
101 + shape_string_interpolation: green_bold
102 + shape_int: green_bold
103 + shape_float: green_bold
104 + shape_bool: green_bold
105 + shape_filepath: green
106 + shape_directory: green
107 + shape_globpattern: green
108 + shape_glob_interpolation: green_bold
109 + shape_record: green
110 + shape_list: green
111 + shape_table: green
112 + shape_datetime: green_bold
113 + shape_match_pattern: blue
114 + shape_signature: blue
115 + shape_literal: white
116 + shape_custom: magenta_bold
117 + shape_closure: blue_bold
118 + shape_block: blue_bold
119 + shape_range: dark_gray
121 + # structural / plumbing -> receded (minor)
122 + shape_keyword: dark_gray
123 + shape_operator: dark_gray
124 + shape_pipe: dark_gray
125 + shape_redirection: dark_gray
126 + shape_flag: light_cyan
127 + shape_binary: dark_gray
128 + shape_nothing: dark_gray
129 + shape_matching_brackets: dark_gray_bold
130 + shape_vardecl: white
131 + shape_variable: white
133 + # externals
134 + shape_external: light_magenta
135 + shape_externalarg: green_bold
136 + shape_external_resolved: magenta_bold
137 + shape_internalcall: light_cyan_bold
139 + # errors
140 + shape_garbage: {fg: white, bg: red, attr: b}
143 +# Generate aliases here so login.nu can source the evaluated file.
144 +source ($nu.default-config-dir | path join "gen-aliases.nu")

nushell/env.nu

Modified
1 -# GLOBAL VARIABLES
3 -#TODO move to config.nu
5 -$env.WIN32 = ($nu.os-info.name =~ "windows")
6 -$env.TERMUX = ($nu.os-info.name =~ "android")
8 -$env.WORKSPACE = if $env.WIN32 { "~/Workspace" } else {
9 - "~/Workspace" | path expand
11 -$env.DOTFILES = ($env.WORKSPACE | path join 'dotfiles' | path expand)
12 -$env.NOTES = ("~/Notes" | path expand)
13 -$env.TOOLS = ("~/Tools" | path expand)
14 -$env.CARGO_HOME = ("~/.cargo" | path expand)
15 -$env.GO_HOME = ("~/.go" | path expand)
16 -$env.DOT_LOCAL = ("~/.local" | path expand)
17 -$env.DIFFTOOL = "zeditor --wait --diff"
18 -$env.BUN_HOME = ("~/.bun" | path expand)
20 -if not $env.WIN32 {
21 - # make sure to start ssh-agent user service: userctl enable --now ssh-agent
22 - $env.SSH_AUTH_SOCK = $"($env.XDG_RUNTIME_DIR)/ssh-agent.socket"
25 -$env.PI_SKIP_VERSION_CHECK = true
26 -$env.PI_TELEMETRY = true
27 -# this seems to be ignored! duplicated in settings for now...
28 -$env.PI_CODING_AGENT_SESSION_DIR = "~/.local/state/pi/sessions" | path expand
29 -$env.PI_CACHE_RETENTION = "long"
31 -if (which sccache | is-not-empty) { $env.RUSTC_WRAPPER = "sccache" }
33 -if $env.WIN32 {
34 - $env.Path = (
35 - $env.Path
36 - | split row (char esep)
37 - | append ($env.CARGO_HOME | path join bin)
38 - | append ($env.GO_HOME | path join bin)
39 - | append ($env.TOOLS | path join bin)
40 - | append ($env.BUN_HOME | path join bin)
41 - | uniq # filter so the paths are unique
43 -} else {
44 - $env.PATH = (
45 - $env.PATH
46 - | split row (char esep)
47 - | append ($env.CARGO_HOME | path join bin)
48 - | append ($env.GO_HOME | path join bin)
49 - | append ($env.TOOLS | path join bin)
50 - | append ($env.DOT_LOCAL | path join bin)
51 - | append ($env.BUN_HOME | path join bin)
52 - | uniq # filter so the paths are unique
56 -if (which nvim | is-not-empty) {
57 - $env.EDITOR = 'nvim'
58 - $env.GIT_EDITOR = 'nvim'
61 -if (which neovide | is-not-empty) {
62 - $env.VISUAL = 'neovide'
65 -$env.LS_COLORS = 'rs=0:di=1;34:ln=1;35:ex=1;32:bd=1;33;40:cd=1;33;40:pi=33:so=35:do=35:or=1;31:mi=1;37;41:su=37;41:sg=30;43:tw=30;41:ow=37;41:st=37;44:*.tar=1;31:*.tgz=1;31:*.zip=1;31:*.gz=1;31:*.xz=1;31:*.7z=1;31:*.rar=1;31:*.jpg=1;35:*.png=1;35:*.gif=1;35:*.bmp=1;35:*.mp4=1;33:*.mp3=1;33:*.flac=1;33:*.pdf=1;33:*.doc=1;33:*.docx=1;33:*.txt=0:*.md=0:*.c=1;34:*.cpp=1;34:*.h=1;34:*.java=1;34:*.py=1;34:*.sh=1;34:'
67 -# Specifies how environment variables are:
68 -# - converted from a string to a value on Nushell startup (from_string)
69 -# - converted from a value back to a string when running external commands (to_string)
70 -# Note: The conversions happen *after* config.nu is loaded
71 -$env.ENV_CONVERSIONS = {
72 - "PATH": {
73 - from_string: {|s|
74 - $s | split row (char esep)
75 - }
76 - to_string: {|v|
77 - $v | str join (char esep)
78 - }
79 - }
80 - "Path": {
81 - from_string: {|s|
82 - $s | split row (char esep)
83 - }
84 - to_string: {|v|
85 - $v | str join (char esep)
86 - }
87 - }
90 -$env.NU_LIB_DIRS = [
91 - ($nu.default-config-dir | path join 'modules')
94 -# generate aliases here and now, so that we can apply conditions.
95 -# later, in config.nu, the evaluated aliases will be sourced
96 -source ($nu.default-config-dir | path join 'gen-aliases.nu')
98 -# TODO move to vendor dirs
100 -# generate zoxide hooks for sourcing later on
101 -let zoxide_config_path = $nu.default-config-dir | path join 'zoxide.nu'
102 -if not (which zoxide | is-empty) {
103 - zoxide init nushell | save --force $zoxide_config_path
104 -} else {
105 - '' | save -f $zoxide_config_path
108 -# Carapace bridges available on this system: bash.
109 -# fish/zsh/inshellisense executables are not installed, so those bridges add no completions.
110 -$env.CARAPACE_BRIDGES = 'bash'
111 -$env.CARAPACE_LENIENT = 1
113 -if not (which mise | is-empty) {
114 - mkdir ($nu.vendor-autoload-dirs | last)
115 - ^mise activate nu | str replace --all 'str upcase' 'str uppercase' | str replace --all 'str downcase' 'str lowercase' | save --force ($nu.vendor-autoload-dirs | last | path join 'mise.nu')
118 -if not (which niri | is-empty) {
119 - mkdir ($nu.vendor-autoload-dirs | last)
120 - ^niri completions nushell | save --force ($nu.vendor-autoload-dirs | last | path join 'niri.nu')
123 -source secrets.nu
1 +# Intentionally empty.
2 +#
3 +# Modern Nushell config keeps environment setup in config.nu and late-loading
4 +# local/session tweaks in autoload/*.nu.

nushell/login.nu

Modified
22 22 use work_scope.nu
24 24 use std/clip
25 -use std/util "path add"
27 26 export def vx [...rest] {
28 27 NVIM_APPNAME=nvim-minimax nvim ...$rest
30 +let save_if_changed = {|path: path, content: string|
31 + if (not ($path | path exists)) or ((open --raw $path) != $content) {
32 + $content | save --force $path
33 + }
36 +let zoxide_config_path = ($nu.default-config-dir | path join "zoxide.nu")
37 +if not (which zoxide | is-empty) {
38 + do $save_if_changed $zoxide_config_path (zoxide init nushell)
39 +} else {
40 + do $save_if_changed $zoxide_config_path ""
43 +let vendor_dir = ($nu.vendor-autoload-dirs | last)
44 +mkdir $vendor_dir
46 +if not (which mise | is-empty) {
47 + let mise_config = (
48 + ^mise activate nu
49 + | str replace --all "str upcase" "str uppercase"
50 + | str replace --all "str downcase" "str lowercase"
51 + )
52 + do $save_if_changed ($vendor_dir | path join "mise.nu") $mise_config
55 +if not (which niri | is-empty) {
56 + do $save_if_changed ($vendor_dir | path join "niri.nu") (^niri completions nushell)
31 59 source ($nu.default-config-dir | path join 'aliases.nu')
32 60 source ($nu.default-config-dir | path join 'secrets.nu')
33 61 source ($nu.default-config-dir | path join "zoxide.nu")
34 -source ($nu.default-config-dir | path join "modules" "completion.nu")
36 63 work_scope generate