summaryrefslogtreecommitdiff
path: root/smartcd.test
blob: 517ffe8188f3c3060e6de9ab910cd26f4ae16445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# could work like 'z' ?
#
	// "complete -C /usr/bin/argv forge" bash ENV values:
	//    * `COMP_LINE`: A string containing the entire current command line (forge first second third forth ). This is what you are looking for.
	//    * `COMP_POINT`: A number indicating the cursor's position (index) within the COMP_LINE.
	//    * `COMP_WORDS`: An array in Bash (seen differently by Go) containing each individual word on the command line.
	//    * `COMP_CWORD`: A number indicating the index of the word the cursor is currently on within the COMP_WORDS array.

_cd_complete()
{
	# sets local to this func vars
	local cur prev all
	cur=${COMP_WORDS[COMP_CWORD]}
	# prev=${COMP_WORDS[COMP_CWORD-1]}
	all=${COMP_WORDS[@]}

	# this is where we generate the go-arg output
        GOARGS=$(smartcd --auto-complete \'$cur\' $all)

	# this compares the command line input from the user
	# to whatever strings we output
        COMPREPLY=( $(compgen -W "$GOARGS" -- $cur) )  # THIS WORKS
	return 0
}
complete -F _cd_complete cd