completions: add SVDIR support for zsh#15
Open
crater2150 wants to merge 1 commit intovoid-linux:masterfrom
Open
completions: add SVDIR support for zsh#15crater2150 wants to merge 1 commit intovoid-linux:masterfrom
crater2150 wants to merge 1 commit intovoid-linux:masterfrom
Conversation
ericonr
reviewed
Jun 5, 2021
completions/sv.zsh
Outdated
| ret=0;; | ||
| args) | ||
| services=( /var/service/*(-/N:t) ) | ||
| if [[ $BUFFER == sudo* ]] then |
Member
There was a problem hiding this comment.
I think it makes sense to also detect at least doas, right?
Author
There was a problem hiding this comment.
I didn't know about doas, good point. I added it and also added su -c.
completions/sv.zsh
Outdated
Comment on lines
38
to
40
| if [[ $BUFFER == sudo\ * | ||
| || $BUFFER == doas\ * | ||
| || $BUFFER == su\ *-c* ]] then |
Member
There was a problem hiding this comment.
Suggested change
| if [[ $BUFFER == sudo\ * | |
| || $BUFFER == doas\ * | |
| || $BUFFER == su\ *-c* ]] then | |
| if [[ $BUFFER == "sudo "* | |
| || $BUFFER == "doas "* | |
| || $BUFFER == "su "*-c* ]] then |
does this work?
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.