2013-03-12 12:00:02 -07:00
|
|
|
function __fish_service_print_names
|
2013-03-12 19:13:52 +03:30
|
|
|
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 23:31:55 +10:00
|
|
|
|
|
|
|
# Fist argument is the names of the service, i.e. a file in /etc/init.d
|
2013-03-12 12:00:02 -07:00
|
|
|
complete -c service -n "test (count (commandline -poc)) = 1" -xa "(__fish_service_print_names)" --description "Service name"
|
2005-09-20 23:31:55 +10: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'
|
|
|
|
|