aboutsummaryrefslogtreecommitdiff
path: root/contrib/completion/hx.bash
blob: 6ef0329e49bd514f3f527698d28c5ff37f33b9c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
# Bash completion script for Helix editor

_hx() {
	# $1 command name
	# $2 word being completed
	# $3 word preceding

	case "$3" in
	-g | --grammar)
		COMPREPLY="$(compgen -W "fetch build" -- $2)"
		;;
	--health)
		local languages=$(hx --health |tail -n '+7' |awk '{print $1}' |sed 's/\x1b\[[0-9;]*m//g')
		COMPREPLY="$(compgen -W "$languages" -- $2)"
		;;
	*)
		COMPREPLY="$(compgen -fd -W "-h --help --tutor -V --version -v -vv -vvv --health -g --grammar --vsplit --hsplit -c --config --log" -- $2)"
		;;
	esac

	local IFS=$'\n'
	COMPREPLY=($COMPREPLY)
} && complete -o filenames -F _hx hx