about summary refs log tree commit diff stats
path: root/wip/tab-compl.sh
blob: 459797ac133af46de911c6bc7a8c63bdf290c3ea (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
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash

option_one() {
	set -o emacs
	bind 'set show-all-if-ambiguous on'
	bind 'set completion-ignore-case on'

	COMP_WORDBREAKS=${COMP_WORDBREAKS//:/}

	bind 'TAB:dynamic-complete-history'

	urls=(http://example.com http://sample.net http://example.org)

	for i in "${urls[@]}"; do
		history -s "$i"
	done

	echo "${urls[@]}"

	compgen -W "${urls[@]}" http://sa
	read -rep "> "

	echo "$REPLY"
}

tab(){ # requires bash 4+
	READLINE_LINE=foobar
	READLINE_POINT="${#READLINE_LINE}"
}

option_two() {
	set -o emacs
	bind -x '"\t":"tab"'
	read -rep "> "
}

option_two "$@"