-
-
Notifications
You must be signed in to change notification settings - Fork 14
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 tab completions #615
Comments
I agree that shell completion would be handy, yes. What the actual implementation should look, I personally have no idea. But I like the idea. |
I'd like tab completions too, and the idea of using When running a plain I'd already created issue #364 for this feature. But this issue goes into more depth, and I believe it's still not possible to move comments to another issue. So let's just use this one. No problem. |
Do you want to discuss here, or in the Slack #configlet channel? |
I propose adding a This completions directory would be added to the artifact zip/tgz file, so they are automatically downloaded and unarchived into the repo's bin/ directory: $ bin/fetch-configlet
$ tree bin
bin
├── completions
│ ├── configlet.bash
│ ├── configlet.fish
│ └── configlet.zsh
├── configlet
├── fetch-configlet
├── fetch-configlet.ps1
... The if command -v getent; then
user_shell=$(getent passwd "$USER" | cut -d: -f6)
elif command -f finger; then
user_shell=$(finger "$USER" | sed -nE '/.*Shell: / { s///; s/ .*//; p; }')
elif [[ -f /etc/passwd ]]; then
user_shell=$(awk -F: -v u="$USER" '$1 == u {print $6}' /etc/passwd)
fi
case "$user_shell" in
*/fish) echo "Enable completions: source bin/completions/configlet.fish" ;;
*/bash) echo "Enable completions: . bin/completions/configlet.bash" ;;
*/zsh) echo "Enable completions: . bin/completions/configlet.zsh" ;;
esac This proposal removes the need for a command-line option on the fetch-configlet script. |
The fish completions look like: https://github.com/glennj/my-configs/blob/main/fish/completions/configlet.fish |
I don't know PowerShell: does it have a completion mechanism? |
@kotp you posted in the Slack channel... |
@ErikSchierboom since the fetch-configlet script is distributed to all tracks, would you want
? |
@glennj Yes, I think separate changes would make sense. |
Sorry, I didn't have the bandwidth to think about this earlier. @glennj @ErikSchierboom What do we think about using the approach of That is: embed the completions in the configlet binary, rather than writing extra files at extraction time. I think I'd prefer to avoid writing a For people that work on multiple tracks, it seems nicer to avoid the duplication, and potentially make it harder for the completions to go out of sync with the configlet binary. That said, I'm not sure if "a user sources completions in one track directory, and then runs a newer configlet in another track directory later" is more likely than "a user sources completions generated by an older configlet binary in one track directory, and run a newer configlet in another track directory later". And if people are adding We could still detect the user's shell when running configlet completion -s fish > ~/.config/fish/completions/configlet.fish If we preferred that way, it doesn't block #629. I imagine I'll be able to merge that PR as-is or nearly as-is - I just haven't finished reviewing it yet (sorry). So I'm just asking if we'd like a follow-up PR that reads and embeds the completion files at compile time, and makes |
I quite like that. Seems like an elegant solution. |
Agreed. I'm curious how that'll be implemented. |
Instead, it looks like we'll bake the completions into the configlet binary via a new subcommand [1]. [1] exercism#615 (comment)
For later: - Add completions for zsh and PowerShell. - Make `fetch-configlet` detect the user's shell and explain how to install completions. - Make `configlet completion -s <shell>` print the corresponding completion script to stdout. This commit also refactors `create-artifact` slightly. Closes: #615 Co-authored-by: ee7 <45465154+ee7@users.noreply.github.com>
For now, I'll propose the simple approach in #631. Pretty much just The approach with one more level of abstraction is #639. That'd also be mostly |
And to be more fancy, it's easy to embed compressed versions of the completion scripts. See #652. |
I've been building a track, so I've been using configlet a lot. With the plethora of subcommands and options, I figured tab completion would be handy. My shell is fish, so that's where I started.
But then I thought "how to install the completions"? How about this: add an option to
fetch-configlet
to download a shell-specific completions file, and emit instructions on how to source it into the user's shell.Example:
Do you think this would be useful?
The text was updated successfully, but these errors were encountered: