Skip to content

Update Zoxide shell setup for Nushell in README#1118

Open
Rikiub wants to merge 8 commits intoajeetdsouza:mainfrom
Rikiub:readme
Open

Update Zoxide shell setup for Nushell in README#1118
Rikiub wants to merge 8 commits intoajeetdsouza:mainfrom
Rikiub:readme

Conversation

@Rikiub
Copy link
Copy Markdown

@Rikiub Rikiub commented Sep 22, 2025

Auto-load files support was added on Nushell v0.96.0, allowing nu files to be auto-loaded on shell start. This behavior is documented here.

This PR replaces the need of have a separate file and source it "manually". Instead, Zoxide completions now can be added with one-line command.

Also, Zoxide now requires v0.96.0+ as minimum Nushell version.

@ajeetdsouza
Copy link
Copy Markdown
Owner

Unfortunately, this wouldn't work.

The reason zoxide requires you to add zoxide init nushell | save -f ~/.zoxide.nu to your Nushell env file is so that the init script is regenerated every time you start a new shell. The advantage of this approach is that every time you update zoxide, the init script gets updated.

Given how often Nushell introduces breaking changes, it is important to make this process smooth. The only other option would be to expect the user to remember to re-run the init script every time they update zoxide, which would be bad UX.

@Rikiub
Copy link
Copy Markdown
Author

Rikiub commented Sep 22, 2025

Thanks for the advice, I made some changes.

Now requires write the command inside config.nu, so each time the shell is started, the file autoload/zoxide.nu is created.

I think should be enough @ajeetdsouza

I get this weird error on the linter tests:

README.md:245:81 MD013/line-length Line length [Expected: 80; Actual: 110]

Therefore I had to separate the text into two lines.
@ajeetdsouza
Copy link
Copy Markdown
Owner

ajeetdsouza commented Feb 2, 2026

Hey! One more thing that just occurred to me: what happens to users who don't have any autoload directories?

@Rikiub
Copy link
Copy Markdown
Author

Rikiub commented Feb 2, 2026

I didn't think on it, but what about tell the users to ensure autoload folder is created?


I could add something like:

Before all, ensure the "autoload" directory exists. You can create it running this command:

mkdir $nu.user-autoload-dirs.0

Then follow the next instructions.


Or maybe just add both to config:

mkdir $nu.user-autoload-dirs.0
zoxide init nushell | save -f ($nu.user-autoload-dirs.0)/zoxide.nu

@ajeetdsouza
Copy link
Copy Markdown
Owner

ajeetdsouza commented Feb 2, 2026

Hm, in that case, I'm not sure that this is a better way to initialize zoxide on Nushell. What do you think?

Also, to clarify - there could be two problems here:

  • the autoload directory does not exist
  • the user has disabled autoloading by making autoload directories an empty list

@Rikiub
Copy link
Copy Markdown
Author

Rikiub commented Feb 2, 2026

I don't think casual users would replace autoload directories, by default nushell always set one autoload directory under ~/.config/nushell/autoload so should be fine. Advanced users at this point should know what they are doing.

My reason to use autoload directories is because is cross-platform. $nu.user-autoload-dirs.0 will always point to system config directory, so it make things more organized.

In my opinion, the second way is the most easy for new users:

mkdir $nu.user-autoload-dirs.0
zoxide init nushell | save -f ($nu.user-autoload-dirs.0)/zoxide.nu

Tell me if you agree so I can send another commit 👋

@DanielAdari
Copy link
Copy Markdown

Just to add some context to this conversation (as a fellow nushell enthusiast 😀 ), this is how the Starship prompt instruct installation:

https://starship.rs/guide/#step-2-set-up-your-shell-to-use-starship

mkdir ($nu.data-dir | path join "vendor/autoload")

starship init nu | save -f ($nu.data-dir | path join "vendor/autoload/starship.nu") 

To me this seems pretty clean :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants