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

Feature: add shell completions for nushell #527

Merged
merged 4 commits into from
Apr 24, 2024

Conversation

Tirka
Copy link
Contributor

@Tirka Tirka commented Apr 23, 2024

Rationale

pueue recommended as a temporary workaround solution for background task spawning for nushell users.

It would be nice to have shell completions within nushell.

Usage

Currently nushell has no preferred way to install completion files into system: nushell/nushell#11337

One possible way of doing this could be:

  1. generate completions
mkdir /usr/share/nushell-completions/pueue/
pueue completions nushell /usr/share/nushell-completions/pueue/
mv /usr/share/nushell-completions/pueue/pueue.nu /usr/share/nushell-completions/pueue/mod.nu
  1. open nushell config
config nu
  1. add reference to completion file into config (at the bottom)
use ~/.config/nushell/completions/pueue/ *
  1. save config and restart the shell

Screenshot

image

@Tirka
Copy link
Contributor Author

Tirka commented Apr 23, 2024

BTW

Not sure why this code block repeats twice, looks like a bug

if let Some(output_directory) = output_directory {
let completion_result = match shell {
Shell::Bash => generate_to(shells::Bash, &mut app, "pueue", output_directory),
Shell::Elvish => generate_to(shells::Elvish, &mut app, "pueue", output_directory),
Shell::Fish => generate_to(shells::Fish, &mut app, "pueue", output_directory),
Shell::PowerShell => {
generate_to(shells::PowerShell, &mut app, "pueue", output_directory)
}
Shell::Zsh => generate_to(shells::Zsh, &mut app, "pueue", output_directory),
Shell::Nushell => generate_to(
clap_complete_nushell::Nushell,
&mut app,
"pueue",
output_directory,
),
};
completion_result.context(format!("Failed to generate completions for {shell:?}"))?;
return Ok(());
}
if let Some(output_directory) = output_directory {
let completion_result = match shell {
Shell::Bash => generate_to(shells::Bash, &mut app, "pueue", output_directory),
Shell::Elvish => generate_to(shells::Elvish, &mut app, "pueue", output_directory),
Shell::Fish => generate_to(shells::Fish, &mut app, "pueue", output_directory),
Shell::PowerShell => {
generate_to(shells::PowerShell, &mut app, "pueue", output_directory)
}
Shell::Zsh => generate_to(shells::Zsh, &mut app, "pueue", output_directory),
Shell::Nushell => generate_to(
clap_complete_nushell::Nushell,
&mut app,
"pueue",
output_directory,
),
};
completion_result.context(format!("Failed to generate completions for {shell:?}"))?;
return Ok(());
}

@Nukesor
Copy link
Owner

Nukesor commented Apr 24, 2024

Yep, not sure how that managed to sneak in there. Feel free to delete that duplicate blob. Probably a copy past error by me when i introduced the feature to print completions to stdout.

Also, could you add nushell to the completions integrationt test :)?

Copy link

Test Results

  3 files   22 suites   2m 39s ⏱️
148 tests 148 ✅ 0 💤 0 ❌
316 runs  316 ✅ 0 💤 0 ❌

Results for commit cc7aedd.

@Tirka
Copy link
Contributor Author

Tirka commented Apr 24, 2024

Also, could you add nushell to the completions integrationt test :)?

The existing test has already been corrected. Should I add something else?

@Nukesor
Copy link
Owner

Nukesor commented Apr 24, 2024

Nice, thanks for the contribution :)
Change looks good to me!

@Nukesor Nukesor merged commit aeb3a0f into Nukesor:main Apr 24, 2024
15 of 16 checks passed
@Tirka Tirka deleted the add-nushell-completions branch April 24, 2024 14:08
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.

2 participants