summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMélanie Chauvel <perso@hack-libre.org>2021-08-10 16:57:59 +0200
committerMélanie Chauvel <perso@hack-libre.org>2021-10-11 02:26:12 +0200
commit0d645735d7c03c7652e31a1daceb0c59f0c5adc1 (patch)
treea2412f2161d9129e5a9b31bbe3e5dbb5fce357d6
parent6af9e221a4a20066de716e1ef8455b45829ef768 (diff)
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 --
-rw-r--r--completions/bash/exa11
1 files changed, 10 insertions, 1 deletions
diff --git a/completions/bash/exa b/completions/bash/exa
index 5340686..187efe0 100644
--- a/completions/bash/exa
+++ b/completions/bash/exa
@@ -30,8 +30,17 @@ _exa()
esac
case "$cur" in
+ # _parse_help doesn’t pick up short options when they are on the same line than long options
+ --*)
+ # colo[u]r isn’t 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" ) )
;;
*)