Sun, 24 Feb 2019 14:55:59 +0100
fixes todo: use scstr instead of sstr
431
1e8592657a01
adds semi-functional bash completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | dav_completion() { |
434
bc173bae3caa
improves dav-bash-completion.bash
Mike Becker <universe@uap-core.de>
parents:
431
diff
changeset
|
2 | local davcmd |
bc173bae3caa
improves dav-bash-completion.bash
Mike Becker <universe@uap-core.de>
parents:
431
diff
changeset
|
3 | local out |
bc173bae3caa
improves dav-bash-completion.bash
Mike Becker <universe@uap-core.de>
parents:
431
diff
changeset
|
4 | local cmd_res |
bc173bae3caa
improves dav-bash-completion.bash
Mike Becker <universe@uap-core.de>
parents:
431
diff
changeset
|
5 | |
457
0eabb741d5d3
fixes dav completion not working with (escaped) spaces
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
6 | davcmd="${COMP_WORDS[0]} complete $COMP_CWORD ${COMP_WORDS[@]}" |
0eabb741d5d3
fixes dav completion not working with (escaped) spaces
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
7 | out=$(eval $davcmd) |
435
def0359fb48f
adds some error detection to completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
434
diff
changeset
|
8 | cmd_res=$? |
434
bc173bae3caa
improves dav-bash-completion.bash
Mike Becker <universe@uap-core.de>
parents:
431
diff
changeset
|
9 | |
435
def0359fb48f
adds some error detection to completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
434
diff
changeset
|
10 | if [ $cmd_res == 10 ]; then |
def0359fb48f
adds some error detection to completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
434
diff
changeset
|
11 | compopt -o nospace |
def0359fb48f
adds some error detection to completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
434
diff
changeset
|
12 | fi |
def0359fb48f
adds some error detection to completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
434
diff
changeset
|
13 | if [ $cmd_res == 12 ]; then |
def0359fb48f
adds some error detection to completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
434
diff
changeset
|
14 | compopt -o default |
def0359fb48f
adds some error detection to completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
434
diff
changeset
|
15 | COMPREPLY=() |
def0359fb48f
adds some error detection to completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
434
diff
changeset
|
16 | else |
434
bc173bae3caa
improves dav-bash-completion.bash
Mike Becker <universe@uap-core.de>
parents:
431
diff
changeset
|
17 | IFS=$'\n' declare -ga 'COMPREPLY=($out)' |
435
def0359fb48f
adds some error detection to completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
434
diff
changeset
|
18 | fi |
431
1e8592657a01
adds semi-functional bash completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | } |
1e8592657a01
adds semi-functional bash completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | |
435
def0359fb48f
adds some error detection to completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
434
diff
changeset
|
21 | complete -F dav_completion dav |
def0359fb48f
adds some error detection to completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
434
diff
changeset
|
22 |