repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

nushell: robust sourcing of generated configs

32a0fb6ffc997bf954ef4d70f026b6f9009ed484

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (8)

neovim/lazy-lock.json

Modified
42 42 "nvim-neoclip.lua": { "branch": "main", "commit": "32e05f2d23dc5b6a284a688c0535a83d1bfc633f" },
43 43 "nvim-rulebook": { "branch": "main", "commit": "bc5e3874a9870709ec91152f9efce6dad49ca862" },
44 44 "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
45 - "nvim-treesitter": { "branch": "master", "commit": "9b1e607298dd5fc2ee6549488324cc92dafb99c0" },
45 + "nvim-treesitter": { "branch": "master", "commit": "cc2c11c403a9143827501223b4ee64432dcaf246" },
46 46 "nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" },
47 - "nvim-treesitter-textobjects": { "branch": "master", "commit": "b91c98afa6c42819aea6cbc1ba38272f5456a5cf" },
47 + "nvim-treesitter-textobjects": { "branch": "master", "commit": "4a2d05ec24eaa6b655c7d19092a3b6c0219d46b9" },
48 48 "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
49 - "nvim-web-devicons": { "branch": "master", "commit": "56f17def81478e406e3a8ec4aa727558e79786f3" },
49 + "nvim-web-devicons": { "branch": "master", "commit": "6b53401918a9033a41159d012160c5fb5eb249ae" },
50 50 "oil.nvim": { "branch": "master", "commit": "1eb9fb35a4613518f79790117ed82c367a0b4a22" },
51 51 "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
52 52 "range-highlight.nvim": { "branch": "master", "commit": "8b5e8ccb3460b2c3675f4639b9f54e64eaab36d9" },

nushell/env.nu

Modified
79 79 source ($nu.default-config-dir | path join 'gen-aliases.nu')
81 81 # generate zoxide hooks for sourcing later on
82 +let zoxide_config_path = $nu.default-config-dir | path join 'zoxide.nu'
82 83 if not (which zoxide | is-empty) {
83 - zoxide init nushell | save -f ($nu.default-config-dir | path join 'zoxide.nu')
84 + zoxide init nushell | save --force $zoxide_config_path
85 +} else {
86 + '' | save -f $zoxide_config_path
89 +# TODO: figure out sensible bridges
90 +$env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense'
91 +let carapace_config_path = $nu.default-config-dir | path join 'carapace.nu'
86 92 if not (which carapace | is-empty) {
87 - $env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense' # TODO: figure out sensible bridges
88 - mkdir ~/.cache/carapace
89 - carapace _carapace nushell | save --force ~/.cache/carapace/init.nu
93 + carapace _carapace nushell | save --force $carapace_config_path
94 +} else {
95 + '' | save --force $carapace_config_path
92 98 def --env wslg [] {

nushell/login.nu

Modified
12 12 use packages.nu
13 13 use fedora_bootstrip.nu
14 14 use notes.nu
15 +use direnv.nu
17 +use svn-completions.nu *
16 19 use svn-completions.nu *
22 25 source ($nu.default-config-dir | path join 'aliases.nu')
24 -# must be done, after defining config, since zoxide mutates it
25 -# this will fail if zoxide is not installed yet
26 26 source ($nu.default-config-dir | path join "zoxide.nu")
27 +source ($nu.default-config-dir | path join "carapace.nu")
28 -# FIXME: just like the zoxide script, this will fail if carapace is not around
29 -# in both cases an empty file needs to be genereated, if the commands are not in PATH
30 -# so that this source never fails
31 -source ( [$nu.home-path '.cache' 'carapace' 'init.nu'] | path join)
33 -source ($nu.default-config-dir | path join "scripts/direnv.nu")
35 30 todo commands
36 31 print (char nl)

nushell/scripts/commands.nu

Modified
17 17 rm -fp $tmp
20 +# creates a backup of the given file in a temporary directory and prints the path
21 +export def bak [
22 + file: path # the file to copy into a backup
23 +] {
24 + if not ($file | path exists ) {
25 + error make {
26 + msg: "The file to backup does not exist.",
27 + label: {
28 + text: "Missing its existence!",
29 + span: (metadata $file).span
30 + }
31 + }
32 + }
33 + let full_path = $file | path expand
34 + let tmpdir = mktemp --directory --tmpdir backup_XXX
35 + let backup = $tmpdir | path join ( $file | path basename )
36 + let backup_original_path = $tmpdir | path join 'original.path'
37 + $full_path | save $backup_original_path
38 + cp --preserve [ mode timestamps ] $file $backup
39 + print $backup
42 +# restores a backup previously made with `bak` command
43 +export def kab [
44 + backup: path # a backup file to restore
45 +] {
46 + if not ($backup | path exists ) {
47 + error make {
48 + msg: "The backup file does not exist.",
49 + label: {
50 + text: "Missing its existence!",
51 + span: (metadata $backup).span
52 + }
53 + }
54 + }
55 + let backup_file = $backup | path expand
56 + if ($backup_file !~ 'backup_' ) {
57 + error make {
58 + msg: "The file does not seem to be a backup file from `bak`.",
59 + label: {
60 + text: "Are u even bak'ed up?",
61 + span: (metadata $backup).span
62 + }
63 + }
64 + }
65 + let backup_dir = $backup | path dirname
66 + let original_path_file = $backup_dir | path join 'original.path'
67 + let original_path = open --raw $original_path_file
68 + try {
69 + mv --progress --interactive --verbose $backup_file $original_path
70 + } catch {
71 + return # skip deletion
72 + }
73 + rm --trash --recursive $backup_dir

nushell/scripts/fedora_bootstrip.nu

Modified
13 13 # these seem to be deps of the openssl-sys crates build system
14 14 sudo dnf install perl-File-Compare perl-File-Copy perl-FindBin perl-IPC-Cmd
16 + # system stuff
17 + sudo dnf install python3-dnf-plugin-rpmconf dnf-automatic
18 + sudo systemctl enable --now dnf-automatic-install.timer
16 20 # my stuff
17 21 sudo dnf install aerc llvm clang cmake unison rustup neovim mold java-latest-openjdk-devel java-latest-openjdk-src perl-Image-ExifTool

topgrade/topgrade.toml

Modified
6 6 display_time = true
7 7 cleanup = true
9 +[containers]
10 +runtime = "podman"
9 12 [composer]
10 13 self_update = false

wezterm/bugabinga/key_binds.lua

Modified
59 59 { key = 'v', action = wez.action.SplitHorizontal { domain = 'CurrentPaneDomain', }, },
60 60 { key = 's', action = wez.action.SplitVertical { domain = 'CurrentPaneDomain', }, },
62 + { key = 'r', action = wez.action.RotatePanes 'CounterClockwise', },
63 + { key = 'R', action = wez.action.RotatePanes 'Clockwise', },
62 64 { key = '=', action = wez.action.ActivateKeyTable { name = resize_pane_mode, one_shot = false, }, },
64 66 { key = 'q', action = wez.action.CloseCurrentPane { confirm = false, }, },

x230.symlinks

Modified
22 22 nushell/scripts
23 23 ~/.config/nushell/scripts
25 +nushell/completions
26 +~/.config/nushell/completions
25 28 icc/thinkpad_x230.icc
26 29 ~/.config/icc/thinkpad_x230.icc