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

Shell completion add nushell support #974

Closed
hustcer opened this issue Sep 19, 2021 · 9 comments
Closed

Shell completion add nushell support #974

hustcer opened this issue Sep 19, 2021 · 9 comments

Comments

@hustcer
Copy link
Contributor

hustcer commented Sep 19, 2021

Hi, Thanks for the great work, and just currently has no completion support for the modern, powerful and elegant NuShell, is there any plan for this? Thx

nu --version
───┬────────────────────┬────────────────────────────────────────────────────────────────────────────────────
 # │      Column0       │                                      Column1
───┼────────────────────┼────────────────────────────────────────────────────────────────────────────────────
 0 │ version            │ 0.37.0
 1 │ build_os           │ macos-x86_64
 2 │ rust_version       │ rustc 1.55.0
 3 │ cargo_version      │ cargo 1.55.0
 4 │ pkg_version        │ 0.37.0
 5 │ build_time         │ 2021-09-14 19:45:30 +00:00
 6 │ build_rust_channel │ release
 7 │ features           │ clipboard-cli, ctrlc, dataframe, default, rustyline, term, trash, uuid, which, zip
 8 │ installed_plugins  │
───┴────────────────────┴────────────────────────────────────────────────────────────────────────────────────
@casey
Copy link
Owner

casey commented Sep 19, 2021

You are most welcome!

Shell completions are currently mostly generated by clap, the argument parsing library. So support for nushell would have to be added to clap, or someone would have to contribute hand-written completion scripts.

@hustcer
Copy link
Contributor Author

hustcer commented Sep 20, 2021

clap-rs/clap#2778

@hustcer
Copy link
Contributor Author

hustcer commented Dec 17, 2021

clap-rs/clap#2778 (comment) Will this help? Thanks

@casey
Copy link
Owner

casey commented Dec 18, 2021

Yup, if clap automatically generated nushell completions, that would definitely help.

@hustcer
Copy link
Contributor Author

hustcer commented Dec 18, 2021

Yup, if clap automatically generated nushell completions, that would definitely help.

I mean the last comment they replied: "If nushell works like bash where you have to write your own parser, #3166 could be a big help towards this." It doesn't look like they are going to provide “automatically generated nushell completions” support in clap

@casey
Copy link
Owner

casey commented Dec 18, 2021

I think that might make it easier on the clap side to implement nushell completion support, but we would still have to wait for it to be implemented there before Just could take advantage of it.

@starthal
Copy link

starthal commented Jul 12, 2023

It looks like Clap has adopted this: https://github.com/clap-rs/clap/tree/master/clap_complete_nushell

Then I imagine this depends on clap v4: #1084

@FrancescElies
Copy link

In the meanwhile you can put the following somewhere in your nushell config

def "nu-complete just" [] {
    (^just --dump --unstable --dump-format json | from json).recipes | transpose recipe data | flatten | where {|row| $row.private == false } | select recipe doc parameters | rename value description
}

# Just: A Command Runner
export extern "just" [
    ...recipe: string@"nu-complete just", # Recipe(s) to run, may be with argument(s)
]

This was stolen from nushell-scripts (now in the link there is a more elaborated version, but I didn't test that yet)

@casey
Copy link
Owner

casey commented May 15, 2024

Clap v4 support was finally merged, so this will make it into the next release!

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

No branches or pull requests

4 participants