bash-completion: handle comma-separated options in findmnt
PATCH 1/1 bash-completion: handle comma-separated options in findmnt
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 <[email protected]>
--- bash-completion/findmnt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
bash-completion/findmnt +12 -4
@@ -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')
Signature · 1 line
2.1.4
Karel Zak
maintainerQuoted 2 lines · Boris Egorov
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 :-)
Quoted 1 line
Similar fixes for other utils follow if this one will be merged.
I have no objections, go ahead.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com