Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve nushell template to gracefully handle no match errors #917

Closed
wants to merge 3 commits into from

Conversation

marcelarie
Copy link

@marcelarie marcelarie commented Oct 8, 2024

Currently, the __zoxide_z command in nushell throws the following error when no matches are found for a query:

zoxide: no match found
Error: nu::shell::non_zero_exit_code

  × External command had a non-zero exit code
    ╭─[/home/marcel/.config/nushell/external/zoxide.nu:33:8]
 32 │   
 33 │       (zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n")
    ·        ───┬──
    ·           ╰── exited with code 1
 34 │     
    ╰────

when the behavior in any other shell is to only return the result of the zoxide command:

zoxide: no match found

This PR modifies the nushell template to ignore errors and display only the zoxide query command result. The cd command is executed only when a valid path is found.

Comment on lines 48 to 56
(try {
zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n"
} catch {
""
})
}

if $path != "" {
cd $path
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy to change the formatting if any other is preferred.

@ajeetdsouza
Copy link
Owner

image

I'm already seeing the expected behaviour on Nu 0.98.0 (macOS). On what version are you seeing the error trace?

@ajeetdsouza ajeetdsouza added the waiting-for-response Waiting for a response from the issue author. label Oct 15, 2024
@marcelarie
Copy link
Author

I'm already seeing the expected behaviour on Nu 0.98.0 (macOS). On what version are you seeing the error trace?

0.99 after an update, everything is working now. Maybe it was something related to my config 🥲

@marcelarie marcelarie closed this Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-response Waiting for a response from the issue author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants