Created
September 22, 2017 07:30
/etc/bash_completion.d/sv
This file contains 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
_runit_sv() { | |
local cur prev commands opts services | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
commands="status up down once \ | |
pause cont hup alarm interrupt quit 1 2 term kill exit \ | |
start stop reload restart shutdown \ | |
force-stop force-reload force-restart force-shutdown try-restart check" | |
opts="-w -v" | |
if [ -z "$SVDIR" ]; then | |
services="$(ls -A /etc/service)" | |
else | |
services="$(ls -A "$SVDIR")" | |
fi | |
if [[ ${prev} == "sv" ]]; then | |
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) ) | |
elif [[ ${cur} == -* ]] ; then | |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
else | |
COMPREPLY=( $(compgen -W "${services}" -- ${cur}) ) | |
fi | |
return 0 | |
} | |
complete -F _runit_sv sv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent, thanks! I forked and added "--color=no" so that color codes don't show up in tab completion.