-
Notifications
You must be signed in to change notification settings - Fork 75
/
bash-completion.sh
60 lines (51 loc) · 1.54 KB
/
bash-completion.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
# Temporary usage:
# Run: source ./scripts/bash-completion.sh
#
# Permanent usage:
# Run: echo "source $(readlink -f .)/scripts/bash-completion.sh" >> ~/.bash_completion
_goblint ()
{
IFS=$'\n'
COMPREPLY=($(${COMP_WORDS[0]} --complete "${COMP_WORDS[@]:1:COMP_CWORD}"))
}
complete -o default -F _goblint goblint
_regtest ()
{
IFS=$'\n'
case $COMP_CWORD in
1)
COMPREPLY=($(ls -1 tests/regression/ | sed -n -r 's/([0-9][0-9])-.*/\1/p' | grep "^${COMP_WORDS[1]}"))
;;
2)
COMPREPLY=($(ls -1 tests/regression/${COMP_WORDS[1]}-* | sed -n -r 's/([0-9][0-9])-.*/\1/p' | grep "^${COMP_WORDS[2]}"))
;;
*)
COMPREPLY=($($(dirname ${COMP_WORDS[0]})/goblint --complete "${COMP_WORDS[@]:3:COMP_CWORD}"))
;;
esac
}
complete -o default -F _regtest regtest.sh
_update_suite ()
{
IFS=$'\n'
case $COMP_CWORD in
1)
COMPREPLY=($(ls -1 tests/regression/*/*.c | sed -n -r 's|.*/([0-9][0-9])-(.*)\.c|\2|p' | grep "^${COMP_WORDS[1]}"))
if [[ "group" =~ ^${COMP_WORDS[1]} ]]; then
COMPREPLY+=("group")
fi
;;
2)
if [[ ${COMP_WORDS[1]} == "group" ]] ; then
COMPREPLY=($(ls -1 tests/regression/ | sed -n -r 's/([0-9][0-9])-(.*)/\2/p' | grep "^${COMP_WORDS[2]}"))
else
COMPREPLY=()
fi
;;
*)
COMPREPLY=()
;;
esac
}
complete -F _update_suite update_suite.rb