Skip to content

Instantly share code, notes, and snippets.

@robbieh
Forked from WoodenDoors/sv.bash
Created November 12, 2017 22:18
Show Gist options
  • Save robbieh/bccfcae3ed6496fca5b4a28738c24933 to your computer and use it in GitHub Desktop.
Save robbieh/bccfcae3ed6496fca5b4a28738c24933 to your computer and use it in GitHub Desktop.
/etc/bash_completion.d/sv
_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 --color=no -A /etc/service)"
else
services="$(ls --color=no -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
@robbieh
Copy link
Author

robbieh commented Nov 12, 2017

Stop ls from printing color codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment