Skip to content

Commit 7b86124

Browse files
committed
completions: add SVDIR support for zsh
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.
1 parent 727b2a5 commit 7b86124

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

completions/sv.zsh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ cmds)
3535
check
3636
ret=0;;
3737
args)
38-
services=( /var/service/*(-/N:t) )
38+
if [[ $BUFFER == sudo\ *
39+
|| $BUFFER == doas\ *
40+
|| $BUFFER == su\ *-c* ]] then
41+
services=( /var/service/*(-/N:t) )
42+
else
43+
services=( ${SVDIR:-/var/service}/*(-/N:t) )
44+
fi
3945
(( $#services )) && _values services $services && ret=0
4046
[[ $words[CURRENT] = */* ]] && _directories && ret=0
4147
;;

0 commit comments

Comments
 (0)