aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/completions/systemctl.fish
diff options
context:
space:
mode:
authorGravatar Valentin-Costel Hăloiu <vially.ichb@gmail.com>2013-05-22 04:14:21 +0300
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-05-25 00:43:03 -0700
commitcdfb5c2bd8505420d9cb2e06f96caadd41c8cd36 (patch)
treea30525792662b6e084a846cd26cb23faf60dc131 /share/completions/systemctl.fish
parent8f9ba2cd094db7eb164a38d704327e230cdcfae0 (diff)
Add systemctl completions
Diffstat (limited to 'share/completions/systemctl.fish')
-rw-r--r--share/completions/systemctl.fish76
1 files changed, 76 insertions, 0 deletions
diff --git a/share/completions/systemctl.fish b/share/completions/systemctl.fish
new file mode 100644
index 00000000..bd696e59
--- /dev/null
+++ b/share/completions/systemctl.fish
@@ -0,0 +1,76 @@
+function __fish_systemctl_services
+ command find /etc/systemd/system -type f -name '*.service' -printf '%f\n'
+ command find /usr/lib/systemd/system -type f -name '*.service' -printf '%f\n'
+end
+
+function __fish_systemctl_sockets
+ command find /etc/systemd/system -type f -name '*.socket' -printf '%f\n'
+ command find /usr/lib/systemd/system -type f -name '*.socket' -printf '%f\n'
+end
+
+function __fish_systemctl_mounts
+ command find /etc/systemd/system -type f -name '*.mount' -printf '%f\n'
+ command find /usr/lib/systemd/system -type f -name '*.mount' -printf '%f\n'
+end
+
+function __fish_systemctl_service_paths
+ command find /etc/systemd/system -type f -name '*.path' -printf '%f\n'
+ command find /usr/lib/systemd/system -type f -name '*.path' -printf '%f\n'
+end
+
+function __fish_systemctl_using_command
+ set cmd (commandline -opc)
+ if [ (count $cmd) -gt 1 ]
+ if [ $argv[1] = $cmd[2] ]
+ return 0
+ end
+ end
+ return 1
+end
+
+# All systemctl commands
+complete -f -c systemctl -n "test (count (commandline -poc)) = 1" -a 'list-units list-sockets start stop reload restart try-restart reload-or-restart reload-or-try-restart isolate kill is-active is-failed status show get-cgroup-attr set-cgroup-attr unset-cgroup-attr set-cgroup help reset-failed list-unit-files enable disable is-enabled reenable preset mask unmask link load list-jobs cancel dump list-dependencies snapshot delete daemon-reload daemon-reexec show-environment set-environment unset-environment default rescue emergency halt poweroff reboot kexec exit suspend hibernate hybrid-sleep switch-root'
+
+#### Units commands
+
+# Start
+complete -f -c systemctl -n "test (count (commandline -poc)) = 1" -a start -d 'Start one or more units'
+complete -f -c systemctl -n '__fish_systemctl_using_command start' -a '(__fish_systemctl_services)' -d 'Service'
+complete -f -c systemctl -n '__fish_systemctl_using_command start' -a '(__fish_systemctl_sockets)' -d 'Socket'
+complete -f -c systemctl -n '__fish_systemctl_using_command start' -a '(__fish_systemctl_mounts)' -d 'Mount'
+complete -f -c systemctl -n '__fish_systemctl_using_command start' -a '(__fish_systemctl_service_paths)' -d 'Path'
+
+# Stop
+complete -f -c systemctl -n "test (count (commandline -poc)) = 1" -a stop -d 'Stop one or more units'
+complete -f -c systemctl -n '__fish_systemctl_using_command stop' -a '(__fish_systemctl_services)' -d 'Service'
+complete -f -c systemctl -n '__fish_systemctl_using_command stop' -a '(__fish_systemctl_sockets)' -d 'Socket'
+complete -f -c systemctl -n '__fish_systemctl_using_command stop' -a '(__fish_systemctl_mounts)' -d 'Mount'
+complete -f -c systemctl -n '__fish_systemctl_using_command stop' -a '(__fish_systemctl_service_paths)' -d 'Path'
+
+# Restart
+complete -f -c systemctl -n "test (count (commandline -poc)) = 1" -a restart -d 'Restart one or more units'
+complete -f -c systemctl -n '__fish_systemctl_using_command restart' -a '(__fish_systemctl_services)' -d 'Service'
+complete -f -c systemctl -n '__fish_systemctl_using_command restart' -a '(__fish_systemctl_sockets)' -d 'Socket'
+complete -f -c systemctl -n '__fish_systemctl_using_command restart' -a '(__fish_systemctl_mounts)' -d 'Mount'
+complete -f -c systemctl -n '__fish_systemctl_using_command restart' -a '(__fish_systemctl_service_paths)' -d 'Path'
+
+# Status
+complete -f -c systemctl -n "test (count (commandline -poc)) = 1" -a status -d 'Runtime status about one or more units'
+complete -f -c systemctl -n '__fish_systemctl_using_command status' -a '(__fish_systemctl_services)' -d 'Service'
+complete -f -c systemctl -n '__fish_systemctl_using_command status' -a '(__fish_systemctl_sockets)' -d 'Socket'
+complete -f -c systemctl -n '__fish_systemctl_using_command status' -a '(__fish_systemctl_mounts)' -d 'Mount'
+complete -f -c systemctl -n '__fish_systemctl_using_command status' -a '(__fish_systemctl_service_paths)' -d 'Path'
+
+# Enable
+complete -f -c systemctl -n "test (count (commandline -poc)) = 1" -a enable -d 'Enable one or more units'
+complete -f -c systemctl -n '__fish_systemctl_using_command enable' -a '(__fish_systemctl_services)' -d 'Service'
+complete -f -c systemctl -n '__fish_systemctl_using_command enable' -a '(__fish_systemctl_sockets)' -d 'Socket'
+complete -f -c systemctl -n '__fish_systemctl_using_command enable' -a '(__fish_systemctl_mounts)' -d 'Mount'
+complete -f -c systemctl -n '__fish_systemctl_using_command enable' -a '(__fish_systemctl_service_paths)' -d 'Path'
+
+# Disable
+complete -f -c systemctl -n "test (count (commandline -poc)) = 1" -a disable -d 'Disable one or more units'
+complete -f -c systemctl -n '__fish_systemctl_using_command disable' -a '(__fish_systemctl_services)' -d 'Service'
+complete -f -c systemctl -n '__fish_systemctl_using_command disable' -a '(__fish_systemctl_sockets)' -d 'Socket'
+complete -f -c systemctl -n '__fish_systemctl_using_command disable' -a '(__fish_systemctl_mounts)' -d 'Mount'
+complete -f -c systemctl -n '__fish_systemctl_using_command disable' -a '(__fish_systemctl_service_paths)' -d 'Path'