1 # Chet Ramey <chet.ramey@case.edu>
3 # Copyright 2002-2020 Chester Ramey
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # TThis program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 # from zsh, just for testing
22 complete -A stopped -P '%' bg
23 complete -j -P '%' fg jobs disown
24 # this is wrong at this point
25 complete -j -P '%' -W '$(ps -x | tail +2 | cut -c1-5)' wait
28 complete -v getopts read unset
29 complete -v -S '=' declare export local readonly typeset
30 complete -f -- . source
31 complete -A shopt shopt
34 complete -A helptopic help
36 complete -c nohup exec nice eval
39 complete -A signal trap kill
41 complete -f chown ln more cat
42 complete -d mkdir rmdir
44 complete -f -X '!*.+(gz|tgz)' gunzip gzcat zcat zmore
45 complete -f -X '!*.Z' uncompress zmore zcat
48 complete -o dirnames -o filenames -o nospace -d pushd popd
52 local IFS=$' \t\n' # normalize IFS
53 local cur _skipdot _cdpath
56 # Tilde expansion, with side effect of expanding tilde to full pathname
62 # no cdpath or absolute pathname -- straight directory completion
63 if [[ -z "${CDPATH:-}" ]] || [[ "$cur" == @(./*|../*|/*) ]]; then
64 # compgen prints paths one per line; could also use while loop
66 COMPREPLY=( $(compgen -d -- "$cur") )
68 # CDPATH+directories in the current directory if not in CDPATH
72 # preprocess CDPATH to convert null directory names to .
73 _cdpath=${CDPATH/#:/.:}
74 _cdpath=${_cdpath//::/:.:}
75 _cdpath=${_cdpath/%:/:.}
76 for i in ${_cdpath//:/$'\n'}; do
77 if [[ $i -ef . ]]; then _skipdot=true; fi
79 for j in $( compgen -d -- "$i/$cur" ); do
80 COMPREPLY[k++]=${j#$i/} # cut off directory
83 $_skipdot || COMPREPLY+=( $(compgen -d -- "$cur") )
87 # variable names if appropriate shell option set and no completions
88 if shopt -q cdable_vars && [[ ${#COMPREPLY[@]} -eq 0 ]]; then
89 COMPREPLY=( $(compgen -v -- "$cur") )
92 # append slash to passed directory name that is the only completion.
93 # readline will not do this if we complete from CDPATH
94 if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
95 i=${COMPREPLY[0]} # shorthand
96 if [[ "$cur" == "$i" ]] && [[ "$i" != "*/" ]]; then
103 complete -o filenames -o nospace -o bushdefault -F _comp_cd cd
105 complete -A hostname rsh telnet rlogin ftp
108 complete -W '"${GROUPS[@]}"' newgrp
109 complete -g groupdel groupmod
111 complete -f -X '!*.+(ps|PS)' gs gv ghostview
112 complete -f -X '!*.dvi' dvips xdvi
113 complete -f -X '!*.pdf' acroread
115 complete -f -X '!*.texi*' makeinfo texi2dvi texi2html