summaryrefslogtreecommitdiffstats
path: root/tests/complete.tests
blob: 36a39833643e2b8c18349bed9953a508fe1c728d (plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#  Chet Ramey <chet.ramey@case.edu>
#
#  Copyright 2002-2020 Chester Ramey
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2, or (at your option)
#   any later version.
#
#   TThis program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software Foundation,
#   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

complete

# from zsh, just for testing
complete -A stopped -P '%' bg
complete -j -P '%' fg jobs disown
# this is wrong at this point
complete -j -P '%' -W '$(ps -x | tail +2 | cut -c1-5)' wait
complete -c type
complete -a unalias
complete -v getopts read unset
complete -v -S '=' declare export local readonly typeset
complete -f -- . source
complete -A shopt shopt
complete -e printenv

complete -A helptopic help

complete -c nohup exec nice eval
complete -c -k time

complete -A signal trap kill

complete -f chown ln more cat
complete -d mkdir rmdir

complete -f -X '!*.+(gz|tgz)' gunzip gzcat zcat zmore
complete -f -X '!*.Z' uncompress zmore zcat
complete -f gzip

complete -o dirnames -o filenames -o nospace -d pushd popd

_comp_cd()
{
	local IFS=$' \t\n'	# normalize IFS
	local cur _skipdot _cdpath
	local i j k

	# Tilde expansion, with side effect of expanding tilde to full pathname
	case "$2" in
	\~*)	eval cur="$2" ;;
	*)	cur=$2 ;;
	esac

	# no cdpath or absolute pathname -- straight directory completion
	if [[ -z "${CDPATH:-}" ]] || [[ "$cur" == @(./*|../*|/*) ]]; then
		# compgen prints paths one per line; could also use while loop
		IFS=$'\n'
		COMPREPLY=( $(compgen -d -- "$cur") )
		IFS=$' \t\n'
	# CDPATH+directories in the current directory if not in CDPATH
	else
		IFS=$'\n'
		_skipdot=false
		# preprocess CDPATH to convert null directory names to .
		_cdpath=${CDPATH/#:/.:}
		_cdpath=${_cdpath//::/:.:}
		_cdpath=${_cdpath/%:/:.}
		for i in ${_cdpath//:/$'\n'}; do
			if [[ $i -ef . ]]; then _skipdot=true; fi
			k="${#COMPREPLY[@]}"
			for j in $( compgen -d -- "$i/$cur" ); do
				COMPREPLY[k++]=${j#$i/}		# cut off directory
			done
		done
		$_skipdot || COMPREPLY+=( $(compgen -d -- "$cur") )
		IFS=$' \t\n'
	fi

	# variable names if appropriate shell option set and no completions
	if shopt -q cdable_vars && [[ ${#COMPREPLY[@]} -eq 0 ]]; then
		COMPREPLY=( $(compgen -v -- "$cur") )
	fi

	# append slash to passed directory name that is the only completion.
	# readline will not do this if we complete from CDPATH
	if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
		i=${COMPREPLY[0]}	# shorthand
		if [[ "$cur" == "$i" ]] && [[ "$i" != "*/" ]]; then
			COMPREPLY[0]+=/
		fi
	fi
	return 0
}

complete -o filenames -o nospace -o bashdefault -F _comp_cd cd

complete -A hostname rsh telnet rlogin ftp

complete -u su
complete -W '"${GROUPS[@]}"' newgrp
complete -g groupdel groupmod

complete -f -X '!*.+(ps|PS)' gs gv ghostview
complete -f -X '!*.dvi' dvips xdvi
complete -f -X '!*.pdf' acroread

complete -f -X '!*.texi*' makeinfo texi2dvi texi2html

complete -c gdb make

complete -p gs
complete -p

complete -r xdvi
complete -r notthere

complete -r
complete