File: bart_completion.sh

package info (click to toggle)
bart-cuda 0.8.00-2
  • links: PTS, VCS
  • area: contrib
  • in suites: bookworm, sid
  • size: 7,752 kB
  • sloc: ansic: 100,267; python: 717; makefile: 576; sh: 564; cpp: 104
file content (44 lines) | stat: -rw-r--r-- 826 bytes parent folder | download | duplicates (7)
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
# bart parameter-completion



function _bart()
{
	local cur=${COMP_WORDS[$COMP_CWORD]}

	if [ $COMP_CWORD -eq 1 ] ; then

		local CMDS=$(bart | tail -n +2)
		COMPREPLY=($(compgen -W "$CMDS" -- "$cur"));

	else

		local bcmd=${COMP_WORDS[1]}

		case $cur in
		-*)
			COMPREPLY=($(bart ${bcmd} -h | grep -o -E "^${cur}\w*"))
			;;
		*)
			case $bcmd in
			twixread)
				COMPREPLY=($(compgen -o plusdirs -f -X '!*.dat' -- ${cur}))
				;;
			*)
				local CFLS=$(compgen -o plusdirs -f -X '!*.hdr' -- ${cur})
				local COOS=$(compgen -o plusdirs -f -X '!*.coo' -- ${cur});
				local RAS=$(compgen -o plusdirs -f -X '!*.ra' -- ${cur});
				local suffix=".hdr"
				COMPREPLY=($(for i in ${CFLS} ${COOS} ${RAS}; do echo ${i%$suffix} ; done))
				;;
			esac

			;;
		esac
	fi

	return 0
}

complete -o filenames -F _bart bart ./bart