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

completions: add SVDIR support for zsh #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

crater2150
Copy link

Moved from void-linux/void-packages#28790

Allows sv's completion to complete other service directories, e.g. for per-user services.
If the $SVDIR environment variable is set and sv isn't used with sudo, the completion is changed to complete services from $SVDIR. Otherwise behaviour is unchanged.

I currently have only implemented the change for zsh. In bash, the sudo completion modifies variables so that the completion of the following command doesn't "see" the sudo in the beginning. I'm still looking for ways to detect sudo in bash.

@@ -35,7 +35,11 @@ cmds)
check
ret=0;;
args)
services=( /var/service/*(-/N:t) )
if [[ $BUFFER == sudo* ]] then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to also detect at least doas, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about doas, good point. I added it and also added su -c.

Comment on lines 38 to 40
if [[ $BUFFER == sudo\ *
|| $BUFFER == doas\ *
|| $BUFFER == su\ *-c* ]] then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [[ $BUFFER == sudo\ *
|| $BUFFER == doas\ *
|| $BUFFER == su\ *-c* ]] then
if [[ $BUFFER == "sudo "*
|| $BUFFER == "doas "*
|| $BUFFER == "su "*-c* ]] then

does this work?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, those should be equivalent, just a style difference. Wasn't sure which one is preferred, as similar globs in the repo don't have spaces. I'll update it.

Allows sv's completion to complete other service directories, e.g. for
per-user services.

Currently only zsh, because it is easier than in bash to detect, if the
command is prefixed with sudo/doas/su.
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.

3 participants