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 completions #127

Closed
acrisci opened this issue Mar 16, 2019 · 7 comments
Closed

shell completions #127

acrisci opened this issue Mar 16, 2019 · 7 comments

Comments

@acrisci
Copy link
Member

acrisci commented Mar 16, 2019

It would be cool if you could have shell completions in the binary and use them in your shell rc file like this:

# in ~/.zshrc
eval $(playerctl completions zsh)
@MarkusG
Copy link
Contributor

MarkusG commented Oct 5, 2019

Should completions be auto-generated? This would avoid having to manually edit completion scripts, but also might require some restructuring of existing code.

Alternatively, completions could be stored in their own file and not included in the binary. This would allow users to source a file rather than invoke playerctl every time they start their shell.

@acrisci
Copy link
Member Author

acrisci commented Oct 6, 2019

Should completions be auto-generated?

What would the approach to this be? I don't want to add a runtime dependency for this.

This would allow users to source a file rather than invoke playerctl every time they start their shell.

There would be ways to implement this command without storing the completions in the binary such as reading from a well-known path.

@MarkusG
Copy link
Contributor

MarkusG commented Oct 6, 2019

The approach I started with was to start by moving the player_commands array out of the playerctl-cli.c file and into a new playerctl-cli.h header, then make a playerctl-completions.c file to generate the completion script. That way if a new command is added to the player_commands array, the completion script will automatically reflect those changes.

Thinking through that, though, it seems pretty convoluted and it would be a lot of work for very little accomplishment.

The idea behind putting them in their own file would be that the user never has to invoke playerctl at all when starting their shell. How much that actually matters is debatable, but personally I don't like the idea of running a program like playerctl in my shell rc.

@acrisci
Copy link
Member Author

acrisci commented Oct 6, 2019

The approach I started with was to start by moving the...

I like the idea in general, but I think it's beyond the scope of this project to put the generator in playerctl itself. It might be interesting to think about some sort of DSL or introspection mechanism that could generate completions from configuration at compile time. I have some other projects where that would be useful too.

I don't like the idea of running a program like playerctl in my shell rc.

We can accommodate that.

@MarkusG
Copy link
Contributor

MarkusG commented Oct 6, 2019

We can accommodate that.

That's true. In the end, if the user just wants to source a file when their shell starts, they can playerctl completions bash > somefile and source somefile.

@jwflory
Copy link
Contributor

jwflory commented Feb 15, 2020

The Fedora package now installs the Bash completions:

https://src.fedoraproject.org/rpms/playerctl/c/c4bf63d086f49d9f9e101c5726d0ad4074127c4f?branch=master

@acrisci
Copy link
Member Author

acrisci commented Oct 30, 2020

There's a compatibility mode for zsh, so this is good enough for me.

autoload bashcompinit
bashcompinit
source /usr/share/bash-completion/completions/playerctl.bash

@acrisci acrisci closed this as completed Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants