Debian Codegraph @

contrib/completion/hx.bash

raw symbols SCIP
1 #!/usr/bin/env bash
2 # Bash completion script for Helix editor
3
4 _hx() {
5 local cur prev languages
6 COMPREPLY=()
7 cur="${COMP_WORDS[COMP_CWORD]}"
8 prev="${COMP_WORDS[COMP_CWORD - 1]}"
9
10 case "$prev" in
11 -g | --grammar)
12 mapfile -t COMPREPLY < <(compgen -W 'fetch build' -- "$cur")
13 return 0
14 ;;
15 --health)
16 languages=$(hx --health all-languages | tail -n '+2' | awk '{print $1}' | sed 's/\x1b\[[0-9;]*m//g')
17 mapfile -t COMPREPLY < <(compgen -W """clipboard languages all-languages all $languages""" -- "$cur")
18 return 0
19 ;;
20 esac
21
22 case "$2" in
23 -*)
24 mapfile -t COMPREPLY < <(compgen -W "-h --help --strict --tutor -V --version -v -vv -vvv --health -g --grammar --vsplit --hsplit -c --config --log" -- """$2""")
25 return 0
26 ;;
27 *)
28 mapfile -t COMPREPLY < <(compgen -fd -- """$2""")
29 return 0
30 ;;
31 esac
32 } && complete -o filenames -F _hx hx