2013-03-12 19:00:02 +00:00
|
|
|
function __fish_service_print_names
|
2013-03-12 15:43:52 +00:00
|
|
|
if type -f systemctl >/dev/null
|
|
|
|
command systemctl list-units -t service | cut -d ' ' -f 1 | grep '\.service$' | sed -e 's/\.service$//'
|
|
|
|
end
|
|
|
|
|
|
|
|
command ls /etc/init.d
|
|
|
|
end
|
2005-09-20 13:31:55 +00:00
|
|
|
|
|
|
|
# Fist argument is the names of the service, i.e. a file in /etc/init.d
|
2013-03-12 19:00:02 +00:00
|
|
|
complete -c service -n "test (count (commandline -poc)) = 1" -xa "(__fish_service_print_names)" --description "Service name"
|
2005-09-20 13:31:55 +00:00
|
|
|
|
|
|
|
#The second argument is what action to take with the service
|
|
|
|
complete -c service -n "test (count (commandline -poc)) -gt 1" -xa '$__fish_service_commands'
|
|
|
|
|