From 021e6670d694917cd9a22e91b921fa34b4d53be8 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Wed, 31 Jul 2024 14:44:13 -0400 Subject: [PATCH] nu: better zoxide integration will not complain if zoxide missing --- src/.config/nushell/.gitignore | 1 + src/.config/nushell/config.nu | 3 ++- src/.config/nushell/env.nu | 4 +++- src/.config/nushell/zoxide.nu | 6 ++++++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/.config/nushell/.gitignore create mode 100644 src/.config/nushell/zoxide.nu diff --git a/src/.config/nushell/.gitignore b/src/.config/nushell/.gitignore new file mode 100644 index 0000000..922f26c --- /dev/null +++ b/src/.config/nushell/.gitignore @@ -0,0 +1 @@ +zoxide.nu diff --git a/src/.config/nushell/config.nu b/src/.config/nushell/config.nu index 20ec37d..2962b97 100644 --- a/src/.config/nushell/config.nu +++ b/src/.config/nushell/config.nu @@ -713,4 +713,5 @@ $env.config = { ] } -source ~/.config/nushell/zoxide.nu +const zoxide_conf = "~/.config/nushell/zoxide.nu" +source $zoxide_conf diff --git a/src/.config/nushell/env.nu b/src/.config/nushell/env.nu index b0eec0b..1bf6750 100644 --- a/src/.config/nushell/env.nu +++ b/src/.config/nushell/env.nu @@ -95,4 +95,6 @@ $env.NU_PLUGIN_DIRS = [ # To load from a custom file you can use: # source ($nu.default-config-dir | path join 'custom.nu') -zoxide init nushell | save -f ~/.config/nushell/zoxide.nu +if (which zoxide | length) > 0 { + zoxide init nushell | save -f ~/.config/nushell/zoxide.nu +} diff --git a/src/.config/nushell/zoxide.nu b/src/.config/nushell/zoxide.nu new file mode 100644 index 0000000..ab9b439 --- /dev/null +++ b/src/.config/nushell/zoxide.nu @@ -0,0 +1,6 @@ +# DUMMY FILE for systems that do not have zoxide installed + +# nu doesn't like sourcing files conditionally, so we can't just have it ignore if zoxide.nu does not exist +# watch issue: https://github.com/nushell/nushell/issues/8214 + +# zoxide will overwrite this if it exists