File: libcap-ng.bash_completion

package info (click to toggle)
libcap-ng 0.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 776 kB
  • sloc: ansic: 7,464; makefile: 188; python: 161; sh: 24
file content (85 lines) | stat: -rw-r--r-- 1,403 bytes parent folder | download
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
_pscap()
{
	local cur prev
	local opts="-a -p --tree"

	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"

	case "$prev" in
	-p)
		COMPREPLY=( $(compgen -W "$(ps -eo pid= 2>/dev/null)" \
			-- "$cur") )
		return 0
		;;
	esac

	if [[ "$cur" == -* ]]; then
		COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
	fi
}

_netcap()
{
	local cur
	local opts="--advanced --json"

	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"

	if [[ "$cur" == -* ]]; then
		COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
	fi
}

_filecap()
{
	local cur prev
	local opts="-a -d"

	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"

	if [[ "$cur" == -* ]]; then
		COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
		return 0
	fi

	case "$prev" in
	-a|-d)
		return 0
		;;
	esac

	if [[ "$cur" == /* ]]; then
		COMPREPLY=( $(compgen -d -- "$cur") $(compgen -f -- "$cur") )
	fi
}

_cap_audit()
{
	local cur prev
	local opts="-v --verbose -j --json -y --yaml --"

	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"

	if [[ "$prev" == "--" ]]; then
		COMPREPLY=( $(compgen -c -- "$cur") )
		return 0
	fi

	if [[ "$cur" == -* ]]; then
		COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
	else
		COMPREPLY=( $(compgen -c -- "$cur") )
	fi
}

complete -F _pscap pscap
complete -F _netcap netcap
complete -F _filecap filecap
complete -F _cap_audit cap-audit