From 7af9e1f5c5bfe9b295309094fb03ef27ee6ca1fd Mon Sep 17 00:00:00 2001 From: "Frederik “Freso” S. Olesen" Date: Fri, 27 May 2016 12:19:01 +0200 Subject: Split off __fish_complete_blockdevice from mount.fish. The __fish_complete_blockdevice function can be useful to other completions than mount.fish, so it should live on its own so its available to those. --- share/completions/mount.fish | 8 -------- share/functions/__fish_complete_blockdevice.fish | 12 ++++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 share/functions/__fish_complete_blockdevice.fish diff --git a/share/completions/mount.fish b/share/completions/mount.fish index ba0d985f..9375a473 100644 --- a/share/completions/mount.fish +++ b/share/completions/mount.fish @@ -1,12 +1,4 @@ # Completions for mount -function __fish_complete_blockdevice - set -l cmd (commandline -ct) - [ "" = "$cmd" ]; and return - for f in $cmd* - [ -b $f ]; and printf "%s\t%s\n" $f "Block device" - [ -d $f ]; and printf "%s\n" $f/ - end -end complete -x -c mount -a '(__fish_complete_blockdevice)' # In case `mount UUID=` and similar also works diff --git a/share/functions/__fish_complete_blockdevice.fish b/share/functions/__fish_complete_blockdevice.fish new file mode 100644 index 00000000..d07487de --- /dev/null +++ b/share/functions/__fish_complete_blockdevice.fish @@ -0,0 +1,12 @@ +# Helper function for completions that need to enumerate block devices. +function __fish_complete_blockdevice + set -l cmd (commandline -ct) + test "" = "$cmd" + and return + for f in $cmd* + test -b $f + and printf "%s\t%s\n" $f "Block device" + test -d $f + and printf "%s\n" $f/ + end +end -- cgit v1.2.3