Add short flags and fix broken flags in bash completion

- Parse help manually to be able to find short options
- Correctly propose options starting with colo[u]r
- Propose short options after - and long after --
This commit is contained in:
Mélanie Chauvel 2021-08-10 16:57:59 +02:00
parent 6af9e221a4
commit 0d645735d7

View File

@ -30,8 +30,17 @@ _exa()
esac
case "$cur" in
# _parse_help doesnt pick up short options when they are on the same line than long options
--*)
# colo[u]r isnt parsed correctly so we filter these options out and add them by hand
parse_help=$( exa --help | grep -oE ' (\-\-[[:alnum:]@-]+)' | tr -d ' ' | grep -v '\-\-colo' )
completions=$( echo '--color --colour --color-scale --colour-scale' $parse_help )
COMPREPLY=( $( compgen -W "$completions" -- "$cur" ) )
;;
-*)
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
completions=$( exa --help | grep -oE ' (\-[[:alnum:]@])' | tr -d ' ' )
COMPREPLY=( $( compgen -W "$completions" -- "$cur" ) )
;;
*)