From 121c70cf399716d4543adfc1bf7e69565405f8dd Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 27 Jun 2018 14:12:52 -0500 Subject: [PATCH] Add completions for FreeBSD's `kldunload` Lists currently loaded kernel modules as valid completions, and obtains a description via the newly minted `__fish_whatis` if available. --- CHANGELOG.md | 1 + share/completions/kldunload.fish | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 share/completions/kldunload.fish diff --git a/CHANGELOG.md b/CHANGELOG.md index cc3d85787..ca637b2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ This section is for changes merged to the `major` branch that are not also merge - `j` (autojump #4344) - `jhipster` (#4472) - `kldload` + - `kldunload` - `meson` - `ngrok` (#4642) - `optipng` diff --git a/share/completions/kldunload.fish b/share/completions/kldunload.fish new file mode 100644 index 000000000..d2db86e12 --- /dev/null +++ b/share/completions/kldunload.fish @@ -0,0 +1,12 @@ +function __fish_list_loaded_klds + set -l klds (kldstat | string match -r '\b\S+.ko$') + for kld in $klds + if set -l description (__fish_whatis (string replace '.ko' '' -- $kld) "kernel module") + printf '%s\t%s\n' $kld $description + else + printf '%s\n' $kld + end + end +end + +complete -c kldunload -xa '(__fish_list_loaded_klds)'