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