PageRenderTime 26ms CodeModel.GetById 23ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/bash_completion_lib/complete -o filenames/apt-build

http://github.com/brinkman83/bashrc
#! | 71 lines | 54 code | 17 blank | 0 comment | 0 complexity | 20895fd763d869fd0d694ce4a2e4dded MD5 | raw file
 1# Debian apt-build(1) completion.
 2
 3
 4comp_include _comp_dpkg_installed_packages _filedir _get_cword
 5
 6
 7_apt_build()
 8{
 9	local cur prev special i
10
11	COMPREPLY=()
12	cur=`_get_cword`
13	prev=${COMP_WORDS[COMP_CWORD-1]}
14
15	for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
16		if [[ ${COMP_WORDS[i]} == @(install|remove|source|info|clean) ]]; then
17			special=${COMP_WORDS[i]}
18		fi
19	done
20
21	if [ -n "$special" ]; then
22		case $special in
23		@(install|source|info))
24			COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
25			return 0
26			;;
27		remove)
28			COMPREPLY=( $( _comp_dpkg_installed_packages \
29					$cur ) )
30			return 0
31			;;
32		*)
33			return 0
34			;;
35		esac
36	fi
37
38	case "$prev" in
39
40	     --@(patch|build-dir|repository-dir))
41		   _filedir
42		   return 0
43		   ;;
44 
45	     -@(h|-help))
46		   return 0
47		   ;;
48
49	esac
50
51	if [[ "$cur" == -* ]]; then
52	    COMPREPLY=( $( compgen -W '--help --show-upgraded -u --build-dir \
53				  --repository-dir --build-only \
54				  --build-command --reinstall --rebuild \
55				  --remove-builddep --no-wrapper --purge \
56				  --patch --patch-strip -p --yes -y \
57				  --version -v --no-source' -- $cur ) )
58
59	else
60	    COMPREPLY=( $( compgen -W 'update upgrade install remove \
61				  source dist-upgrade world clean info \
62				  clean-build update-repository ' -- $cur ) )
63	fi
64
65
66	return 0
67}
68
69comp_install -F _apt_build  # Make completion persistent for subsequent invocations
70
71_apt_build  # Generate completions for first invocation