Source
# launchctl(1) completion -*- shell-script -*-
_launchctl()
{
local cur prev words cword
_init_completion || return
local oslevel
oslevel=${OSTYPE//darwin/}
oslevel=${oslevel%%.*}
COMPREPLY=()
if [[ $cword -eq 1 ]]; then
local commands
commands="load unload start stop list setenv unsetenv \
getenv export limit shutdown getrusage log umask help"
if [[ $oslevel -le 8 ]]; then
commands+=" reloadttys stdout stderr"
fi
if [[ $oslevel -ge 9 ]]; then
commands+=" submit remove bootstrap singleuser bsexec bslist"
if [[ $oslevel -ge 10 ]]; then
commands+=" bstree managerpid manageruid managername"
fi
fi
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
else
local command
command=${words[1]}
case "$command" in
load|unload)
case $prev in
-S)
COMPREPLY=( $( compgen -W "Aqua LoginWindow Background StandardIO System" -- $cur ) )
;;
-D)
COMPREPLY=( $( compgen -W "system local network all user" -- $cur ) )
;;
*)
opts="-w"
if [[ $oslevel -ge 0 ]]; then
opts+=" -S -D"
if [[ $command = load ]]; then
opts+=" -F"
fi
fi
COMPREPLY=( $( compgen -f -W "$opts" -- $cur ) )
;;
esac
;;
start|stop|remove|list)
local jobs opts
if [[ $command != list || $oslevel -ge 9 ]]; then
if [[ $oslevel -le 8 ]]; then
jobs="$( launchctl list )"
else