From: Boris Egorov <egorov@linux.com>
To: util-linux@vger.kernel.org
Cc: Boris Egorov <egorov@linux.com>
Subject: [PATCH] bash-completion: handle comma-separated options in findmnt
Date: Sun, 31 May 2015 00:01:16 +0600 [thread overview]
Message-ID: <1433008876-8622-1-git-send-email-egorov@linux.com> (raw)
So, I discovered a way to complete comma-separated options. This
solution can become messy when you have too many values listed.
Similar fixes for other utils follow if this one will be merged.
Signed-off-by: Boris Egorov <egorov@linux.com>
---
bash-completion/findmnt | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/bash-completion/findmnt b/bash-completion/findmnt
index cf66565..3ad9147 100644
--- a/bash-completion/findmnt
+++ b/bash-completion/findmnt
@@ -43,15 +43,23 @@ _findmnt_module()
return 0
;;
'-o'|'--output')
- # FIXME: how to append to a string with compgen?
- local OUTPUT
- OUTPUT="SOURCE TARGET FSTYPE OPTIONS VFS-OPTIONS
+ local prefix realcur OUTPUT_ALL OUTPUT
+ realcur="${cur##*,}"
+ prefix="${cur%$realcur}"
+
+ OUTPUT_ALL="SOURCE TARGET FSTYPE OPTIONS VFS-OPTIONS
FS-OPTIONS LABEL UUID PARTLABEL PARTUUID
MAJ\:MIN ACTION OLD-TARGET OLD-OPTIONS
SIZE AVAIL USED USE% FSROOT TID ID
OPT-FIELDS PROPAGATION FREQ PASSNO"
+
+ for WORD in $OUTPUT_ALL; do
+ if ! [[ $prefix == *"$WORD"* ]]; then
+ OUTPUT="$WORD $OUTPUT"
+ fi
+ done
compopt -o nospace
- COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+ COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) )
return 0
;;
'-t'|'--types')
--
2.1.4
next reply other threads:[~2015-05-30 18:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-30 18:01 Boris Egorov [this message]
2015-06-02 10:34 ` [PATCH] bash-completion: handle comma-separated options in findmnt Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433008876-8622-1-git-send-email-egorov@linux.com \
--to=egorov@linux.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox