chiark / gitweb /
zsh completion: add _kernel-install
authorDaniel Wallace <danielwallace@gtmanfred.com>
Sat, 3 Aug 2013 02:38:14 +0000 (21:38 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 3 Aug 2013 13:20:12 +0000 (09:20 -0400)
Makefile.am
shell-completion/zsh/_kernel-install [new file with mode: 0644]

index 1d7abfd61f7a40ca386eb3f4b5ebbee075b12714..b9c283503cff092f7fa1ad925e4809bebccab796 100644 (file)
@@ -347,6 +347,7 @@ dist_zshcompletion_DATA = \
        shell-completion/zsh/_systemctl \
        shell-completion/zsh/_journalctl \
        shell-completion/zsh/_udevadm \
+       shell-completion/zsh/_kernel-install \
        shell-completion/zsh/_systemd-nspawn \
        shell-completion/zsh/_systemd-analyze \
        shell-completion/zsh/_systemd
diff --git a/shell-completion/zsh/_kernel-install b/shell-completion/zsh/_kernel-install
new file mode 100644 (file)
index 0000000..0655188
--- /dev/null
@@ -0,0 +1,26 @@
+#compdef kernel-install
+
+_images(){
+    if [[ "$words[2]" == "remove" ]]; then
+        _message 'No more options'
+    else
+        _path_files -W /boot/ -P /boot/ -g "vmlinuz-*"
+    fi
+}
+
+_kernels(){
+    read _MACHINE_ID < /etc/machine-id
+    _kernel=( /lib/modules/[0-9]* )
+    if [[ "$cmd" == "remove" && -n "$_MACHINE_ID" ]]; then
+        _kernel=( /lib/modules/[0-9]* "/boot/$_MACHINE_ID"/[0-9]* )
+    fi
+    _kernel=( ${_kernel##*/} )
+    _describe "installed kernels" _kernel
+}
+
+_arguments \
+    '1::add or remove:(add remove)' \
+    '2::kernel versions:_kernels' \
+    '3::kernel images:_images'
+
+#vim: set ft=zsh sw=4 ts=4 et