* [PATCH] bash-completion: handle comma-separated options in findmnt
@ 2015-05-30 18:01 Boris Egorov
2015-06-02 10:34 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Boris Egorov @ 2015-05-30 18:01 UTC (permalink / raw)
To: util-linux; +Cc: Boris Egorov
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bash-completion: handle comma-separated options in findmnt
2015-05-30 18:01 [PATCH] bash-completion: handle comma-separated options in findmnt Boris Egorov
@ 2015-06-02 10:34 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2015-06-02 10:34 UTC (permalink / raw)
To: Boris Egorov; +Cc: util-linux
On Sun, May 31, 2015 at 12:01:16AM +0600, Boris Egorov wrote:
> So, I discovered a way to complete comma-separated options. This
> solution can become messy when you have too many values listed.
Yes, it's little bit messy, but it's still better than nothing :-)
> Similar fixes for other utils follow if this one will be merged.
I have no objections, go ahead.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-02 10:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-30 18:01 [PATCH] bash-completion: handle comma-separated options in findmnt Boris Egorov
2015-06-02 10:34 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox