Skip to content

Commit

Permalink
completions: add SVDIR support for zsh
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crater2150 committed Jan 20, 2023
1 parent 727b2a5 commit adebada
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion completions/sv.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ cmds)
check
ret=0;;
args)
services=( /var/service/*(-/N:t) )
if [[ $BUFFER == "sudo "*
|| $BUFFER == "doas "*
|| $BUFFER == "su "*-c* ]] then
services=( /var/service/*(-/N:t) )
else
services=( ${SVDIR:-/var/service}/*(-/N:t) )
fi
(( $#services )) && _values services $services && ret=0
[[ $words[CURRENT] = */* ]] && _directories && ret=0
;;
Expand Down

0 comments on commit adebada

Please sign in to comment.