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

Command completion for :sh #6727

Open
vp2177 opened this issue Apr 12, 2023 · 5 comments
Open

Command completion for :sh #6727

vp2177 opened this issue Apr 12, 2023 · 5 comments
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-medium Call for participation: Experience needed to fix: Medium / intermediate

Comments

@vp2177
Copy link

vp2177 commented Apr 12, 2023

Typing :sh l<Tab> should display completions for (example) longcommand, ls, ln, etc... based on executables available in PATH, in addition to file/directory name completion.

Similar to, but distinct from #6717

@vp2177 vp2177 added the C-enhancement Category: Improvements label Apr 12, 2023
@pascalkuthe
Copy link
Member

I don't think that's possible, what commands are available depends in the system shell and there is no unified way to obtain completions from those. Crawling $PATH for binaries (if we assumed that there are no builtin shell commands which is not a good assumption at all) is way too slow and super problematic so I don't think thus can be implement

@vp2177
Copy link
Author

vp2177 commented Apr 16, 2023

It can be implemented, that's not the question (it's implemented in other editors like Vim). Is it a good idea? I am saying yes because it's a (minor) improvement to user experience

@the-mikedavis
Copy link
Member

the-mikedavis commented Apr 16, 2023

It can be implemented, that's not the question

Well, Pascal described a way to do it - we're just concerned about the performance: blocking the prompt for a while to scan the PATH is not a good UX. Also, if you're going to assert this it would be helpful to at least link to the code where another editor implements this.

It looks like Kakoune crawls PATH and has a nice way of caching the file lookups per directory: https://github.com/mawww/kakoune/blob/019fbc5439ad884f172c324ebc928463eab9bc74/src/file.cc#L534-L600. It takes a stat of each directory and caches the commands until a directory's mtime changes. The initial lookup could still be a little slow for large PATHs though - it would be nice to figure out the completion candidates async but I think this would be a much larger change. (I think we've discussed that previously but I can't find the issue/discussion.)

@pvarga-dni
Copy link

Crawling $PATH for binaries (if we assumed that there are no builtin shell commands which is not a good assumption at all) is way too slow and super problematic so I don't think thus can be implement

As for shell built-ins, this is not a great solution, but maybe Helix could complete a hard-coded list of POSIX standard built-ins. If the user's shell has additional ones, those won't be completed. Not ideal when the user's shell isn't POSIX compliant, though...

@kirawi kirawi added A-helix-term Area: Helix term improvements E-medium Call for participation: Experience needed to fix: Medium / intermediate labels May 27, 2023
@mo8it
Copy link
Contributor

mo8it commented Feb 27, 2024

Shell completion for Fish can be implemented pretty easily by using the complete --escape -C "…" command. I can implement that if you want.

I wasn't able to find an equivalent for Bash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-medium Call for participation: Experience needed to fix: Medium / intermediate
Projects
None yet
Development

No branches or pull requests

6 participants