2002-07-29 16:05:59 +00:00
# bash_completion - some programmable completion functions for bash 2.05b
2000-08-08 22:17:29 +00:00
#
2003-04-19 06:52:57 +00:00
# $Id: bash_completion,v 1.549 2003/04/19 08:52:57 ianmacd Exp $
2000-08-08 22:17:29 +00:00
#
# Copyright (C) Ian Macdonald <ian@caliban.org>
#
# 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.
#
# This 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.
2003-04-19 05:44:04 +00:00
# RELEASE: 20030419
2002-01-05 20:04:01 +00:00
2002-12-18 18:15:46 +00:00
[ -n " ${ DEBUG :- } " ] && set -v || set +v
2002-01-29 20:33:49 +00:00
# Alter the following to reflect the location of this file
#
2002-06-16 16:35:28 +00:00
declare -r BASH_COMPLETION = ${ BASH_COMPLETION :- /etc/bash_completion } 2>/dev/null
declare -r BASH_COMPLETION_DIR = ${ BASH_COMPLETION_DIR : =/etc/bash_completion.d } 2>/dev/null
2002-01-29 20:33:49 +00:00
2001-07-08 23:14:13 +00:00
# Set a couple of useful vars
#
2002-04-22 05:59:08 +00:00
UNAME = $( uname -s )
2001-07-08 23:14:13 +00:00
RELEASE = $( uname -r )
2003-02-26 00:17:54 +00:00
if [ [ ${ BASH_VERSINFO [1] } > 04 ] ] ; then
2002-04-03 17:19:30 +00:00
default = "-o default"
dirnames = "-o dirnames"
filenames = "-o filenames"
fi
2003-02-26 00:17:54 +00:00
[ [ ${ BASH_VERSINFO [1] } = "05b" ] ] && nospace = "-o nospace" || nospace = ""
2001-07-08 23:14:13 +00:00
2000-08-29 00:41:27 +00:00
# Turn on extended globbing and programmable completion
shopt -s extglob progcomp
2000-08-08 22:17:29 +00:00
# A lot of the following one-liners were taken directly from the
# completion examples provided with the bash 2.04 source distribution
2000-10-19 15:25:36 +00:00
# Make directory commands see only directories
mkdir and rmdir now bound to _longopt(), default to dirnames
a2ps, autoconf, automake, bc, gprof, ld, nm, objcopy, objdump, readelf, strip,
bison, cpio, diff, patch, enscript, cp, df, dir, du, ln, ls, mkfifo, mknod,
mv, rm, touch, vdir, xargs, awk, gperf, grep, gpg, grub, indent, less, m4,
sed, shar, date, env, seq, su, tee, uname, who, texindex, cat, csplit, cut,
expand, fmt, fold, head, md5sum, nl, od, paste, pr, ptx, sha1sum, sort,
split, tac, tail, tr, unexpand, uniq, wc, units and rsync now all have
GNU long option completion from _longopt()
gpc completion added into _gcc()
cat, less, more, ln and strip no longer bound to _filedir()
2002-02-18 08:26:34 +00:00
complete -d pushd
2000-10-19 15:25:36 +00:00
2002-03-02 00:13:23 +00:00
# The following section lists completions that are redefined later
# Do NOT break these over multiple lines.
#
2001-12-20 07:52:12 +00:00
# START exclude -- do NOT remove this line
2002-07-16 06:16:50 +00:00
complete -f -X '!*.?(t)bz2' bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
2002-12-05 01:31:52 +00:00
complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo)' unzip zipinfo
2002-02-06 04:02:46 +00:00
complete -f -X '*.Z' compress znew
2002-07-22 18:08:53 +00:00
complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
2001-12-20 07:52:12 +00:00
complete -f -X '!*.Z' uncompress
2003-02-26 00:17:54 +00:00
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|GIF|JP?(E)G|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA)' ee display
2002-07-12 07:21:06 +00:00
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|X[BP]M|RLE|RGB|PCX|FITS|PM)' xv qiv
2002-04-04 14:27:06 +00:00
complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.Z))' gv ggv
2002-02-06 16:05:12 +00:00
complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi
complete -f -X '!*.@(dvi|DVI)' dvips dviselect dvitype
2002-02-06 15:54:09 +00:00
complete -f -X '!*.@(pdf|PDF)' acroread xpdf
2002-12-04 04:02:12 +00:00
complete -f -X '!*.texi*' makeinfo texi2html
complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
2002-05-09 16:20:53 +00:00
complete -f -X '!*.@(mp3|MP3)' mpg123 mpg321
2002-10-26 03:54:48 +00:00
complete -f -X '!*.@(mpg|mpeg|MPG|MPEG|wma|avi|AVI|asf|vob|bin|vcd|ps|pes|fli|viv|rm|ram|yuv|mov|wmv|mp3|MP3|ogg|OGG|ogm|OGM|mp4|MP4)' xine
2002-08-05 05:39:37 +00:00
complete -f -X '!*.@(avi|asf|wmv)' aviplay
2002-03-22 03:18:54 +00:00
complete -f -X '!*.@(rm|ram|smi?(l))' realplay
2002-02-06 15:54:09 +00:00
complete -f -X '!*.@(mpg|mpeg|avi|mov)' xanim
complete -f -X '!*.@(ogg|OGG)' ogg123
2002-08-12 14:04:58 +00:00
complete -f -X '!*.@(mp3|MP3|ogg|OGG|pls|m3u)' gqmpeg freeamp
2002-12-04 06:26:35 +00:00
complete -f -X '!*.@(mp3|MP3|ogg|OGG|wav|WAV|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)' xmms
2002-02-10 20:32:39 +00:00
complete -f -X '!*.fig' xfig
2002-03-19 15:19:58 +00:00
complete -f -X '!*.@(mid?(i))' timidity playmidi
2003-01-13 15:30:56 +00:00
complete -f -X '*.@(o|so|so.!(conf)|tar|tgz|tbz2|rpm|zip|ZIP|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mpg|MPG|avi|AVI|asf|ASF|ogg|OGG)' vi vim gvim rvim view rview rgvim rgview gview emacs
2002-07-08 03:09:22 +00:00
complete -f -X '!*.@(exe|EXE|com|COM|scr|SCR)' wine
2002-05-21 03:35:40 +00:00
complete -f -X '!*.@(zip|ZIP|z|Z|gz|GZ|tgz|TGZ)' bzme
2002-12-06 21:43:02 +00:00
complete -f -X '!*.@(?(x)htm?(l))' netscape mozilla lynx opera w3m galeon curl dillo elinks
2001-12-20 07:52:12 +00:00
# FINISH exclude -- do not remove this line
2000-08-08 22:17:29 +00:00
2002-03-02 00:13:23 +00:00
# start of section containing compspecs that can be handled within bash
2000-08-08 22:17:29 +00:00
# user commands see only users
2003-02-10 06:55:22 +00:00
complete -u su usermod userdel passwd chage write chfn groups slay
2000-08-08 22:17:29 +00:00
2001-11-29 00:37:54 +00:00
# group commands see only groups
2003-02-26 00:17:54 +00:00
[ [ ${ BASH_VERSINFO [1] } > 04 ] ] &&
2002-06-04 03:28:41 +00:00
complete -g groupmod groupdel newgrp 2>/dev/null
2001-11-29 00:37:54 +00:00
2000-08-08 22:17:29 +00:00
# bg completes with stopped jobs
complete -A stopped -P '%' bg
# other job commands
complete -j -P '%' fg jobs disown
2002-03-27 06:32:19 +00:00
# readonly and unset complete with shell variables
2002-02-11 01:49:26 +00:00
complete -v readonly unset
2000-08-08 22:17:29 +00:00
# set completes with set options
complete -A setopt set
# shopt completes with shopt options
complete -A shopt shopt
# helptopics
complete -A helptopic help
# unalias completes with aliases
complete -a unalias
# bind completes with readline bindings (make this more intelligent)
complete -A binding bind
2002-04-03 16:56:55 +00:00
# type and which complete on commands
complete -c command type which
2002-02-11 22:28:47 +00:00
2002-03-02 00:13:23 +00:00
# start of section containing completion functions called by other functions
2000-08-08 22:17:29 +00:00
2002-03-02 00:13:23 +00:00
# This function checks whether we have a given programs on the system.
# No need for bulky functions in memory if we don't.
2001-07-08 23:14:13 +00:00
#
have( )
{
2001-07-09 00:55:01 +00:00
unset -v have
2003-01-09 10:44:29 +00:00
type $1 & > /dev/null && have = "yes"
2001-07-08 23:14:13 +00:00
}
2002-06-17 14:38:37 +00:00
# use GNU sed if we have it, since its extensions are still used in our code
#
[ $UNAME != Linux ] && have gsed && alias sed = gsed
2002-03-02 00:13:23 +00:00
# This function performs file and directory completion. It's better than
2002-05-18 17:05:08 +00:00
# simply using 'compgen -f', because it honours spaces in filenames.
# If passed -d, it completes only on directories. If passed anything else,
2002-05-19 14:56:19 +00:00
# it's assumed to be a file glob to complete on.
2002-03-02 00:13:23 +00:00
#
_filedir( )
{
2002-05-18 17:05:08 +00:00
local IFS = $'\t\n' xspec
2002-03-02 00:13:23 +00:00
_expand || return 0
2002-12-18 18:15:46 +00:00
if [ " ${ 1 :- } " = -d ] ; then
COMPREPLY = ( ${ COMPREPLY [@] :- } $( compgen -d -- $cur ) )
2002-03-02 00:13:23 +00:00
return 0
fi
2002-05-18 17:05:08 +00:00
xspec = ${ 1 : + " !*. $1 " } # set only if glob passed in as $1
2002-12-18 18:15:46 +00:00
COMPREPLY = ( ${ COMPREPLY [@] :- } $( compgen -f -X " $xspec " -- " $cur " )
2002-05-18 17:05:08 +00:00
$( compgen -d -- " $cur " ) )
2002-03-02 00:13:23 +00:00
}
# This function completes on signal names
#
_signals( )
{
local i
# standard signal completion is rather braindead, so we need
# to hack around to get what we want here, which is to
# complete on a dash, followed by the signal name minus
# the SIG prefix
COMPREPLY = ( $( compgen -A signal SIG${ cur #- } ) )
for ( ( i = 0; i < ${# COMPREPLY [@] } ; i++ ) ) ; do
COMPREPLY[ i] = -${ COMPREPLY [i]#SIG }
done
}
# This function expands tildes in pathnames
#
_expand( )
{
2002-10-01 06:07:33 +00:00
[ " $cur " != " ${ cur % \\ } " ] && cur = " $cur \\ "
2002-06-24 19:40:04 +00:00
# expand ~username type directory specifications
if [ [ " $cur " = = \~ */* ] ] ; then
2003-04-17 07:38:27 +00:00
eval cur = $cur
2002-12-19 20:56:47 +00:00
2002-06-24 19:40:04 +00:00
elif [ [ " $cur " = = \~ * ] ] ; then
2002-03-02 00:13:23 +00:00
cur = ${ cur # \~ }
COMPREPLY = ( $( compgen -P '~' -u $cur ) )
return ${# COMPREPLY [@] }
fi
}
2002-04-02 06:17:35 +00:00
# This function completes on process IDs
#
_pids( )
{
2002-10-20 04:56:41 +00:00
COMPREPLY = ( $( compgen -W '$( command ps axo pid | sed 1d )' -- $cur ) )
2002-04-02 06:17:35 +00:00
}
# This function completes on process group IDs
#
_pgids( )
{
2002-10-20 04:56:41 +00:00
COMPREPLY = ( $( compgen -W '$( command ps axo pgid | sed 1d )' -- $cur ) )
2002-04-02 06:17:35 +00:00
}
2002-08-19 14:56:55 +00:00
# Linux ifconfig(8) and iwconfig(8) helper function
#
2003-01-30 08:22:43 +00:00
[ $UNAME = Linux ] && { have ifconfig || have iwconfig; } &&
2002-08-19 14:56:55 +00:00
_ifwconfig( )
{
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
case " ${ COMP_WORDS [1] } " in
-| *[ 0-9] *)
#COMPREPLY=( $( compgen -W '${keywords[@]}' ) )
COMPREPLY = ( ${ keywords [@] } )
COMPREPLY = ( $( echo " ${ COMP_WORDS [@] } " | \
( while read -d ' ' i; do
[ " $i " = = "" ] && continue
# flatten array with spaces on either side,
# otherwise we cannot grep on word
# boundaries of first and last word
COMPREPLY = " ${ COMPREPLY [@] } "
# remove word from list of completions
COMPREPLY = ( ${ COMPREPLY / $i / } )
done
echo ${ COMPREPLY [@] } )
) )
return 0
; ;
esac
COMPREPLY = ( $( eval " $@ " 2>/dev/null | \
sed -ne 's|^\(' $cur '[^ ]*\).*$|\1|p' ) )
}
2002-03-02 00:13:23 +00:00
# start of section containing completion functions for bash built-ins
# bash alias completion
#
_alias( )
{
local cur
COMPREPLY = ( )
2002-09-28 16:12:24 +00:00
cur = ${ COMP_WORDS [ $COMP_CWORD ] }
2002-03-02 00:13:23 +00:00
case " $COMP_LINE " in
*[ ^= ] )
COMPREPLY = ( $( compgen -A alias -S '=' -- $cur ) )
; ;
2002-03-07 18:04:05 +00:00
*= )
2002-03-02 00:13:23 +00:00
COMPREPLY = ( " $( alias ${ cur %= } 2>/dev/null | \
sed -e 's|^alias ' $cur '\(.*\)$|\1|' ) " )
; ;
esac
}
complete -F _alias alias
# bash export completion
#
_export( )
{
local cur
COMPREPLY = ( )
2002-09-28 16:12:24 +00:00
cur = ${ COMP_WORDS [ $COMP_CWORD ] }
2002-03-02 00:13:23 +00:00
case " $COMP_LINE " in
2002-04-23 00:51:54 +00:00
*= \$ *)
COMPREPLY = ( $( compgen -v -P '$' -- ${ cur #*= \$ } ) )
; ;
2002-03-02 00:13:23 +00:00
*[ ^= ] )
COMPREPLY = ( $( compgen -v -S '=' -- $cur ) )
; ;
2002-03-07 18:04:05 +00:00
*= )
2002-03-02 00:13:23 +00:00
COMPREPLY = ( $( eval echo $` echo ${ cur %= } ` ) )
; ;
2002-03-28 07:41:09 +00:00
esac
2002-03-02 00:13:23 +00:00
}
2002-08-05 05:47:30 +00:00
complete -F _export $default $nospace export
2002-03-02 00:13:23 +00:00
# bash shell function completion
#
_function( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ $1 = = @( declare| typeset ) ] ] ; then
if [ " $prev " = -f ] ; then
COMPREPLY = ( $( compgen -A function -- $cur ) )
elif [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '-a -f -F -i -r -x -p' -- \
$cur ) )
fi
elif [ $COMP_CWORD -eq 1 ] ; then
COMPREPLY = ( $( compgen -A function -- $cur ) )
else
COMPREPLY = ( " () $( type -- ${ COMP_WORDS [1] } | sed -e 1,2d ) " )
fi
}
complete -F _function function declare typeset
2002-06-01 19:16:20 +00:00
# bash complete completion
#
_complete( )
{
local cur prev options
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
-o)
options = "default dirnames filenames"
2003-02-26 00:17:54 +00:00
[ [ ${ BASH_VERSINFO [1] } = "05b" ] ] && options = " $options nospace "
2002-06-01 19:16:20 +00:00
COMPREPLY = ( $( compgen -W " $options " -- $cur ) )
return 0
; ;
-A)
COMPREPLY = ( $( compgen -W ' alias arrayvar binding \
builtin command directory disabled enabled \
export file function group helptopic hostname \
job keyword running service setopt shopt \
signal stopped user variable' -- $cur ) )
return 0
; ;
-C)
COMPREPLY = ( $( compgen -A command -- $cur ) )
return 0
; ;
-F)
COMPREPLY = ( $( compgen -A function -- $cur ) )
return 0
; ;
-@( p| r) )
COMPREPLY = ( $( complete -p | sed -e 's|.* ||' | \
grep " ^ $cur " ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
options = "-a -b -c -d -e -f -g -j -k -s -v -u -A -G -W -P -S -X -F -C"
2003-02-26 00:17:54 +00:00
[ [ ${ BASH_VERSINFO [1] } > 04 ] ] && options = " $options -o "
2002-06-01 19:16:20 +00:00
COMPREPLY = ( $( compgen -W " $options " -- $cur ) )
else
COMPREPLY = ( $( compgen -A command -- $cur ) )
fi
}
complete -F _complete complete
2002-03-02 00:13:23 +00:00
# start of section containing completion functions for external programs
2003-03-27 06:48:09 +00:00
# This completes on a list of all available service scripts for the
# 'service' command and/or the SysV init.d directory, followed by
# that script's available commands
#
{ have service || [ -d /etc/init.d/ ] ; } &&
_service( )
{
local cur sysvdir
COMPREPLY = ( )
prev = ${ COMP_WORDS [COMP_CWORD-1] }
cur = ${ COMP_WORDS [COMP_CWORD] }
# don't complete for things like killall, ssh and mysql if it's
# the standalone command, rather than the init script
[ [ ${ COMP_WORDS [0] } != @( *init.d*| service) ] ] && return 0
[ -d /etc/rc.d/init.d ] && sysvdir = /etc/rc.d/init.d \
|| sysvdir = /etc/init.d
if [ [ $COMP_CWORD -eq 1 ] ] && [ [ $prev = = "service" ] ] ; then
COMPREPLY = ( $( compgen -W '`echo $sysvdir/!(*.rpmsave|*.rpmorig)`' ) )
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]#$sysvdir/}' -- \
$cur ) )
else
COMPREPLY = ( $( compgen -W ' ` sed -ne " y/|/ /; \
s/^.*Usage.*{ \( .*\) } .*$/\1 /p" \
$sysvdir /${ prev ##*/ } ` ' -- \
$cur ) )
fi
return 0
}
[ -n " ${ have :- } " ] && complete -F _service service
[ -d /etc/init.d/ ] && complete -F _service $default \
$( for i in /etc/init.d/*; do echo ${ i ##*/ } ; done )
2002-03-26 15:17:12 +00:00
# chown(1) completion
2000-08-08 22:17:29 +00:00
#
2000-08-29 00:41:27 +00:00
_chown( )
2000-08-08 22:17:29 +00:00
{
2001-11-20 04:15:48 +00:00
local cur prev user group i
2000-08-08 22:17:29 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-08-08 22:17:29 +00:00
2002-09-08 20:04:26 +00:00
# options completion
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -c -h -f -R -v --changes \
--dereference --no-dereference --from= --silent --quiet \
2002-10-01 03:57:54 +00:00
--reference= --recursive --verbose --help --version' -- $cur ) )
2002-09-08 20:04:26 +00:00
return 0
fi
2000-08-08 22:17:29 +00:00
# first parameter on line or first since an option?
2002-02-26 22:59:47 +00:00
if [ $COMP_CWORD -eq 1 ] || [ [ " $prev " = = -* ] ] ; then
2002-04-02 23:37:51 +00:00
if [ [ " $cur " = = [ a-zA-Z] *[ .:] * ] ] && \
2003-02-26 00:17:54 +00:00
[ [ ${ BASH_VERSINFO [1] } > 04 ] ] ; then
2002-03-26 15:17:12 +00:00
user = ${ cur %%?( \\ )[. : ]* }
group = ${ cur #*[. : ] }
2002-06-26 03:30:50 +00:00
COMPREPLY = ( $( compgen -P $user ':' \
2002-04-14 22:41:04 +00:00
-g -- $group 2>/dev/null) )
2000-08-29 00:41:27 +00:00
else
2002-06-26 03:30:50 +00:00
COMPREPLY = ( $( compgen -S ':' -u $cur ) )
2000-08-29 00:41:27 +00:00
fi
2002-06-26 03:30:50 +00:00
else
_filedir
2000-08-08 22:17:29 +00:00
fi
return 0
}
2002-06-26 03:30:50 +00:00
complete -F _chown $filenames chown
2000-08-08 22:17:29 +00:00
2002-01-08 04:49:06 +00:00
# chgrp(1) completion
#
_chgrp( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-09-08 20:04:26 +00:00
# options completion
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -c -h -f -R -v --changes \
--dereference --no-dereference --silent --quiet \
2002-10-01 03:57:54 +00:00
--reference= --recursive --verbose --help --version' -- $cur ) )
2002-09-08 20:04:26 +00:00
return 0
fi
2002-01-08 04:49:06 +00:00
# first parameter on line or first since an option?
2002-04-02 23:37:51 +00:00
if [ $COMP_CWORD -eq 1 ] && [ [ " $cur " != -* ] ] || \
[ [ " $prev " = = -* ] ] ; then
2003-02-26 00:17:54 +00:00
[ [ ${ BASH_VERSINFO [1] } > 04 ] ] && \
2002-04-14 22:41:04 +00:00
COMPREPLY = ( $( compgen -g $cur 2>/dev/null) )
2002-04-02 23:37:51 +00:00
else
2002-01-24 04:03:26 +00:00
_expand || return 0
2002-01-08 04:49:06 +00:00
fi
return 0
}
2002-04-03 17:19:30 +00:00
complete -F _chgrp $default chgrp
2002-01-08 04:49:06 +00:00
2000-08-08 22:17:29 +00:00
# umount(8) completion. This relies on the mount point being the third
# space-delimited field in the output of mount(8)
#
2000-08-29 00:41:27 +00:00
_umount( )
2000-08-08 22:17:29 +00:00
{
local cur
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2000-08-08 22:17:29 +00:00
2002-04-03 16:56:01 +00:00
COMPREPLY = ( $( compgen -W '$( mount | cut -d" " -f 3 )' -- $cur ) )
2000-08-29 00:41:27 +00:00
2000-08-08 22:17:29 +00:00
return 0
}
2002-04-03 17:19:30 +00:00
complete -F _umount $dirnames umount
2000-08-08 22:17:29 +00:00
# mount(8) completion. This will pull a list of possible mounts out of
2003-01-17 09:01:29 +00:00
# /etc/{,v}fstab, unless the word being completed contains a ':', which
2000-08-08 22:17:29 +00:00
# would indicate the specification of an NFS server. In that case, we
# query the server for a list of all available exports and complete on
# that instead.
#
2000-08-29 00:41:27 +00:00
_mount( )
2002-07-15 23:07:03 +00:00
{ local cur i sm host
2000-08-08 22:17:29 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-10-05 06:03:21 +00:00
[ [ " $cur " = = \\ ] ] && cur = "/"
2002-03-24 18:57:37 +00:00
for i in { ,/usr} /{ ,s} bin/showmount; do [ -x $i ] && sm = $i && break; done
2000-08-08 22:17:29 +00:00
2001-12-21 07:56:18 +00:00
if [ -n " $sm " ] && [ [ " $cur " = = *:* ] ] ; then
2002-03-24 18:57:37 +00:00
COMPREPLY = ( $( $sm -e ${ cur %% : * } | sed 1d | \
2000-10-09 18:07:50 +00:00
grep ^${ cur #* : } | awk '{print $1}' ) )
2002-07-15 23:07:03 +00:00
elif [ [ " $cur " = = //* ] ] ; then
host = ${ cur #// }
host = ${ host %%/* }
if [ -n $host ] ; then
COMPREPLY = ( $( compgen -W " $( echo $( smbclient -d 0 -NL $host |
sed -ne '/^[' $'\t ' ']*Sharename/,/^$/p' |
sed -ne '3,$s|^[^A-Za-z]*\([^' $'\t ' ']*\).*$|//' $host '/\1|p' ) ) " -- " $cur " ) )
fi
2003-01-17 09:01:29 +00:00
elif [ -r /etc/vfstab ] ; then
# Solaris
COMPREPLY = ( $( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \
/etc/vfstab | grep " ^ $cur " ) )
2000-08-29 00:41:27 +00:00
else
2003-01-17 09:01:29 +00:00
# probably Linux
COMPREPLY = ( $( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' \
/etc/fstab | grep " ^ $cur " ) )
2000-08-29 00:41:27 +00:00
fi
return 0
2000-08-08 22:17:29 +00:00
}
2003-02-07 17:04:35 +00:00
complete -F _mount $default $filenames mount
2000-08-08 22:17:29 +00:00
2002-12-05 04:22:22 +00:00
# Linux rmmod(8) completion. This completes on a list of all currently
2000-08-08 22:17:29 +00:00
# installed kernel modules.
#
2002-12-05 04:22:22 +00:00
have rmmod && {
2000-08-29 00:41:27 +00:00
_rmmod( )
2000-08-08 22:17:29 +00:00
{
local cur
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2000-08-08 22:17:29 +00:00
2000-09-25 21:38:11 +00:00
COMPREPLY = ( $( /sbin/lsmod | \
2002-10-05 06:03:21 +00:00
awk '{if (NR != 1 && $1 ~ /^' $cur '/) print $1}' 2>/dev/null ) )
2000-08-08 22:17:29 +00:00
return 0
}
2002-12-05 04:22:22 +00:00
complete -F _rmmod rmmod
2000-08-08 22:17:29 +00:00
2003-01-21 06:37:44 +00:00
# Linux insmod(8), modprobe(8) and modinfo(8) completion. This completes on a
# list of all available modules for the version of the kernel currently
# running.
2000-08-08 22:17:29 +00:00
#
2000-08-29 00:41:27 +00:00
_insmod( )
2000-08-08 22:17:29 +00:00
{
2000-09-25 21:38:11 +00:00
local cur prev modpath
2000-08-08 22:17:29 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-08-08 22:17:29 +00:00
modpath = /lib/modules/` uname -r`
2001-01-31 22:57:06 +00:00
# behave like lsmod for modprobe -r
2002-02-26 22:59:47 +00:00
if [ $1 = "modprobe" ] &&
2002-01-08 04:49:06 +00:00
[ " ${ COMP_WORDS [1] } " = "-r" ] ; then
2001-01-31 22:57:06 +00:00
COMPREPLY = ( $( /sbin/lsmod | \
awk '{if (NR != 1 && $1 ~ /^' $cur '/) print $1}' ) )
return 0
fi
# do filename completion if we're giving a path to a module
2002-10-06 20:24:18 +00:00
if [ [ " $cur " = = ?( .| ..) /* ] ] ; then
2002-02-27 15:48:20 +00:00
_filedir
2001-12-18 03:43:25 +00:00
return 0
fi
2001-01-31 22:57:06 +00:00
2000-09-25 21:38:11 +00:00
if [ $COMP_CWORD -gt 1 ] ; then
2001-01-31 22:57:06 +00:00
# do module parameter completion
2002-02-26 22:59:47 +00:00
COMPREPLY = ( $( /sbin/modinfo -p ${ COMP_WORDS [1] } 2>/dev/null | \
2002-03-15 19:02:06 +00:00
awk '{if ($1 ~ /^parm:/ && $2 ~ /^' $cur ' /) { print $2 } \
else if ( $1 !~ /:/ && $1 ~ /^'$cur' /) { print $1 } } ' ) )
2002-02-18 17:36:00 +00:00
elif [ -r $modpath -a -x $modpath ] ; then
2001-01-31 22:57:06 +00:00
# do module name completion
2002-06-04 03:45:09 +00:00
COMPREPLY = ( $( command ls -R $modpath | \
2002-09-28 16:12:24 +00:00
sed -ne 's/^\(' $cur '.*\)\.o\(\|.gz\)$/\1/p' ) )
2002-02-18 17:36:00 +00:00
else
2002-02-27 15:48:20 +00:00
_filedir
2000-09-25 21:38:11 +00:00
fi
2000-08-29 00:41:27 +00:00
2000-08-08 22:17:29 +00:00
return 0
}
2003-01-21 06:37:44 +00:00
complete -F _insmod $filenames insmod modprobe modinfo
2002-12-05 04:22:22 +00:00
}
2000-08-08 22:17:29 +00:00
2003-01-17 08:54:32 +00:00
# man(1) completion
2000-08-08 22:17:29 +00:00
#
2003-01-17 08:54:32 +00:00
[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
-o $UNAME = FreeBSD -o $UNAME = SunOS ] &&
2000-08-29 00:41:27 +00:00
_man( )
2000-08-08 22:17:29 +00:00
{
2002-04-22 05:59:08 +00:00
local cur prev sect manpath UNAME
2000-08-08 22:17:29 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-08-08 22:17:29 +00:00
2002-01-24 04:03:26 +00:00
_expand || return 0
2001-12-18 03:25:04 +00:00
# default completion if parameter contains /
2002-02-18 22:40:23 +00:00
if [ [ " $cur " = = */* ] ] ; then
_filedir
return 0
fi
2002-02-14 22:39:04 +00:00
2002-04-22 05:59:08 +00:00
UNAME = $( uname -s )
2002-06-19 14:53:48 +00:00
if [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = FreeBSD ] ; then
2002-06-04 03:45:09 +00:00
manpath = $( manpath 2>/dev/null || command man --path )
2002-03-02 00:56:21 +00:00
else
manpath = $MANPATH
fi
2002-02-14 22:39:04 +00:00
if [ -z " $manpath " ] ; then
2002-02-26 23:13:04 +00:00
COMPREPLY = ( $( compgen -c -- $cur ) )
2001-12-18 03:25:04 +00:00
return 0
fi
2000-08-08 22:17:29 +00:00
2002-02-12 16:05:22 +00:00
# determine manual section to search
2003-01-17 08:54:32 +00:00
[ [ " $prev " = = [ 0-9ln] ] ] && sect = $prev || sect = '*'
2002-02-14 22:39:04 +00:00
manpath = $manpath :
if [ -n " $cur " ] ; then
2003-01-17 08:54:32 +00:00
manpath = " ${ manpath // : //*man $sect / $cur * } "
2002-02-14 22:39:04 +00:00
else
2003-01-17 08:54:32 +00:00
manpath = " ${ manpath // : //*man $sect / } "
2002-02-14 22:39:04 +00:00
fi
2002-02-12 16:05:22 +00:00
2002-02-08 16:49:05 +00:00
# redirect stderr for when path doesn't exist
2002-06-04 03:45:09 +00:00
COMPREPLY = ( $( eval command ls " $manpath " 2>/dev/null ) )
2002-02-14 22:39:04 +00:00
# weed out directory path names and paths to man pages
COMPREPLY = ( ${ COMPREPLY [@]##*/?( : ) } )
2002-02-08 16:49:05 +00:00
# strip suffix from man pages
COMPREPLY = ( ${ COMPREPLY [@]%.@(gz|bz2) } )
2002-10-23 13:50:04 +00:00
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]%.*}' -- " ${ cur // \\ \\ / } " ) )
2002-02-08 16:49:05 +00:00
2002-05-18 21:00:14 +00:00
[ [ " $prev " != [ 0-9ln] ] ] && _filedir '[0-9ln]'
2000-08-29 00:41:27 +00:00
return 0
2000-08-08 22:17:29 +00:00
}
2003-01-17 08:54:32 +00:00
[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
-o $UNAME = FreeBSD -o $UNAME = SunOS ] && complete -F _man $filenames man
2000-08-08 22:17:29 +00:00
2002-04-02 06:17:35 +00:00
# renice(8) completion
#
_renice( )
{
local command cur curopt i
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
command = $1
i = 0
2003-04-15 06:54:50 +00:00
# walk back through command line and find last option
2002-04-02 06:17:35 +00:00
while [ $i -le $COMP_CWORD -a ${# COMPREPLY [@] } -eq 0 ] ; do
curopt = ${ COMP_WORDS [COMP_CWORD- $i ] }
case " $curopt " in
-u)
COMPREPLY = ( $( compgen -u -- $cur ) )
; ;
-g)
_pgids
; ;
-p| $command )
_pids
; ;
esac
i = $(( + + i ))
done
}
complete -F _renice renice
2002-02-19 17:37:15 +00:00
# kill(1) completion
#
_kill( )
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-03-07 18:04:05 +00:00
if [ $COMP_CWORD -eq 1 ] && [ [ " $cur " = = -* ] ] ; then
2002-02-19 17:37:15 +00:00
# return list of available signals
_signals
else
# return list of available PIDs
2002-04-02 06:22:27 +00:00
_pids
2002-02-19 17:37:15 +00:00
fi
}
complete -F _kill kill
2002-03-24 00:34:33 +00:00
# Linux and FreeBSD killall(1) completion.
2000-08-08 22:17:29 +00:00
#
2002-04-22 05:59:08 +00:00
[ $UNAME = Linux -o $UNAME = FreeBSD ] &&
2000-08-29 00:41:27 +00:00
_killall( )
2000-08-08 22:17:29 +00:00
{
2002-02-19 17:37:15 +00:00
local cur
2000-08-08 22:17:29 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2000-08-08 22:17:29 +00:00
2002-02-19 17:37:15 +00:00
if [ $COMP_CWORD -eq 1 ] && [ [ " $cur " = = -* ] ] ; then
_signals
else
2002-10-20 04:56:41 +00:00
COMPREPLY = ( $( compgen -W '$( command ps axo ucomm | sed 1d )' \
2002-03-24 00:34:33 +00:00
-- $cur ) )
2000-08-08 22:17:29 +00:00
fi
return 0
}
2002-04-22 05:59:08 +00:00
[ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _killall killall
2000-08-08 22:17:29 +00:00
# GNU find(1) completion. This makes heavy use of ksh style extended
# globs and contains Linux specific code for completing the parameter
# to the -fstype option.
#
2000-08-29 00:41:27 +00:00
_find( )
2000-08-08 22:17:29 +00:00
{
2002-02-27 00:41:56 +00:00
local cur prev
2000-08-08 22:17:29 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2002-02-26 23:29:54 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
2001-12-18 03:43:25 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-08-08 22:17:29 +00:00
case " $prev " in
-@( max| min) depth)
2002-02-26 23:29:54 +00:00
COMPREPLY = ( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- $cur ) )
2000-08-08 22:17:29 +00:00
return 0
; ;
2002-02-06 17:41:06 +00:00
-?( a) newer| -fls| -fprint?( 0| f) | -?( i) ?( l) name)
2002-02-27 15:48:20 +00:00
_filedir
2000-08-08 22:17:29 +00:00
return 0
; ;
-fstype)
2002-01-03 00:16:41 +00:00
# this is highly non-portable
2002-04-03 21:17:10 +00:00
COMPREPLY = ( $( cut -d$'\t' -f 2 /proc/filesystems | \
grep " ^ $cur " ) )
2000-08-08 22:17:29 +00:00
return 0
; ;
-gid)
COMPREPLY = ( $( awk ' BEGIN { FS = ":" } \
2002-01-30 18:48:45 +00:00
{ if ( $3 ~ /^'$ncur' /) print $3 } ' /etc/group ) )
2000-08-08 22:17:29 +00:00
return 0
; ;
-group)
2003-02-26 00:17:54 +00:00
[ [ ${ BASH_VERSINFO [1] } > 04 ] ] && \
2002-04-14 22:41:04 +00:00
COMPREPLY = ( $( compgen -g -- $cur 2>/dev/null) )
2000-08-08 22:17:29 +00:00
return 0
; ;
-?( x) type )
2002-02-26 23:29:54 +00:00
COMPREPLY = ( $( compgen -W 'b c d p f l s' -- $cur ) )
2000-08-08 22:17:29 +00:00
return 0
; ;
-uid)
COMPREPLY = ( $( awk ' BEGIN { FS = ":" } \
2002-01-30 18:48:45 +00:00
{ if ( $3 ~ /^'$ncur' /) print $3 } ' /etc/passwd ) )
2000-08-08 22:17:29 +00:00
return 0
; ;
-user)
2002-02-26 23:29:54 +00:00
COMPREPLY = ( $( compgen -u -- $cur ) )
2000-08-08 22:17:29 +00:00
return 0
; ;
-[ acm] min| -[ acm] time| -?( i) ?( l) name| -inum| -?( i) path| -?( i) regex| \
-links| -perm| -size| -used| -exec| -ok| -printf)
# do nothing, just wait for a parameter to be given
return 0
; ;
esac
2002-01-24 04:03:26 +00:00
_expand || return 0
2002-01-30 18:48:45 +00:00
# handle case where first parameter is not a dash option
2002-02-26 23:29:54 +00:00
if [ $COMP_CWORD -eq 1 ] && [ [ " $cur " != -* ] ] ; then
2002-02-27 15:48:20 +00:00
_filedir -d
2002-01-30 18:48:45 +00:00
return 0
fi
2002-02-26 23:29:54 +00:00
# complete using basic options
2002-10-05 19:33:03 +00:00
COMPREPLY = ( $( compgen -W ' -daystart -depth -follow -help -maxdepth \
-mindepth -mount -noleaf -version -xdev -amin -anewer \
-atime -cmin -cnewer -ctime -empty -false -fstype \
-gid -group -ilname -iname -inum -ipath -iregex \
-links -lname -mmin -mtime -name -newer -nouser \
-nogroup -perm -regex -size -true -type -uid -used \
-user -xtype -exec -fls -fprint -fprint0 -fprintf -ok \
-print -print0 -printf -prune -ls' -- $cur ) )
2000-08-08 22:17:29 +00:00
# this removes any options from the list of completions that have
# already been specified somewhere on the command line.
2002-02-26 23:29:54 +00:00
COMPREPLY = ( $( echo " ${ COMP_WORDS [@] } " | \
( while read -d ' ' i; do
2000-08-08 22:17:29 +00:00
[ " $i " = = "" ] && continue
# flatten array with spaces on either side,
# otherwise we cannot grep on word boundaries of
# first and last word
COMPREPLY = " ${ COMPREPLY [@] } "
# remove word from list of completions
COMPREPLY = ( ${ COMPREPLY / ${ i %% * } / } )
2001-12-18 03:43:25 +00:00
done
echo ${ COMPREPLY [@] } )
2000-08-08 22:17:29 +00:00
) )
return 0
}
2002-04-03 17:19:30 +00:00
complete -F _find $filenames find
2000-08-08 22:17:29 +00:00
# Linux ifconfig(8) completion
#
2002-08-19 14:56:55 +00:00
[ $UNAME = Linux ] && have ifconfig &&
2000-08-29 00:41:27 +00:00
_ifconfig( )
2000-08-08 22:17:29 +00:00
{
local cur
2002-08-19 14:56:55 +00:00
local -a keywords = ( -a up down arp promisc allmulti metric mtu dstaddr \
netmask add del tunnel irq io_addr mem_start media \
broadcast pointopoint hw multicast address txqueuelen )
2000-08-08 22:17:29 +00:00
2002-08-19 14:56:55 +00:00
_ifwconfig ifconfig -a
2000-08-08 22:17:29 +00:00
2002-08-19 14:56:55 +00:00
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
}
[ $UNAME = Linux ] && have ifconfig && complete -F _ifconfig ifconfig
# Linux iwconfig(8) completion
#
[ $UNAME = Linux ] && have iwconfig &&
_iwconfig( )
{
local -a keywords = ( essid nwid domain freq channel sens mode ap nick \
rate bit rts frag key enc power )
_ifwconfig iwconfig
2000-08-08 22:17:29 +00:00
2002-08-19 14:56:55 +00:00
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
2000-08-08 22:17:29 +00:00
}
2002-08-19 14:56:55 +00:00
[ $UNAME = Linux ] && complete -F _iwconfig iwconfig
2000-08-08 22:17:29 +00:00
2002-05-09 16:20:53 +00:00
# RedHat & Debian GNU/Linux if{up,down} completion
2002-01-08 00:33:08 +00:00
#
2002-04-22 05:59:08 +00:00
[ $UNAME = Linux ] && ( have ifup || have ifdown ) &&
2002-01-08 00:33:08 +00:00
_ifupdown( )
{
2002-01-29 22:06:26 +00:00
local cur
2002-01-08 00:33:08 +00:00
2002-01-29 22:06:26 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-01-08 00:33:08 +00:00
2002-02-26 22:59:47 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
2002-01-29 22:06:26 +00:00
if [ -f /etc/debian_version ] ; then
# Debian system
2002-03-26 18:45:45 +00:00
COMPREPLY = ( $( sed -ne 's|^iface \([^ ]\+\).*$|\1|p' \
/etc/network/interfaces ) )
2002-01-29 22:06:26 +00:00
else
# Assume Red Hat
2002-06-04 03:45:09 +00:00
COMPREPLY = ( $( command ls \
/etc/sysconfig/network-scripts/ifcfg-* | \
sed -ne 's|.*ifcfg-\(' $cur '.*\)|\1|p' ) )
2002-01-29 22:06:26 +00:00
fi
2002-01-08 00:33:08 +00:00
fi
return 0
}
2002-04-22 05:59:08 +00:00
[ $UNAME = Linux ] && have ifup && complete -F _ifupdown ifup ifdown
2002-01-08 00:33:08 +00:00
2002-08-19 14:56:55 +00:00
# Linux ipsec(8) completion (for FreeS/WAN)
2000-08-08 22:17:29 +00:00
#
2002-04-22 05:59:08 +00:00
[ $UNAME = Linux ] && have ipsec &&
2000-08-29 00:41:27 +00:00
_ipsec( )
2000-08-08 22:17:29 +00:00
{
local cur
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2000-08-08 22:17:29 +00:00
2000-10-09 18:07:50 +00:00
2002-02-26 22:59:47 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
2002-02-13 16:02:57 +00:00
COMPREPLY = ( $( compgen -W ' auto barf eroute klipsdebug look \
manual pluto ranbits rsasigkey \
setup showdefaults showhostkey spi \
2002-02-18 10:09:59 +00:00
spigrp tncfg whack' $cur ) )
2000-10-09 18:07:50 +00:00
return 0
fi
case ${ COMP_WORDS [1] } in
auto)
COMPREPLY = ( $( compgen -W ' --asynchronous --up --add --delete \
--replace --down --route --unroute \
2002-02-13 16:02:57 +00:00
--ready --status --rereadsecrets' \
$cur ) )
2000-10-09 18:07:50 +00:00
; ;
manual)
COMPREPLY = ( $( compgen -W ' --up --down --route --unroute \
--union' $cur ) )
; ;
ranbits)
COMPREPLY = ( $( compgen -W '--quick --continuous --bytes' $cur ) )
; ;
setup)
COMPREPLY = ( $( compgen -W '--start --stop --restart' $cur ) )
; ;
*)
; ;
esac
2000-08-29 00:41:27 +00:00
return 0
2000-08-08 22:17:29 +00:00
}
2002-12-18 18:15:46 +00:00
[ $UNAME = Linux ] && [ -n " ${ have :- } " ] && complete -F _ipsec ipsec
2000-08-11 21:20:41 +00:00
2002-05-05 20:46:30 +00:00
# Postfix completion.
#
have postfix && {
2002-05-08 15:23:51 +00:00
# postfix(1)
#
2002-12-05 01:47:49 +00:00
_postfix( )
2002-05-08 15:23:51 +00:00
{
COMPREPLY = ( $( compgen -W 'start stop reload abort flush check' -- \
" ${ COMP_WORDS [COMP_CWORD] } " ) )
}
complete -F _postfix postfix
2002-05-05 20:46:30 +00:00
# postalias(1) and postmap(1)
#
_postmap( )
{
local cur prev len idx
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ $cur = = '-' ] ] ; then
2002-05-08 15:23:51 +00:00
COMPREPLY = ( -N -f -i -n -o -r -v -w -c -d -q)
2002-05-05 20:46:30 +00:00
return 0
fi
if [ [ $prev = = '-c' ] ] ; then
_filedir -d
return 0
fi
if [ [ $prev = = -[ dq] ] ] ; then
return 0
fi
if [ [ " $cur " = = *:* ] ] ; then
COMPREPLY = ( $( compgen -f -- ${ cur #* : } ) )
else
len = ${# cur }
idx = 0
for pval in $( postconf -m ) ; do
if [ [ " $cur " = = " ${ pval : 0 : $len } " ] ] ; then
COMPREPLY[ $idx ] = " $pval : "
idx = $(( $idx + 1 ))
fi
done
if [ [ $idx -eq 0 ] ] ; then
COMPREPLY = ( $( compgen -f -- " $cur " ) )
fi
fi
return 0
}
complete -F _postmap postmap postalias
# postconf(1)
#
_postconf( )
{
local cur prev len idx eqext
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ $cur = = '-' ] ] ; then
COMPREPLY = ( -c -d -e -h -m -l -n -v)
return 0
fi
if [ [ $prev = = '-c' ] ] ; then
_filedir -d
return 0
fi
if [ [ $prev = = '-e' ] ] ; then
cur = ${ cur #[ \" \' ] }
eqext = '='
fi
len = ${# cur }
idx = 0
for pval in $( postconf | cut -d ' ' -f 1 ) ; do
if [ [ " $cur " = = " ${ pval : 0 : $len } " ] ] ; then
COMPREPLY[ $idx ] = " $pval $eqext "
idx = $(( $idx + 1 ))
fi
done
return 0
}
complete -F _postconf postconf
# postsuper(1)
#
_postsuper( )
{
local cur prev len idx
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ $cur = = '-' ] ] ; then
COMPREPLY = ( -d -p -r -s -v)
return 0
fi
if [ [ $prev = = -[ dr] ] ] ; then
len = ${# cur }
idx = 0
for pval in $( mailq | \
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//' ) ; do
if [ [ " $cur " = = " ${ pval : 0 : $len } " ] ] ; then
COMPREPLY[ $idx ] = $pval
idx = $(( $idx + 1 ))
fi
done
return 0
fi
_filedir -d
return 0
}
complete -F _postsuper postsuper
}
2000-08-29 00:41:27 +00:00
# cvs(1) completion
#
2002-05-02 22:43:50 +00:00
have cvs && {
set_prefix( )
2000-08-11 21:20:41 +00:00
{
2002-12-18 18:15:46 +00:00
[ -z ${ prefix :- } ] || prefix = ${ cur %/* } /
[ -r ${ prefix :- } CVS/Entries ] || prefix = ""
2002-05-02 22:43:50 +00:00
}
2002-03-01 18:29:34 +00:00
2002-05-02 22:43:50 +00:00
get_entries( )
{
2002-12-18 18:15:46 +00:00
[ -r ${ prefix :- } CVS/Entries ] && \
2002-05-16 07:10:04 +00:00
entries = ( $( compgen -W \
2003-02-06 18:06:29 +00:00
" $( echo $( cut -d/ -f2 -s ${ prefix :- } CVS/Entries ) ) " -- $cur ) )
2002-05-02 22:43:50 +00:00
}
get_modules( )
{
if [ -n " $prefix " ] ; then
2002-06-04 03:45:09 +00:00
COMPREPLY = ( $( command ls -d ${ cvsroot } /${ prefix } /!( CVSROOT) ) )
2002-05-02 22:43:50 +00:00
else
2002-06-04 03:45:09 +00:00
COMPREPLY = ( $( command ls -d ${ cvsroot } /!( CVSROOT) ) )
2002-05-02 22:43:50 +00:00
fi
}
_cvs( )
{
2003-02-08 06:33:51 +00:00
local cur count mode i cvsroot cvsroots pwd
2002-02-28 22:23:14 +00:00
local -a flags miss files entries changed newremoved
2000-08-11 21:20:41 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2000-08-11 21:20:41 +00:00
2002-10-05 07:33:14 +00:00
count = 0
2002-02-28 22:23:14 +00:00
for i in ${ COMP_WORDS [@] } ; do
[ $count -eq $COMP_CWORD ] && break
2003-02-08 06:33:51 +00:00
# Last parameter was the CVSROOT, now go back to mode selection
if [ " ${ COMP_WORDS [((count))] } " = = " $cvsroot " -a " $mode " = = "cvsroot" ] ; then
mode = ""
fi
2002-02-28 22:23:14 +00:00
if [ -z " $mode " ] ; then
case $i in
-d)
2003-02-08 06:33:51 +00:00
mode = cvsroot
2002-10-05 07:33:14 +00:00
cvsroot = ${ COMP_WORDS [((count+1))] }
2002-02-28 22:23:14 +00:00
; ;
@( add| new) )
mode = add
; ;
@( admin| rcs) )
mode = admin
; ;
@( checkout| co| get) )
mode = checkout
; ;
@( commit| ci) )
mode = commit
; ;
2003-01-17 09:09:59 +00:00
@( ex?( p?( ort) ) ) )
mode = export
; ;
@( annotate| diff| history| import| release| status| update| ?( un) edit) )
2002-02-28 22:23:14 +00:00
mode = $i
; ;
?( r) log)
mode = log
; ;
@( rdiff| patch) )
mode = rdiff
; ;
@( remove| rm| delete) )
mode = remove
; ;
@( rtag| rfreeze) )
mode = rtag
; ;
@( tag| freeze) )
mode = tag
; ;
*)
; ;
esac
elif [ [ " $i " = -* ] ] ; then
2003-03-29 07:29:49 +00:00
flags = ( ${ flags [@] :- } $i )
2002-02-28 22:23:14 +00:00
fi
count = $(( + + count))
done
2000-08-29 00:41:27 +00:00
2002-02-28 22:23:14 +00:00
case " $mode " in
add)
2002-03-01 06:58:23 +00:00
if [ [ " $cur " != -* ] ] ; then
2002-02-28 22:23:14 +00:00
set_prefix
2003-02-06 18:06:29 +00:00
if [ $COMP_CWORD -gt 1 -a -r ${ prefix :- } CVS/Entries ] ; then
2002-02-28 22:23:14 +00:00
get_entries
[ -z " $cur " ] && \
2002-09-09 13:46:17 +00:00
files = $( command ls -Ad !( CVS) ) || \
2002-06-04 03:45:09 +00:00
files = $( command ls -d ${ cur } * 2>/dev/null )
2003-02-06 18:06:29 +00:00
for i in ${ entries [@] :- } ; do
2002-09-09 13:46:17 +00:00
files = ( ${ files [@]/# $i // } )
2002-02-28 22:23:14 +00:00
done
2002-03-01 06:58:23 +00:00
COMPREPLY = ( $( compgen -W '${files[@]}' -- \
$cur ) )
2002-02-28 22:23:14 +00:00
fi
else
COMPREPLY = ( $( compgen -W '-k -m' -- $cur ) )
fi
; ;
admin)
2002-03-01 06:58:23 +00:00
if [ [ " $cur " = -* ] ] ; then
2002-02-28 22:23:14 +00:00
COMPREPLY = ( $( compgen -W ' -i -a -A -e -b -c -k -l -u \
-L -U -m -M -n -N -o -q -I \
-s -t -t- -T -V -x -z' -- \
$cur ) )
fi
; ;
checkout)
2002-03-01 06:58:23 +00:00
if [ [ " $cur " != -* ] ] ; then
2002-05-08 15:26:18 +00:00
[ -z " $cvsroot " ] && cvsroot = $CVSROOT
COMPREPLY = ( $( cvs -d " $cvsroot " co -c | awk '{print $1}' ) )
2002-05-05 18:29:35 +00:00
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
2002-02-28 22:23:14 +00:00
else
COMPREPLY = ( $( compgen -W ' -A -N -P -R -c -f -l -n -p \
-s -r -D -d -k -j' -- $cur ) )
fi
; ;
commit)
set_prefix
2002-04-02 17:22:40 +00:00
2003-01-25 21:22:16 +00:00
if [ [ " $cur " != -* ] ] && [ -r ${ prefix :- } CVS/Entries ] ; then
2002-04-02 17:22:40 +00:00
# if $COMP_CVS_REMOTE is not null, 'cvs commit' will
# complete on remotely checked-out files (requires
# passwordless access to the remote repository
2003-01-30 07:41:42 +00:00
if [ -n " ${ COMP_CVS_REMOTE :- } " ] ; then
2002-04-01 14:45:45 +00:00
# this is the least computationally intensive
# way found so far, but other changes
# (something other than changed/removed/new)
# may be missing
changed = ( $( cvs diff --brief 2>& 1 | \
sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ) )
newremoved = ( $( cvs diff --brief 2>& 1 | \
sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ) )
2003-01-25 21:22:16 +00:00
COMPREPLY = ( $( compgen -W ' ${ changed [@] :- } \
${ newremoved [@] :- } ' -- $cur ) )
2002-04-01 14:45:45 +00:00
else
COMPREPLY = ( $( compgen -f -- $cur ) )
fi
2002-02-28 22:23:14 +00:00
else
COMPREPLY = ( $( compgen -W '-n -R -l -f -F -m -r' -- \
$cur ) )
fi
; ;
2003-02-08 06:33:51 +00:00
cvsroot)
if [ -r ~/.cvspass ] ; then
# Ugly escaping because of bash treating ':' specially
cvsroots = $( sed 's/^[^ ]* //; s/:/\\:/g' ~/.cvspass )
COMPREPLY = ( $( compgen -W '$cvsroots' -- $cur ) )
fi
; ;
2003-01-17 09:09:59 +00:00
export )
if [ [ " $cur " != -* ] ] ; then
[ -z " $cvsroot " ] && cvsroot = $CVSROOT
COMPREPLY = ( $( cvs -d " $cvsroot " co -c | awk '{print $1}' ) )
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
else
COMPREPLY = ( $( compgen -W ' -N -f -l -R -n \
-r -D -d -k' -- $cur ) )
fi
; ;
2002-04-30 19:55:20 +00:00
diff)
if [ [ " $cur " = = -* ] ] ; then
_longopt diff
else
get_entries
2002-12-18 18:15:46 +00:00
COMPREPLY = ( ${ entries [@] :- } )
2002-04-30 19:55:20 +00:00
fi
; ;
2002-02-28 22:23:14 +00:00
remove)
2002-03-01 06:58:23 +00:00
if [ [ " $cur " != -* ] ] ; then
2002-02-28 22:23:14 +00:00
set_prefix
2003-02-06 18:06:29 +00:00
if [ $COMP_CWORD -gt 1 -a -r ${ prefix :- } CVS/Entries ] ; then
2002-02-28 22:23:14 +00:00
get_entries
# find out what files are missing
for i in ${ entries [@] } ; do
2003-02-06 18:06:29 +00:00
[ ! -r " $i " ] && miss = ( ${ miss [@] :- } $i )
2002-02-28 22:23:14 +00:00
done
2003-02-06 18:06:29 +00:00
COMPREPLY = ( $( compgen -W '${miss[@]:-}' -- $cur ) )
2002-02-28 22:23:14 +00:00
fi
else
COMPREPLY = ( $( compgen -W '-f -l -R' -- $cur ) )
fi
; ;
import)
2002-03-01 06:58:23 +00:00
if [ [ " $cur " != -* ] ] ; then
2002-02-28 22:23:14 +00:00
# starts with same algorithm as checkout
[ -z " $cvsroot " ] && cvsroot = $CVSROOT
2002-03-01 18:29:34 +00:00
prefix = ${ cur %/* }
if [ -r ${ cvsroot } /${ prefix } ] ; then
get_modules
2002-03-01 06:58:23 +00:00
COMPREPLY = ( ${ COMPREPLY [@]# $cvsroot } )
COMPREPLY = ( ${ COMPREPLY [@]# \/ } )
fi
2002-02-28 22:23:14 +00:00
pwd = $( pwd )
pwd = ${ pwd ##*/ }
2002-03-01 06:58:23 +00:00
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]} $pwd' -- \
$cur ) )
2002-02-28 22:23:14 +00:00
else
COMPREPLY = ( $( compgen -W '-d -k -I -b -m -W' -- $cur ) )
fi
; ;
2002-03-01 06:58:23 +00:00
"" )
2002-04-18 13:55:50 +00:00
COMPREPLY = ( $( compgen -W ' add admin annotate checkout ci co \
2002-06-21 07:11:32 +00:00
commit diff delete edit export \
freeze get history import log new \
patch rcs rdiff release remove \
rfreeze rlog rm rtag status tag \
unedit update -H -Q -q -b -d -e -f \
-l -n -t -r -v -w -x -z --help \
--version' -- $cur ) )
2002-02-28 22:23:14 +00:00
; ;
2002-03-01 06:58:23 +00:00
*)
; ;
2002-02-28 22:23:14 +00:00
esac
2000-08-11 21:20:41 +00:00
return 0
}
2002-06-01 18:58:06 +00:00
complete -F _cvs $default cvs
2002-05-02 22:43:50 +00:00
}
2000-08-11 21:20:41 +00:00
2002-04-29 18:58:39 +00:00
have rpm && {
2002-04-07 17:17:13 +00:00
# helper functions for rpm completion
#
2002-09-09 16:26:14 +00:00
_rpm_installed_packages( )
2000-08-11 21:20:41 +00:00
{
2002-12-18 18:15:46 +00:00
local i
2002-04-07 17:17:13 +00:00
if [ -r /var/log/rpmpkgs -a \
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ] ; then
# using RHL 7.2 - this is quicker than querying the DB
COMPREPLY = ( $( sed -ne \
2002-07-23 13:59:15 +00:00
's|^\(' $cur '.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+.*\.rpm$|\1|p' \
2002-04-07 17:17:13 +00:00
/var/log/rpmpkgs ) )
else
COMPREPLY = ( $( rpm -qa | sed -ne \
2002-07-23 13:59:15 +00:00
's|^\(' $cur '.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+$|\1|p' ) )
2002-04-07 17:17:13 +00:00
fi
}
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
2002-09-09 16:26:14 +00:00
_rpm_groups( )
2002-04-17 06:44:12 +00:00
{
local IFS = $'\t'
# remove trailing backslash, or grep will complain
2002-10-01 06:07:33 +00:00
cur = ${ cur % "\\" }
2002-04-17 06:44:12 +00:00
COMPREPLY = ( $( rpm -qa --queryformat '%{group}\n' | grep " ^ $cur " ) )
# backslash escape spaces and translate newlines to tabs
COMPREPLY = ( $( echo ${ COMPREPLY [@] } | sed 's/ /\\ /g' | tr '\n' '\t' ) )
}
2002-04-07 17:17:13 +00:00
# rpm(8) completion
#
_rpm( )
{
2002-02-27 00:14:52 +00:00
local cur prev
2000-08-11 21:20:41 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-08-11 21:20:41 +00:00
2002-02-26 22:59:47 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
2000-08-11 21:20:41 +00:00
# first parameter on line
case " $cur " in
-b*)
2002-02-27 00:14:52 +00:00
COMPREPLY = ( $( compgen -W '-ba -bb -bc -bi -bl -bp -bs' \
-- $cur ) )
2000-08-11 21:20:41 +00:00
; ;
-t*)
2002-02-27 00:14:52 +00:00
COMPREPLY = ( $( compgen -W '-ta -tb -tc -ti -tl -tp -ts' \
-- $cur ) )
2000-08-11 21:20:41 +00:00
; ;
--*)
2002-02-27 00:14:52 +00:00
COMPREPLY = ( $( compgen -W ' --help --version --initdb \
--checksig --recompile --rebuild --resign --addsign \
--rebuilddb --showrc --setperms --setugids --tarbuild \
--eval --install --upgrade --query --freshen --erase \
2002-05-05 18:20:02 +00:00
--verify --querytags --rmsource --rmspec --clean \
--import' -- $cur ) )
2000-08-11 21:20:41 +00:00
; ;
*)
2002-02-27 00:14:52 +00:00
COMPREPLY = ( $( compgen -W '-b -e -F -i -q -t -U -V' \
-- $cur ) )
2000-08-11 21:20:41 +00:00
; ;
esac
2002-02-27 00:14:52 +00:00
return 0
2000-08-11 21:20:41 +00:00
fi
2000-08-29 00:41:27 +00:00
case " $prev " in
2002-02-27 00:14:52 +00:00
--@( @( db| exclude) path| prefix| relocate| root) )
2002-02-27 15:48:20 +00:00
_filedir -d
2000-08-29 00:41:27 +00:00
return 0
; ;
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
--eval)
2002-01-03 00:16:41 +00:00
# get a list of macros
2002-03-01 00:42:13 +00:00
COMPREPLY = ( $( sed -ne 's|^\(%' ${ cur # \% } '[^ ' $'\t' ']*\).*$|\1|p' \
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
/usr/lib/rpm/macros ) )
return 0
; ;
--pipe)
2002-02-27 00:14:52 +00:00
COMPREPLY = ( $( compgen -c -- $cur ) )
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
return 0
; ;
--rcfile)
2002-02-27 15:48:20 +00:00
_filedir
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
return 0
; ;
2001-03-05 19:12:48 +00:00
--specfile)
# complete on .spec files
2002-05-18 17:05:08 +00:00
_filedir spec
2001-03-05 19:12:48 +00:00
return 0
; ;
--whatprovides)
2002-03-04 03:46:42 +00:00
if [ [ " $cur " = = */* ] ] ; then
_filedir
else
2001-03-05 19:12:48 +00:00
# complete on capabilities
2002-03-29 07:30:47 +00:00
COMPREPLY = ( $( rpm -qa --queryformat \
2002-04-03 21:17:10 +00:00
'%{providename}\n' | grep " ^ $cur " ) )
2002-03-04 03:46:42 +00:00
fi
2001-03-05 19:12:48 +00:00
return 0
; ;
--whatrequires)
# complete on capabilities
2002-03-29 07:30:47 +00:00
COMPREPLY = ( $( rpm -qa --queryformat '%{requirename}\n' | \
2002-04-03 21:17:10 +00:00
grep " ^ $cur " ) )
2001-03-05 19:12:48 +00:00
return 0
; ;
2000-08-29 00:41:27 +00:00
esac
2000-08-11 21:20:41 +00:00
case " ${ COMP_WORDS [1] } " in
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
-@( [ iFU] *| -install| -freshen| -upgrade) )
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --percent --force --test \
--replacepkgs --replacefiles --root --excludedocs \
--includedocs --noscripts --rcfile --ignorearch \
--dbpath --prefix --ignoreos --nodeps --allfiles \
--ftpproxy --ftpport --justdb --httpproxy --httpport \
--noorder --relocate --badreloc --notriggers \
--excludepath --ignoresize --oldpackage --define \
2002-05-05 18:20:02 +00:00
--eval --pipe --queryformat --repackage --nosuggests \
--nodigest --nosignature' -- $cur ) )
2002-03-29 07:30:47 +00:00
else
2002-05-19 14:56:19 +00:00
_filedir 'rpm'
2002-03-29 07:30:47 +00:00
fi
2000-08-11 21:20:41 +00:00
; ;
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
-@( e| -erase) )
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --allmatches --noscripts \
--notriggers --nodeps --test --repackage' -- $cur ) )
else
2002-09-09 16:26:14 +00:00
_rpm_installed_packages
2002-03-29 07:30:47 +00:00
fi
2000-08-11 21:20:41 +00:00
; ;
2002-03-29 07:30:47 +00:00
-@( q*| -query) )
2002-04-17 06:44:12 +00:00
# check whether we're doing file completion
if [ " ${ COMP_LINE #* -*([^ -])f } " != " $COMP_LINE " ] ; then
_filedir
elif [ " ${ COMP_LINE #* -*([^ -])g } " != " $COMP_LINE " ] ; then
2002-09-09 16:26:14 +00:00
_rpm_groups
2002-04-05 17:45:05 +00:00
elif [ " ${ COMP_LINE #* -*([^ -])p } " != " $COMP_LINE " ] ; then
2002-04-03 21:10:35 +00:00
# uninstalled package completion
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --scripts --root \
--rcfile --whatprovides --whatrequires \
--requires --triggeredby --ftpport --ftpproxy \
--httpproxy --httpport --provides --triggers \
--dump --changelog --dbpath --filesbypkg \
--define --eval --pipe --showrc --info --list \
--state --docfiles --configfiles --queryformat \
2002-05-05 18:20:02 +00:00
--conflicts --obsoletes --nodigest \
--nosignature' -- $cur ) )
2002-03-29 07:30:47 +00:00
else
2002-05-19 14:56:19 +00:00
_filedir 'rpm'
2002-03-29 07:30:47 +00:00
fi
2002-03-07 16:16:43 +00:00
else
2002-04-03 21:10:35 +00:00
# installed package completion
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --scripts --root \
--rcfile --whatprovides --whatrequires \
--requires --triggeredby --ftpport --ftpproxy \
--httpproxy --httpport --provides --triggers \
--dump --changelog --dbpath --specfile \
--querybynumber --last --filesbypkg --define \
--eval --pipe --showrc --info --list --state \
--docfiles --configfiles --queryformat \
--conflicts --obsoletes --pkgid --hdrid \
2002-05-05 18:20:02 +00:00
--fileid --tid --nodigest --nosignature' \
-- $cur ) )
2002-04-05 17:45:05 +00:00
elif [ " ${ COMP_LINE #* -*([^ -])a } " = = " $COMP_LINE " ] ; then
2002-09-09 16:26:14 +00:00
_rpm_installed_packages
2002-03-29 07:30:47 +00:00
fi
2002-03-07 16:16:43 +00:00
fi
2001-08-22 15:20:27 +00:00
; ;
2002-12-04 04:32:06 +00:00
-@( K*| -checksig) )
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
2002-05-05 18:20:02 +00:00
COMPREPLY = ( $( compgen -W ' --nopgp --nogpg --nomd5 \
--nodigest --nosignature' -- $cur ) )
2002-03-29 07:30:47 +00:00
else
2002-05-19 14:56:19 +00:00
_filedir 'rpm'
2002-03-29 07:30:47 +00:00
fi
2000-08-11 21:20:41 +00:00
; ;
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
-@( [ Vy] *| -verify) )
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --root --rcfile --dbpath \
--nodeps --nofiles --noscripts --nomd5 --querytags \
2002-05-05 18:20:02 +00:00
--specfile --whatrequires --whatprovides --nodigest \
--nosignature' -- $cur ) )
2002-04-17 06:44:12 +00:00
# check whether we're doing file completion
elif [ " ${ COMP_LINE #* -*([^ -])f } " != " $COMP_LINE " ] ; then
_filedir
elif [ " ${ COMP_LINE #* -*([^ -])g } " != " $COMP_LINE " ] ; then
2002-09-09 16:26:14 +00:00
_rpm_groups
2002-04-05 17:45:05 +00:00
elif [ " ${ COMP_LINE #* -*([^ -])p } " != " $COMP_LINE " ] ; then
2002-05-19 14:56:19 +00:00
_filedir 'rpm'
2002-03-22 15:45:42 +00:00
else
2002-09-09 16:26:14 +00:00
_rpm_installed_packages
2002-03-22 15:45:42 +00:00
fi
2000-08-11 21:20:41 +00:00
; ;
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
-[ bt] *)
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --short-circuit --timecheck \
--clean --rmsource --rmspec --test --sign --buildroot \
--targetbuildarch --buildos --nobuild --nodeps \
--nodirtokens' -- $cur ) )
elif [ [ ${ COMP_WORDS [1] } = = -b* ] ] ; then
2002-05-19 14:56:19 +00:00
_filedir 'spec'
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
else
2002-05-19 14:56:19 +00:00
_filedir '@(tgz|tar.@(gz|bz2))'
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
fi
2000-08-11 21:20:41 +00:00
; ;
--re@( build| compile) )
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --nodeps --rmsource \
--rmspec --sign --nodirtokens' -- $cur ) )
else
2002-05-19 14:56:19 +00:00
_filedir 'src.rpm'
2002-03-29 07:30:47 +00:00
fi
2000-08-11 21:20:41 +00:00
; ;
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
--tarbuild)
2002-05-19 14:56:19 +00:00
_filedir '@(tgz|tar.@(gz|bz2))'
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
; ;
--@( re| add) sign)
2002-05-19 14:56:19 +00:00
_filedir 'rpm'
2000-08-11 21:20:41 +00:00
; ;
--set@( perms| gids) )
2002-09-09 16:26:14 +00:00
_rpm_installed_packages
2000-08-11 21:20:41 +00:00
; ;
2002-01-30 04:04:28 +00:00
--@( clean| rms@( ource| pec) ) )
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --clean --rmsource \
--rmspec' -- $cur ) )
else
2002-05-19 14:56:19 +00:00
_filedir 'spec'
2002-03-29 07:30:47 +00:00
fi
2000-12-20 02:04:54 +00:00
; ;
2002-05-05 18:20:02 +00:00
--@( import| dbpath| root) )
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '--import --dbpath --root' \
-- $cur ) )
else
_filedir
fi
; ;
2000-08-11 21:20:41 +00:00
esac
2000-08-29 00:41:27 +00:00
return 0
2000-08-11 21:20:41 +00:00
}
2002-04-29 18:58:39 +00:00
complete -F _rpm $filenames rpm rpmbuild
}
2000-08-11 21:20:41 +00:00
2002-05-09 16:20:53 +00:00
# Debian apt-get(8) completion.
2000-10-09 18:07:50 +00:00
#
2001-07-08 23:14:13 +00:00
have apt-get &&
2002-02-27 00:24:04 +00:00
_apt_get( )
2000-10-09 18:07:50 +00:00
{
2001-11-20 04:15:48 +00:00
local cur prev special i
2000-10-09 18:07:50 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-10-09 18:07:50 +00:00
for ( ( i = 0; i < ${# COMP_WORDS } -1; i++ ) ) ; do
2002-04-07 17:17:13 +00:00
if [ [ ${ COMP_WORDS [i] } = = @( install| remove| source| build-dep) ] ] ; then
2000-10-09 18:07:50 +00:00
special = ${ COMP_WORDS [i] }
fi
done
2002-10-02 01:32:40 +00:00
2000-10-09 18:07:50 +00:00
if [ -n " $special " ] ; then
case $special in
2002-04-07 17:17:13 +00:00
remove)
if [ -f /etc/debian_version ] ; then
# Debian system
COMPREPLY = ( $( _comp-dpkg-installed-packages \
$cur ) )
else
# assume RPM based
2002-09-09 16:26:14 +00:00
_rpm_installed_packages
2002-04-07 17:17:13 +00:00
fi
return 0
; ;
2002-10-13 01:46:49 +00:00
*)
COMPREPLY = ( $( apt-cache pkgnames $cur 2> /dev/null ) )
return 0
; ;
2000-10-09 18:07:50 +00:00
esac
fi
2002-10-02 01:32:40 +00:00
case " $prev " in
-@( c| -config-file) )
_filedir
return 0
; ;
-@( t| -target-release| -default-release) )
COMPREPLY = ( $( apt-cache policy | \
grep " release.o=Debian,a= $cur " | \
sed -e "s/.*a=\(\w*\).*/\1/" | uniq ) )
return 0
; ;
2002-10-13 01:46:49 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -d -f -h -v -m -q -s -y \
2002-10-02 01:32:40 +00:00
-u -t -b -c -o --download-only --fix-broken \
--help --version --ignore-missing \
--fix-missing --no-download --quiet --simulate \
--just-print --dry-run --recon --no-act --yes \
--assume-yes --show-upgraded --only-source \
--compile --build --ignore-hold \
--target-release --no-upgrade --force-yes \
--print-uris --purge --reinstall \
--list-cleanup --default-release \
--trivial-only --no-remove --diff-only \
--tar-only --config-file --option' -- $cur ) )
2002-10-13 01:46:49 +00:00
else
COMPREPLY = ( $( compgen -W ' update upgrade dselect-upgrade \
dist-upgrade install remove source build-dep \
check clean autoclean' -- $cur ) )
fi
2000-10-09 18:07:50 +00:00
return 0
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _apt_get $filenames apt-get
2000-10-09 18:07:50 +00:00
2002-05-09 16:20:53 +00:00
# Debian apt-cache(8) completion.
2000-10-09 18:07:50 +00:00
#
2001-07-08 23:14:13 +00:00
have apt-cache &&
2002-02-27 00:24:04 +00:00
_apt_cache( )
2000-10-09 18:07:50 +00:00
{
2001-11-20 04:15:48 +00:00
local cur prev special i
2000-10-09 18:07:50 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-10-09 18:07:50 +00:00
2002-10-13 01:46:49 +00:00
if [ " $cur " != show ] ; then
for ( ( i = 0; i < ${# COMP_WORDS } -1; i++ ) ) ; do
2003-04-12 03:05:37 +00:00
if [ [ ${ COMP_WORDS [i] } = = @( add| depends| dotty| policy| show?( pkg| src) ) ] ] ; then
2002-10-13 01:46:49 +00:00
special = ${ COMP_WORDS [i] }
2000-10-09 18:07:50 +00:00
fi
2002-10-13 01:46:49 +00:00
done
fi
2002-10-02 01:32:40 +00:00
2000-10-09 18:07:50 +00:00
if [ -n " $special " ] ; then
2002-10-13 01:46:49 +00:00
case $special in
2000-10-09 18:07:50 +00:00
add)
2002-10-13 01:46:49 +00:00
_filedir
return 0
; ;
*)
COMPREPLY = ( $( apt-cache pkgnames $cur 2> /dev/null ) )
return 0
; ;
esac
2000-10-09 18:07:50 +00:00
fi
2002-10-02 01:32:40 +00:00
case " $prev " in
-@( c| p| s| -config-file| -@( pkg| src) -cache) )
_filedir
return 0
; ;
2002-10-13 01:46:49 +00:00
search)
return 0
; ;
esac
2002-10-02 01:32:40 +00:00
2002-10-13 01:46:49 +00:00
if [ [ " $cur " = = -* ] ] ; then
2002-10-02 01:32:40 +00:00
2002-10-13 01:46:49 +00:00
COMPREPLY = ( $( compgen -W ' -h -v -p -s -q -i -f -a -g -c \
2000-10-09 18:07:50 +00:00
-o --help --version --pkg-cache --src-cache \
--quiet --important --full --all-versions \
2002-10-02 01:32:40 +00:00
--generate --no-generate --names-only \
--all-names --config-file --option \
--recurse' -- $cur ) )
2002-10-13 01:46:49 +00:00
else
COMPREPLY = ( $( compgen -W ' add gencaches showpkg show stats \
dumpavail unmet check search dump dotty policy \
2003-04-12 03:05:37 +00:00
depends pkgnames showsrc' -- $cur ) )
2002-10-13 01:46:49 +00:00
fi
2000-10-09 18:07:50 +00:00
return 0
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _apt_cache $filenames apt-cache
2002-10-13 01:46:49 +00:00
2000-10-09 18:07:50 +00:00
2002-09-28 16:12:24 +00:00
# Debian aptitude(1) completion
2002-05-05 17:24:31 +00:00
#
2002-05-11 07:28:58 +00:00
have aptitude && {
_comp-dpkg-hold-packages( )
{
2002-05-30 18:17:29 +00:00
grep -B 2 'hold' /var/lib/dpkg/status | grep " Package: $1 " \
2002-05-19 07:16:30 +00:00
| cut -d\ -f2
2002-05-11 07:28:58 +00:00
}
2002-05-05 17:24:31 +00:00
_aptitude( )
{
local cur dashoptions prev special i
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-09-28 16:12:24 +00:00
dashoptions = ' -S -u -i -h --help --version -s --simulate -d \
2002-05-05 17:24:31 +00:00
--download-only -P --prompt -y --assume-yes -F \
--display-format -w --width -f --with-recommends \
--with-suggests --without-recommends --without-suggests'
for ( ( i = 0; i < ${# COMP_WORDS } -1; i++ ) ) ; do
2002-05-19 07:16:30 +00:00
if [ [ ${ COMP_WORDS [i] } = = @( install| hold| unhold| markauto| unmarkauto| dist-upgrade| download| purge| remove) ] ] ; then
2002-05-05 17:24:31 +00:00
special = ${ COMP_WORDS [i] }
fi
2002-05-08 15:38:56 +00:00
#exclude some mutually exclusive options
2002-05-05 17:24:31 +00:00
[ [ ${ COMP_WORDS [i] } = = '-u' ] ] && dashoptions = ${ dashoptions /-i }
[ [ ${ COMP_WORDS [i] } = = '-i' ] ] && dashoptions = ${ dashoptions /-u }
done
if [ [ -n " $special " ] ] ; then
case $special in
@( install| hold| markauto| unmarkauto| dist-upgrade| download) )
2002-10-05 06:08:53 +00:00
COMPREPLY = ( $( apt-cache pkgnames $cur 2> /dev/null ) )
2002-09-28 16:12:24 +00:00
return 0
2002-05-05 17:24:31 +00:00
; ;
@( purge| remove) )
2002-09-28 16:12:24 +00:00
COMPREPLY = ( $( _comp-dpkg-installed-packages $cur ) )
return 0
2002-05-05 17:24:31 +00:00
; ;
unhold)
2002-09-28 16:12:24 +00:00
COMPREPLY = ( $( _comp-dpkg-hold-packages $cur ) )
return 0
2002-05-05 17:24:31 +00:00
; ;
esac
fi
case $prev in
2002-05-19 07:16:30 +00:00
# don't complete anything if these options are found
2002-05-05 17:24:31 +00:00
@( autoclean| clean| forget-new| search| upgrade| update) )
2002-09-28 16:12:24 +00:00
return 0
2002-05-05 17:24:31 +00:00
; ;
-S)
2002-09-28 16:12:24 +00:00
_filedir
2002-05-05 17:24:31 +00:00
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W " $dashoptions " -- $cur ) )
else
COMPREPLY = ( $( compgen -W ' update upgrade forget-new clean \
autoclean install remove hold unhold \
purge markauto unmarkauto dist-upgrade \
download search' -- $cur ) )
fi
2002-10-13 01:46:49 +00:00
return 0
2002-05-05 17:24:31 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _aptitude $default aptitude
2002-05-11 07:28:58 +00:00
}
2002-05-05 17:24:31 +00:00
2002-07-31 23:11:14 +00:00
# Debian apt-build(1) completion.
#
2002-09-28 16:48:02 +00:00
have apt-build &&
2002-10-02 01:32:40 +00:00
_apt_build( )
2002-07-31 23:11:14 +00:00
{
local cur prev special i
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
for ( ( i = 0; i < ${# COMP_WORDS } -1; i++ ) ) ; do
2002-09-28 16:33:12 +00:00
if [ [ ${ COMP_WORDS [i] } = = @( install| remove| source| info| clean) ] ] ; then
2002-07-31 23:11:14 +00:00
special = ${ COMP_WORDS [i] }
fi
done
2002-09-28 16:33:12 +00:00
2002-07-31 23:11:14 +00:00
if [ -n " $special " ] ; then
case $special in
2002-09-28 16:33:12 +00:00
@( install| source| info) )
2002-10-05 06:08:53 +00:00
COMPREPLY = ( $( apt-cache pkgnames $cur 2> /dev/null ) )
2002-07-31 23:11:14 +00:00
return 0
; ;
remove)
2002-09-28 16:12:24 +00:00
COMPREPLY = ( $( _comp-dpkg-installed-packages \
2002-09-28 16:33:12 +00:00
$cur ) )
return 0
; ;
*)
2002-07-31 23:11:14 +00:00
return 0
; ;
esac
fi
2002-10-02 01:32:40 +00:00
case " $prev " in
--@( patch| build-dir| repository-dir) )
_filedir
return 0
; ;
-@( h| -help) )
return 0
; ;
2002-07-31 23:11:14 +00:00
2002-10-13 01:46:49 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --help --show-upgraded -u --build-dir \
2002-10-02 01:32:40 +00:00
--repository-dir --build-only \
--build-command --reinstall --rebuild \
--remove-builddep --no-wrapper --purge \
--patch --patch-strip -p --yes -y \
2002-10-13 01:46:49 +00:00
--version -v --no-source' -- $cur ) )
else
COMPREPLY = ( $( compgen -W ' update upgrade install remove \
source dist-upgrade world clean info \
2002-10-17 00:53:37 +00:00
clean-build update-repository ' -- $cur ) )
2002-10-13 01:46:49 +00:00
fi
2002-07-31 23:11:14 +00:00
return 0
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _apt_build $filenames apt-build
2002-07-31 23:11:14 +00:00
2000-08-29 00:41:27 +00:00
# chsh(1) completion
#
2000-08-11 21:20:41 +00:00
_chsh( )
{
local cur prev
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-08-11 21:20:41 +00:00
if [ " $prev " = "-s" ] ; then
2002-04-03 21:17:10 +00:00
COMPREPLY = ( $( chsh -l | grep " ^ $cur " ) )
2000-08-11 21:20:41 +00:00
else
2002-02-27 00:41:56 +00:00
COMPREPLY = ( $( compgen -u -- $cur ) )
2000-08-11 21:20:41 +00:00
fi
2000-08-29 00:41:27 +00:00
return 0
2000-08-11 21:20:41 +00:00
}
complete -F _chsh chsh
2000-08-29 00:41:27 +00:00
# chkconfig(8) completion
#
2001-07-08 23:14:13 +00:00
have chkconfig &&
2000-08-11 21:20:41 +00:00
_chkconfig( )
{
2002-02-27 00:41:56 +00:00
local cur prev
2000-08-11 21:20:41 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-08-11 21:20:41 +00:00
2002-02-26 22:59:47 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
2002-02-27 00:41:56 +00:00
COMPREPLY = ( $( compgen -W '--list --add --del --level' -- \
$cur ) )
2000-08-11 21:20:41 +00:00
return 0
fi
if [ $COMP_CWORD -eq 4 ] ; then
2002-02-27 00:41:56 +00:00
COMPREPLY = ( $( compgen -W 'on off reset' -- $cur ) )
2000-08-11 21:20:41 +00:00
return 0
fi
case " $prev " in
@( [ 1-6] | --@( list| add| del) ) )
COMPREPLY = ( $( compgen -W "`(cd /etc/rc.d/init.d; echo *)`" \
2002-02-27 00:41:56 +00:00
-- $cur ) )
2000-08-11 21:20:41 +00:00
return 0
; ;
--level)
2002-02-27 00:41:56 +00:00
COMPREPLY = ( $( compgen -W '1 2 3 4 5 6' -- $cur ) )
2000-08-11 21:20:41 +00:00
return 0
; ;
esac
2000-08-29 00:41:27 +00:00
return 0
2000-08-11 21:20:41 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _chkconfig chkconfig
2000-08-11 21:20:41 +00:00
2002-10-05 05:52:37 +00:00
# This function provides simple user@host completion
2002-07-22 16:57:28 +00:00
#
_user_at_host( ) {
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
if [ [ $cur = = *@* ] ] ; then
_known_hosts
else
COMPREPLY = ( $( compgen -S '@' -u -- " $cur " ) )
fi
return 0
}
2002-12-10 00:30:08 +00:00
shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
2002-07-22 16:57:28 +00:00
2002-01-08 04:49:06 +00:00
# This function performs host completion based on ssh's known_hosts files,
# defaulting to standard host completion if they don't exist.
2000-08-29 00:41:27 +00:00
#
2000-09-25 21:38:11 +00:00
_known_hosts( )
2000-08-29 00:41:27 +00:00
{
2002-05-17 22:35:26 +00:00
local cur ocur user suffix aliases global_kh user_kh hosts
2002-05-05 23:31:28 +00:00
local -a kh config
2000-08-29 00:41:27 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-05-17 22:35:26 +00:00
ocur = $cur
[ " $1 " = -a ] || [ " $2 " = -a ] && aliases = 'yes'
[ " $1 " = -c ] || [ " $2 " = -c ] && suffix = ':'
2002-01-16 07:14:14 +00:00
[ [ $cur = = *@* ] ] && user = ${ cur %@* } @ && cur = ${ cur #*@ }
2001-03-05 19:12:48 +00:00
kh = ( )
2000-09-11 18:46:39 +00:00
2002-05-05 23:31:28 +00:00
# ssh config files
[ -r /etc/ssh/ssh_config ] && config[ 0] = /etc/ssh/ssh_config
[ -r ~/.ssh/config ] && config[ 1] = ~/.ssh/config
if [ ${# config [@] } -gt 0 ] ; then
# expand path (if present) to global known hosts file
2002-05-30 18:26:41 +00:00
global_kh = $( eval echo $( sed -ne 's/^[Gg][Ll][Oo][Bb][Aa][Ll][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][' $'\t ' ']*\(.*\)$/\1/p' ${ config [@] } ) )
2002-05-05 23:31:28 +00:00
# expand path (if present) to user known hosts file
2002-05-30 18:26:41 +00:00
user_kh = $( eval echo $( sed -ne 's/^[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][' $'\t ' ']*\(.*\)$/\1/p' ${ config [@] } ) )
2002-05-05 23:31:28 +00:00
fi
# choose which global known hosts file to use
if [ -r " $global_kh " ] ; then
kh = ( " $global_kh " )
else
2002-12-23 07:51:39 +00:00
[ -r /etc/ssh/ssh_known_hosts ] && kh[ 0] = /etc/ssh/ssh_known_hosts
[ -r /etc/ssh/ssh_known_hosts2 ] && kh[ 1] = /etc/ssh/ssh_known_hosts2
2002-12-31 02:15:25 +00:00
[ -r /etc/known_hosts ] && kh[ 2] = /etc/known_hosts
[ -r /etc/known_hosts2 ] && kh[ 3] = /etc/known_hosts2
2002-05-05 23:31:28 +00:00
fi
# choose which user known hosts file to use
if [ -r " $user_kh " ] ; then
kh = ( ${ kh [@] } " $user_kh " )
else
[ -r ~/.ssh/known_hosts ] && kh = ( ${ kh [@] } ~/.ssh/known_hosts )
[ -r ~/.ssh/known_hosts2 ] && kh = ( ${ kh [@] } ~/.ssh/known_hosts2 )
fi
2000-08-29 00:41:27 +00:00
# If we have known_hosts files to use
if [ ${# kh [@] } -gt 0 ] ; then
2002-01-16 07:14:14 +00:00
# Escape slashes and dots in paths for awk
cur = ${ cur // \/ / \\ \/ }
cur = ${ cur // \. / \\ \. }
2002-05-17 22:35:26 +00:00
2001-12-05 16:32:24 +00:00
if [ [ " $cur " = = [ 0-9] *.* ] ] ; then
2000-09-11 18:46:39 +00:00
# Digits followed by a dot - just search for that
cur = " ^ $cur .* "
2001-12-05 16:32:24 +00:00
elif [ [ " $cur " = = [ 0-9] * ] ] ; then
2000-09-11 18:46:39 +00:00
# Digits followed by no dot - search for digits followed
# by a dot
cur = " ^ $cur .*\. "
2001-12-05 16:32:24 +00:00
elif [ -z " $cur " ] ; then
2000-09-11 18:46:39 +00:00
# A blank - search for a dot or an alpha character
cur = "[a-z.]"
else
cur = " ^ $cur "
fi
2002-05-17 22:35:26 +00:00
2000-08-29 00:41:27 +00:00
# FS needs to look for a comma separated list
2001-11-20 04:15:48 +00:00
COMPREPLY = ( $( awk ' BEGIN { FS = "," }
{ for ( i = 1; i<= 2; ++i) { \
gsub( " .* $" , "" , $i ) ; \
2000-09-11 18:46:39 +00:00
if ( $i ~ /'$cur' /) { print $i } \
2003-01-09 10:25:58 +00:00
} } ' ${ kh [@] } 2>/dev/null ) )
2002-05-17 22:35:26 +00:00
# append any available aliases from config files
if [ ${# config [@] } -gt 0 ] && [ -n " $aliases " ] ; then
2002-05-30 18:26:41 +00:00
hosts = $( compgen -W " $( echo $( sed -ne "s/^[Hh][Oo][Ss][Tt][" $'\t ' " ]*\([^*?]*\) $/\1/p " ${ config [@] } ) ) " -- $ocur )
2002-05-17 22:35:26 +00:00
COMPREPLY = ( ${ COMPREPLY [@] } $hosts )
fi
# apply suffix
2002-01-16 07:14:14 +00:00
for ( ( i = 0; i < ${# COMPREPLY [@] } ; i++ ) ) ; do
2002-02-11 02:14:08 +00:00
COMPREPLY[ i] = $user ${ COMPREPLY [i] } $suffix
2002-01-16 07:14:14 +00:00
done
2000-08-29 00:41:27 +00:00
else
# Just do normal hostname completion
2002-02-27 00:41:56 +00:00
COMPREPLY = ( $( compgen -A hostname -S " $suffix " -- $cur ) )
2000-08-29 00:41:27 +00:00
fi
return 0
}
2002-12-10 00:30:08 +00:00
complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \
2002-12-23 07:52:37 +00:00
ping fping telnet host nslookup rsh rlogin ftp dig
2000-09-25 21:38:11 +00:00
2002-03-07 18:04:05 +00:00
# ssh(1) completion
2000-09-25 21:38:11 +00:00
#
2002-05-17 22:35:26 +00:00
have ssh && {
2000-09-25 21:38:11 +00:00
_ssh( )
{
2002-05-17 22:35:26 +00:00
local cur prev
2002-05-05 21:28:59 +00:00
local -a config
2000-09-25 21:38:11 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-09-25 21:38:11 +00:00
case " $prev " in
-*c)
COMPREPLY = ( $( compgen -W ' blowfish 3des 3des-cbc blowfish-cbc \
2002-02-27 00:41:56 +00:00
arcfour cast128-cbc' -- $cur ) )
2000-09-25 21:38:11 +00:00
; ;
2002-10-08 05:00:57 +00:00
-*i)
_filedir
; ;
2000-09-25 21:38:11 +00:00
-*l)
2002-02-27 00:41:56 +00:00
COMPREPLY = ( $( compgen -u -- $cur ) )
2000-09-25 21:38:11 +00:00
; ;
2001-11-20 04:15:48 +00:00
*)
2002-05-17 22:35:26 +00:00
_known_hosts -a
2002-05-05 21:28:59 +00:00
2002-02-26 22:59:47 +00:00
[ $COMP_CWORD -eq 1 ] || \
2002-02-27 00:41:56 +00:00
COMPREPLY = ( ${ COMPREPLY [@] } $( compgen -c -- $cur ) )
2000-09-25 21:38:11 +00:00
esac
2001-11-20 04:15:48 +00:00
return 0
}
2002-06-01 18:58:06 +00:00
shopt -u hostcomplete && complete -F _ssh ssh slogin sftp
2001-11-20 04:15:48 +00:00
2002-03-15 16:39:18 +00:00
# scp(1) completion
#
2001-11-20 04:15:48 +00:00
_scp( )
{
2002-03-15 06:20:04 +00:00
local cur userhost path
2000-09-25 21:38:11 +00:00
2002-10-17 03:33:24 +00:00
local IFS = $'\t\n'
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2001-11-20 04:15:48 +00:00
2002-01-24 04:03:26 +00:00
_expand || return 0
2002-03-15 06:20:04 +00:00
if [ [ " $cur " = = *:* ] ] ; then
# remove backslash escape from :
cur = ${ cur / \\ : / : }
userhost = ${ cur %%?( \\ ) : * }
path = ${ cur #* : }
2002-10-17 03:33:24 +00:00
# unescape spaces
path = ${ path // \\ \\ \\ \\ / }
2002-03-15 06:20:04 +00:00
if [ -z " $path " ] ; then
# default to home dir of specified user on remote host
2002-10-25 20:45:23 +00:00
path = $( ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
2002-03-15 06:20:04 +00:00
fi
2002-10-17 18:51:25 +00:00
# escape spaces; remove executables, aliases, pipes and sockets;
2002-10-25 20:45:23 +00:00
# add space at end of file names
2002-10-17 03:33:24 +00:00
COMPREPLY = ( $( ssh -o 'Batchmode yes' $userhost \
2002-10-22 18:23:41 +00:00
command ls -aF1d " $path * " 2>/dev/null | \
2002-10-22 13:59:44 +00:00
sed -e 's/ /\\\\\\\ /g' -e 's/[*@|=]$//g' \
2002-10-25 20:45:23 +00:00
-e 's/[^\/]$/& /g' ) )
2002-03-15 06:20:04 +00:00
return 0
fi
2002-05-17 22:35:26 +00:00
[ [ " $cur " = = */* ] ] || _known_hosts -c -a
2002-10-25 20:45:23 +00:00
COMPREPLY = ( ${ COMPREPLY [@] } $( command ls -aF1d " $cur " * \
2>/dev/null | sed -e 's/ /\\ /g' -e 's/[*@|=]$//g' \
-e 's/[^\/]$/& /g' ) )
2002-10-22 13:59:44 +00:00
2000-09-25 21:38:11 +00:00
return 0
}
2002-10-25 20:45:23 +00:00
complete -F _scp $nospace scp
2002-05-17 22:35:26 +00:00
}
2001-11-20 04:15:48 +00:00
2003-01-30 07:56:28 +00:00
# rsync(1) completion
#
have rsync &&
_rsync( )
{
local cur prev shell i userhost path
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
_expand || return 0
case " $prev " in
--@( config| password-file| include-from| exclude-from) )
_filedir
return 0
; ;
-@( T| -temp-dir| -compare-dest) )
_filedir -d
return 0
; ;
-@( e| -rsh) )
COMPREPLY = ( $( compgen -W 'rsh ssh' -- $cur ) )
return 0
; ;
esac
case " $cur " in
-*)
COMPREPLY = ( $( compgen -W ' -v -q -c -a -r -R -b -u -l -L -H \
-p -o -g -D -t -S -n -W -x -B -e -C -I -T -P \
-z -h -4 -6 --verbose --quiet --checksum \
--archive --recursive --relative --backup \
--backup-dir --suffix= --update --links \
--copy-links --copy-unsafe-links --safe-links \
--hard-links --perms --owner --group --devices\
--times --sparse --dry-run --whole-file \
--no-whole-file --one-file-system \
--block-size= --rsh= --rsync-path= \
--cvs-exclude --existing --ignore-existing \
--delete --delete-excluded --delete-after \
--ignore-errors --max-delete= --partial \
--force --numeric-ids --timeout= \
--ignore-times --size-only --modify-window= \
--temp-dir= --compare-dest= --compress \
--exclude= --exclude-from= --include= \
--include-from= --version --daemon --no-detach\
--address= --config= --port= --blocking-io \
--no-blocking-io --stats --progress \
--log-format= --password-file= --bwlimit= \
--write-batch= --read-batch= --help' -- $cur ) )
; ;
*:*)
# find which remote shell is used
shell = rsh
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = -@( e| -rsh) ] ] ; then
shell = ${ COMP_WORDS [i+1] }
break
fi
done
if [ [ " $shell " = = ssh ] ] ; then
# remove backslash escape from :
cur = ${ cur / \\ : / : }
userhost = ${ cur %%?( \\ ) : * }
path = ${ cur #* : }
# unescape spaces
path = ${ path // \\ \\ \\ \\ / }
if [ -z " $path " ] ; then
# default to home dir of specified
# user on remote host
path = $( ssh -o 'Batchmode yes' \
$userhost pwd 2>/dev/null)
fi
# escape spaces; remove executables, aliases, pipes
# and sockets; add space at end of file names
COMPREPLY = ( $( ssh -o 'Batchmode yes' $userhost \
command ls -aF1d " $path * " 2>/dev/null | \
sed -e 's/ /\\\\\\\ /g' -e 's/[*@|=]$//g' \
-e 's/[^\/]$/& /g' ) )
fi
; ;
*)
_known_hosts -c -a
_filedir
; ;
esac
return 0
}
[ -n " ${ have :- } " ] && complete -F _rsync $nospace rsync
2002-03-15 16:39:18 +00:00
# Linux route(8) completion
2000-09-11 18:46:39 +00:00
#
2002-04-22 05:59:08 +00:00
[ $UNAME = Linux ] &&
2000-09-11 18:46:39 +00:00
_route( )
{
local cur prev
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-09-11 18:46:39 +00:00
if [ " $prev " = dev ] ; then
2002-03-01 00:42:13 +00:00
COMPREPLY = ( $( ifconfig -a | sed -ne 's|^\(' $cur '[^ ]*\).*$|\1|p' ) )
2000-09-11 18:46:39 +00:00
return 0
fi
COMPREPLY = ( $( compgen -W ' add del -host -net netmask metric mss \
2002-04-03 19:10:49 +00:00
window irtt reject mod dyn reinstate dev \
default gw' -- $cur ) )
2000-09-11 18:46:39 +00:00
COMPREPLY = ( $( echo " ${ COMP_WORDS [@] } " | \
( while read -d ' ' i; do
[ " $i " = = "" ] && continue
# flatten array with spaces on either side,
# otherwise we cannot grep on word
# boundaries of first and last word
COMPREPLY = " ${ COMPREPLY [@] } "
# remove word from list of completions
COMPREPLY = ( ${ COMPREPLY / $i / } )
done
echo ${ COMPREPLY [@] } )
) )
return 0
}
2002-04-22 05:59:08 +00:00
[ $UNAME = Linux ] && complete -F _route route
2000-09-11 18:46:39 +00:00
2000-09-25 21:38:11 +00:00
# GNU make(1) completion (adapted from the example supplied with the bash 2.04
# source code)
#
2002-02-18 17:26:54 +00:00
have make &&
2000-09-25 21:38:11 +00:00
_make( )
{
2001-12-18 03:43:25 +00:00
local mdef makef gcmd cur prev i
2000-09-25 21:38:11 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-09-25 21:38:11 +00:00
2001-12-18 03:43:25 +00:00
# if prev argument is -f, return possible filename completions.
# we could be a little smarter here and return matches against
# `makefile Makefile *.mk', whatever exists
if [ [ " $prev " = = -*f ] ] ; then
2002-02-27 15:48:20 +00:00
_filedir
2002-02-27 01:18:08 +00:00
return 0
fi
# check for a long option
if [ [ " $cur " = = --* ] ] ; then
_longopt $1
return 0
2000-09-25 21:38:11 +00:00
fi
2001-12-18 03:43:25 +00:00
# if we want an option, return the possible posix options
2002-02-27 00:41:56 +00:00
if [ [ " $cur " = = -* ] ] ; then
2002-02-27 01:18:08 +00:00
COMPREPLY = ( $( compgen -W '-e -f -i -k -n -p -q -r -S -s -t' \
-- $cur ) )
return 0
2001-12-18 03:43:25 +00:00
fi
2003-01-21 07:21:15 +00:00
# make reads `GNUmakefile', then `makefile', then `Makefile'
if [ -f GNUmakefile ] ; then
mdef = GNUmakefile
elif [ -f makefile ] ; then
2001-12-18 03:43:25 +00:00
mdef = makefile
elif [ -f Makefile ] ; then
mdef = Makefile
else
mdef = *.mk # local convention
fi
# before we scan for targets, see if a makefile name was specified
# with -f
for ( ( i = 0; i < ${# COMP_WORDS [@] } ; i++ ) ) ; do
if [ [ ${ COMP_WORDS [i] } = = -*f ] ] ; then
2002-02-27 00:41:56 +00:00
eval makef = ${ COMP_WORDS [i+1] } # eval for tilde expansion
2001-12-18 03:43:25 +00:00
break
fi
done
[ -z " $makef " ] && makef = $mdef
# if we have a partial word to complete, restrict completions to
# matches of that word
[ -n " $2 " ] && gcmd = 'grep "^$2"' || gcmd = cat
2002-05-15 18:56:25 +00:00
COMPREPLY = ( $( grep -v '^\w\w*[[:space:]]*:=' $makef 2>/dev/null | \
awk 'BEGIN {FS=":"} /^[^.#' $'\t' '][^=]*:/ {print $1}' | \
2000-09-25 21:38:11 +00:00
eval $gcmd ) )
# default to filename completion if all else failed
2002-02-27 00:41:56 +00:00
[ ${# COMPREPLY [@] } -eq 0 ] && _filedir
2000-09-25 21:38:11 +00:00
return 0
}
2003-02-07 17:04:35 +00:00
[ -n " ${ have :- } " ] && complete -F _make -X '+($*|*.[ch])' $default $filenames make gmake pmake
2001-01-10 23:09:48 +00:00
2002-03-19 15:19:58 +00:00
# GNU tar(1) completion
2001-07-08 23:14:13 +00:00
#
_tar( )
{
2002-06-02 20:19:38 +00:00
local cur ext regex tar untar
2001-07-08 23:14:13 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2001-07-08 23:14:13 +00:00
2002-06-01 16:46:19 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
2002-03-07 17:47:12 +00:00
COMPREPLY = ( $( compgen -W 'c t x u r d A' -- $cur ) )
return 0
fi
2002-02-21 19:26:36 +00:00
2002-02-18 18:21:14 +00:00
case " ${ COMP_WORDS [1] } " in
2002-06-06 14:48:16 +00:00
?( -) c*f)
2002-02-18 18:21:14 +00:00
_filedir
2002-06-02 20:19:38 +00:00
return 0
2002-02-18 18:21:14 +00:00
; ;
2002-03-26 15:27:02 +00:00
+( [ ^Izjy] ) f)
2002-06-02 20:19:38 +00:00
ext = 'tar'
regex = $ext
2002-02-18 18:21:14 +00:00
; ;
*z*f)
2002-12-16 19:48:58 +00:00
ext = 't?(ar.)@(gz|Z)'
regex = 't\(ar\.\)\(gz\|Z\)'
2002-02-18 18:21:14 +00:00
; ;
2002-03-26 15:27:02 +00:00
*[ Ijy] *f)
2002-06-17 14:40:59 +00:00
ext = 't?(ar.)bz?(2)'
2002-10-14 17:57:15 +00:00
regex = 't\(ar\.\)bz2\?'
2002-02-18 18:21:14 +00:00
; ;
*)
_filedir
2002-06-02 20:19:38 +00:00
return 0
2002-02-18 18:21:14 +00:00
; ;
esac
2001-07-08 23:14:13 +00:00
2002-06-11 16:49:57 +00:00
if [ [ " $COMP_LINE " = = *$ext ' ' ] ] ; then
2002-06-02 20:19:38 +00:00
# complete on files in tar file
#
# get name of tar file from command line
tar = $( echo " $COMP_LINE " | \
2002-06-04 03:45:09 +00:00
sed -e 's|^.* \([^ ]*' $regex '\) .*$|\1|' )
2002-06-02 20:19:38 +00:00
# devise how to untar and list it
2002-06-04 03:27:03 +00:00
untar = t${ COMP_WORDS [1]//[^Izjyf]/ }
2002-06-02 20:19:38 +00:00
2002-06-10 13:36:50 +00:00
COMPREPLY = ( $( compgen -W " $( echo $( tar $untar $tar \
2>/dev/null ) ) " -- " $cur " ) )
2002-10-14 16:56:46 +00:00
return 0
2002-06-02 20:19:38 +00:00
fi
# file completion on relevant files
_filedir $ext
2001-07-08 23:14:13 +00:00
return 0
}
2002-12-18 18:15:46 +00:00
[ -n " ${ COMP_TAR_INTERNAL_PATHS :- } " ] && complete -F _tar $dirnames tar ||
2002-06-25 13:48:33 +00:00
complete -F _tar $filenames tar
2001-07-08 23:14:13 +00:00
2002-03-07 17:35:32 +00:00
# jar(1) completion
#
have jar &&
_jar( )
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
if [ $COMP_CWORD = 1 ] ; then
COMPREPLY = ( $( compgen -W 'c t x u' -- $cur ) )
return 0
fi
case " ${ COMP_WORDS [1] } " in
2002-10-05 07:34:57 +00:00
*c*f)
2002-03-07 17:35:32 +00:00
_filedir
; ;
*f)
2003-02-06 18:08:16 +00:00
_filedir '?(e|j|w)ar'
2002-03-07 17:35:32 +00:00
; ;
*)
_filedir
; ;
esac
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _jar $filenames jar
2002-03-07 17:35:32 +00:00
2001-07-08 23:14:13 +00:00
# Linux iptables(8) completion
#
have iptables &&
_iptables( )
{
2002-01-08 00:26:49 +00:00
local cur prev table chain
2001-07-08 23:14:13 +00:00
COMPREPLY = ( )
2002-01-08 00:26:49 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-01-06 18:11:12 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-01-08 00:26:49 +00:00
chain = 's/^Chain \([^ ]\+\).*$/\1/p'
if [ [ $COMP_LINE = = *-t\ *filter* ] ] ; then
table = "-t filter"
elif [ [ $COMP_LINE = = *-t\ *nat* ] ] ; then
table = "-t nat"
elif [ [ $COMP_LINE = = *-t\ *mangle* ] ] ; then
table = "-t mangle"
fi
case " $prev " in
-*[ AIDPFXL] )
2002-03-11 17:38:17 +00:00
COMPREPLY = ( $( compgen -W ' ` iptables $table -nL | \
sed -ne " s/^Chain \([^ ]\+\).* $/\1/p " ` ' -- $cur ) )
2002-01-08 00:26:49 +00:00
; ;
-*t)
2002-02-27 01:02:43 +00:00
COMPREPLY = ( $( compgen -W 'nat filter mangle' -- $cur ) )
2002-01-08 00:26:49 +00:00
; ;
-j)
if [ " $table " = "-t filter" -o " $table " = "" ] ; then
COMPREPLY = ( $( compgen -W ' ACCEPT DROP LOG ULOG REJECT \
` iptables $table -nL | sed -ne " $chain " \
2002-02-27 01:02:43 +00:00
-e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//" ` ' -- \
2002-01-08 00:26:49 +00:00
$cur ) )
elif [ " $table " = "-t nat" ] ; then
COMPREPLY = ( $( compgen -W ' ACCEPT DROP LOG ULOG REJECT \
MIRROR SNAT DNAT MASQUERADE ` iptables $table -nL | \
sed -ne " $chain " -e "s/OUTPUT|PREROUTING|POSTROUTING//" ` ' \
2002-02-27 01:02:43 +00:00
-- $cur ) )
2002-01-08 00:26:49 +00:00
elif [ " $table " = "-t mangle" ] ; then
COMPREPLY = ( $( compgen -W ' ACCEPT DROP LOG ULOG REJECT \
MARK TOS ` iptables $table -nL | sed -ne " $chain " \
2002-02-27 01:02:43 +00:00
-e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//" ` ' -- \
2002-01-08 00:26:49 +00:00
$cur ) )
fi
; ;
*)
; ;
esac
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _iptables iptables
2001-07-08 23:14:13 +00:00
2002-01-03 00:16:41 +00:00
# tcpdump(8) completion
2001-07-08 23:14:13 +00:00
#
have tcpdump &&
_tcpdump( )
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-02-13 15:54:03 +00:00
COMPREPLY = ( $( compgen -W ' host net port src dst ether gateway \
2002-02-27 01:02:43 +00:00
less greater' -- $cur ) )
2001-07-08 23:14:13 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _tcpdump tcpdump
2001-03-05 19:12:48 +00:00
2002-04-03 19:10:49 +00:00
# autorpm(8) completion
#
have autorpm &&
_autorpm( )
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
COMPREPLY = ( $( compgen -W ' --notty --debug --help --version \
auto add fullinfo info help install list \
remove set' -- $cur ) )
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _autorpm autorpm
2002-04-03 19:10:49 +00:00
2001-03-05 19:12:48 +00:00
# This meta-cd function observes the CDPATH variable, so that cd additionally
# completes on directories under those specified in CDPATH.
#
_cd( )
{
2002-05-16 07:05:04 +00:00
local IFS = $'\t\n' cur = ${ COMP_WORDS [COMP_CWORD] } i j k
2001-03-05 19:12:48 +00:00
2002-03-29 02:43:09 +00:00
# Use standard dir completion if no CDPATH or parameter starts with /,
# ./ or ../
2002-12-18 18:15:46 +00:00
if [ -z " ${ CDPATH :- } " ] || [ [ " $cur " = = ?( .) ?( .) /* ] ] ; then
2002-02-27 15:48:20 +00:00
_filedir -d
2002-01-05 19:48:59 +00:00
return 0
fi
2002-05-13 21:40:40 +00:00
IFS = $'\t\n'
2002-03-29 02:43:09 +00:00
# we have a CDPATH, so loop on its contents
for i in ${ CDPATH // : / $'\t' } ; do
# create an array of matched subdirs
2002-05-16 07:05:04 +00:00
k = ${# COMPREPLY [@] }
2002-06-24 14:34:50 +00:00
for j in $( compgen -d $i /$cur ) ; do
2002-05-16 07:05:04 +00:00
COMPREPLY[ $k ] = ${ j # $i / }
k = $(( + + k))
done
2002-03-29 02:43:09 +00:00
done
2002-05-13 21:40:40 +00:00
2002-02-27 15:48:20 +00:00
_filedir -d
2001-03-05 19:12:48 +00:00
return 0
}
2003-01-13 02:30:37 +00:00
if shopt -q cdable_vars; then
complete -A variable -F _cd $nospace $filenames cd
else
complete -F _cd $nospace $filenames cd
fi
2001-07-09 00:55:01 +00:00
2002-01-18 15:54:22 +00:00
# A meta-command completion function for commands like sudo(8), which need to
# first complete on a command, then complete according to that command's own
2002-01-23 23:13:21 +00:00
# completion definition - currently not quite foolproof (e.g. mount and umount
# don't work properly), but still quite useful
2002-01-18 15:54:22 +00:00
#
_command( )
{
2003-04-19 05:43:41 +00:00
local cur func cline cspec noglob
2002-01-18 15:54:22 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2003-04-19 05:43:41 +00:00
# save noglob state
shopt -o noglob >/dev/null; noglob = $?
# turn on noglob, as things like 'sudo ls *<Tab>' don't work otherwise
shopt -so noglob
2002-02-26 22:59:47 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
2002-02-27 01:02:43 +00:00
COMPREPLY = ( $( compgen -c -- $cur ) )
2002-01-23 17:14:19 +00:00
elif complete -p ${ COMP_WORDS [1] } & >/dev/null; then
2002-01-18 15:54:22 +00:00
cspec = $( complete -p ${ COMP_WORDS [1] } )
if [ " ${ cspec #*-F } " != " $cspec " ] ; then
# complete -F <function>
#
# COMP_CWORD and COMP_WORDS() are not read-only,
# so we can set them before handing off to regular
# completion routine
2002-04-11 22:24:08 +00:00
# set current token number to 1 less than now
COMP_CWORD = $(( $COMP_CWORD - 1 ))
2002-01-18 15:54:22 +00:00
# get function name
func = ${ cspec #*-F }
func = ${ func %% * }
# get current command line minus initial command
cline = " ${ COMP_LINE # $1 } "
# split current command line tokens into array
2002-04-13 17:21:42 +00:00
COMP_WORDS = ( $cline )
2002-01-23 17:14:19 +00:00
$func $cline
2002-03-30 18:20:51 +00:00
# remove any \: generated by a command that doesn't
# default to filenames or dirnames (e.g. sudo chown)
if [ " ${ cspec #*-o } " != " $cspec " ] ; then
cspec = ${ cspec #*-o }
cspec = ${ cspec %% * }
if [ [ " $cspec " != @( dir| file) names ] ] ; then
COMPREPLY = ( " ${ COMPREPLY [@]// \\ \\ : / : } " )
fi
fi
2002-01-18 15:54:22 +00:00
elif [ " ${ cspec #*-[abcdefgjkvu] } " != " $cspec " ] ; then
# complete -[abcdefgjkvu]
func = $( echo $cspec | \
sed -e 's/^.*\(-[abcdefgjkvu]\).*$/\1/' )
2002-02-27 01:02:43 +00:00
COMPREPLY = ( $( compgen $func -- $cur ) )
2002-01-18 15:54:22 +00:00
elif [ " ${ cspec #*-A } " != " $cspec " ] ; then
# complete -A <type>
func = ${ cspec #*-A }
func = ${ func %% * }
2002-02-27 01:02:43 +00:00
COMPREPLY = ( $( compgen -A $func -- $cur ) )
2002-01-18 15:54:22 +00:00
fi
fi
2002-02-27 15:28:26 +00:00
[ ${# COMPREPLY [@] } -eq 0 ] && _filedir
2003-04-19 05:43:41 +00:00
# reset noglob if necessary
[ $noglob -eq 1 ] && shopt -uo noglob
2002-01-18 15:54:22 +00:00
}
2002-12-10 00:30:08 +00:00
complete -F _command $filenames nohup exec nice eval strace time ltrace then \
else do
2002-01-18 15:54:22 +00:00
2002-02-26 22:21:39 +00:00
_root_command( )
{
2002-02-27 10:01:21 +00:00
PATH = $PATH :/sbin:/usr/sbin:/usr/local/sbin _command $1
2002-02-26 22:21:39 +00:00
}
2002-04-03 17:19:30 +00:00
complete -F _root_command $filenames sudo fakeroot
2002-02-26 22:21:39 +00:00
2002-03-07 17:32:03 +00:00
# ant(1) completion
2001-12-11 20:25:53 +00:00
#
have ant &&
2002-03-07 17:32:03 +00:00
_ant( )
2001-12-11 20:25:53 +00:00
{
2002-03-07 17:32:03 +00:00
local cur prev buildfile i
2001-12-11 20:25:53 +00:00
COMPREPLY = ( )
2002-03-07 17:32:03 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2001-12-11 20:25:53 +00:00
2002-03-07 17:32:03 +00:00
case " $prev " in
-buildfile)
2002-05-18 21:00:14 +00:00
_filedir 'xml'
2002-03-07 17:32:03 +00:00
return 0
; ;
-logfile)
_filedir
return 0
; ;
esac
2001-12-11 20:25:53 +00:00
2002-03-07 17:32:03 +00:00
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
2002-03-29 15:33:08 +00:00
COMPREPLY = ( $( compgen -W ' -help -projecthelp -version -quiet \
-verbose -debug -emacs -logfile -logger \
-listener -buildfile -D -find' -- $cur ) )
2002-03-07 17:32:03 +00:00
else
# available targets completion
2002-06-19 06:18:28 +00:00
# find which buildfile to use
2002-03-07 17:32:03 +00:00
buildfile = build.xml
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = -buildfile ] ] ; then
buildfile = ${ COMP_WORDS [i+1] }
break
fi
done
[ ! -f $buildfile ] && return 0
2001-12-11 20:25:53 +00:00
2002-03-07 17:32:03 +00:00
# parse buildfile for targets
2002-03-29 15:33:08 +00:00
COMPREPLY = ( $( awk -F'"' '/<target name="/ {print $2}' \
2003-01-25 21:11:18 +00:00
$buildfile | grep " ^ $cur " )
$( awk -F"'" "/<target name='/ " '{print $2}' \
2002-04-03 21:17:10 +00:00
$buildfile | grep " ^ $cur " ) )
2002-03-07 17:32:03 +00:00
fi
2001-12-11 20:25:53 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _ant $filenames ant
2001-12-11 20:25:53 +00:00
2001-12-18 03:25:04 +00:00
have nslookup &&
_nslookup( )
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD]#- }
COMPREPLY = ( $( compgen -P '-' -W ' all class = debug d2 domain = \
srchlist = defname search port = querytype = \
type = recurse retry root timeout vc \
2002-02-27 01:02:43 +00:00
ignoretc' -- $cur ) )
2001-12-18 03:25:04 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _nslookup nslookup
2001-12-18 03:25:04 +00:00
2002-01-14 20:38:22 +00:00
# mysqladmin(1) completion
#
have mysqladmin &&
_mysqladmin( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-u)
2002-02-27 01:02:43 +00:00
COMPREPLY = ( $( compgen -u -- $cur ) )
2002-01-14 20:38:22 +00:00
return 0
; ;
*)
; ;
esac
2002-02-27 01:02:43 +00:00
COMPREPLY = ( $( compgen -W ' -# -f -? -C -h -p -P -i -r -E -s -S -t -u \
-v -V -w' -- $cur ) )
2002-01-14 20:38:22 +00:00
COMPREPLY = ( ${ COMPREPLY [@] } \
$( compgen -W ' create drop extended-status flush-hosts \
flush-logs flush-status flush-tables \
flush-threads flush-privileges kill \
password ping processlist reload refresh \
2002-02-27 01:02:43 +00:00
shutdown status variables version' \
-- $cur ) )
2002-01-14 20:38:22 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _mysqladmin mysqladmin
2002-01-14 20:38:22 +00:00
2002-01-23 23:13:21 +00:00
# gzip(1) and bzip2(1) completion
#
have gzip &&
_zip( )
{
local IFS cur prev xspec
IFS = $'\t\n'
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-12-04 04:43:34 +00:00
[ $1 = "gzip" ] && xspec = "*.?(t)gz"
2002-06-19 14:53:48 +00:00
[ $1 = "bzip2" ] && xspec = "*.bz2"
[ [ " $prev " = = -*[ dt] * ] ] && xspec = "!" $xspec
2002-01-23 23:13:21 +00:00
_expand || return 0
2002-02-27 01:02:43 +00:00
COMPREPLY = ( $( compgen -f -X " $xspec " -- $cur ) \
$( compgen -d -- $cur ) )
2002-01-23 23:13:21 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _zip $filenames gzip bzip2
2002-01-23 23:13:21 +00:00
2002-02-04 02:12:10 +00:00
# openssl(1) completion
#
have openssl &&
_openssl( )
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-02-26 22:59:47 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
2002-02-04 02:12:10 +00:00
COMPREPLY = ( $( compgen -W ' asn1parse ca ciphers crl crl2pkcs7 \
dgst dh dhparam dsa dsaparam enc errstr gendh gendsa \
genrsa nseq passwd pkcs12 pkcs7 pkcs8 rand req rsa \
rsautl s_client s_server s_time sess_id smime speed \
spkac verify version x509 md2 md4 md5 mdc2 rmd160 sha \
sha1 base64 bf bf-cbc bf-cfb bf-ecb bf-ofb cast \
cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb des \
des-cbc des-cfb des-ecb des-ede des-ede-cbc \
des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc \
des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 \
rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb \
2002-02-27 01:02:43 +00:00
rc4 rc4-40' -- $cur ) )
2002-03-07 18:04:05 +00:00
fi
2002-02-04 02:12:10 +00:00
2002-03-07 18:04:05 +00:00
return 0
2002-02-04 02:12:10 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _openssl $default openssl
2002-02-04 02:12:10 +00:00
# screen(1) completion
#
have screen &&
_screen( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-12-05 01:56:19 +00:00
test " $COMP_CWORD " -ge 2 && preprev = ${ COMP_WORDS [COMP_CWORD-2] } || unset preprev
2002-02-04 02:12:10 +00:00
2002-12-05 01:56:19 +00:00
if test " $preprev " = "-d" -o " $preprev " = "-D" -a " $prev " = "-r" -o " $prev " = "-R" ; then
# list all
2002-06-04 03:45:09 +00:00
COMPREPLY = ( $( command screen -ls | \
2002-12-05 01:56:19 +00:00
sed -ne 's|^[' $'\t' ']\+[0-9]\+\.\(' $cur '[^' $'\t' ']\+\).*$|\1|p' ) )
else
case " $prev " in
-[ rR] )
# list detached
COMPREPLY = ( $( command screen -ls | \
sed -ne 's|^[' $'\t' ']\+[0-9]\+\.\(' $cur '[^' $'\t' ']\+\).*Detached.*$|\1|p' ) )
; ;
-[ dDx] )
# list attached
COMPREPLY = ( $( command screen -ls | \
sed -ne 's|^[' $'\t' ']\+[0-9]\+\.\(' $cur '[^' $'\t' ']\+\).*Attached.*$|\1|p' ) )
; ;
-s)
# shells
COMPREPLY = ( $( grep ^${ cur :- [^#] } /etc/shells ) )
; ;
*)
; ;
esac
fi
2002-02-04 02:12:10 +00:00
2002-03-07 18:04:05 +00:00
return 0
2002-02-04 02:12:10 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _screen $default screen
2002-02-04 02:12:10 +00:00
2002-04-03 19:10:49 +00:00
# lftp(1) bookmark completion
#
have lftp &&
_lftp( )
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
if [ $COMP_CWORD -eq 1 ] && [ -f ~/.lftp/bookmarks ] ; then
COMPREPLY = ( $( compgen -W '$( sed -ne "s/^\(.*\)' $'\t' ' .*$/\1 /p" \
~/.lftp/bookmarks ) ' -- $cur ) )
fi
return 0
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _lftp $default lftp
2002-04-03 19:10:49 +00:00
2002-02-10 20:45:46 +00:00
# ncftp(1) bookmark completion
#
have ncftp &&
_ncftp( )
{
local cur
2002-02-11 22:28:47 +00:00
COMPREPLY = ( )
2002-02-10 20:45:46 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-02-26 22:59:47 +00:00
if [ $COMP_CWORD -eq 1 ] && [ -f ~/.ncftp/bookmarks ] ; then
2002-03-26 15:36:00 +00:00
COMPREPLY = ( $( compgen -W ' $( sed -ne " s/^\([^,]\{1,\}\),.* $/\1/p " \
~/.ncftp/bookmarks ) ' -- $cur ) )
2002-03-07 18:04:05 +00:00
fi
2002-02-10 20:45:46 +00:00
2002-03-07 18:04:05 +00:00
return 0
2002-02-10 20:45:46 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _ncftp $default ncftp
2002-02-10 20:45:46 +00:00
2002-02-11 22:28:47 +00:00
# gdb(1) completion
#
have gdb &&
_gdb( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ $COMP_CWORD -eq 1 ] ; then
2002-02-27 01:02:43 +00:00
COMPREPLY = ( $( compgen -c -- $cur ) )
2002-02-11 22:28:47 +00:00
elif [ $COMP_CWORD -eq 2 ] ; then
2002-06-24 06:22:11 +00:00
prev = ${ prev ##*/ }
2003-03-17 23:34:02 +00:00
COMPREPLY = ( $( compgen -W " $( compgen -f core \
2002-10-20 04:56:41 +00:00
$( command ps axo comm,pid |
2002-06-24 06:22:11 +00:00
awk '{if ($1 ~ /^' $prev '/) print $2}' ) ) " \
-- " $cur " ) )
2002-02-11 22:28:47 +00:00
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _gdb $filenames gdb
2002-02-11 22:28:47 +00:00
2002-04-29 18:36:04 +00:00
# Postgresql completion
#
have psql && {
_pg_databases( )
{
COMPREPLY = ( $( psql -l 2>/dev/null | \
sed -ne 's|^ \(' $cur '[^ ]*\).*$|\1|p' ) )
}
_pg_users( )
{
COMPREPLY = ( $( psql -qtc 'select usename from pg_user' 2>/dev/null | \
grep " ^ $cur " ) )
[ ${# COMPREPLY [@] } -eq 0 ] && COMPREPLY = ( $( compgen -u -- $cur ) )
}
2002-02-13 18:20:59 +00:00
# psql(1) completion
#
2002-02-18 08:32:56 +00:00
_psql( )
2002-02-13 18:20:59 +00:00
{
2002-02-18 08:27:09 +00:00
local cur prev
2002-02-13 18:20:59 +00:00
2002-02-18 10:09:59 +00:00
COMPREPLY = ( )
2002-02-13 18:20:59 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
2002-04-30 20:16:35 +00:00
-h| --host)
2002-02-13 18:20:59 +00:00
_known_hosts
return 0
; ;
2002-04-30 20:16:35 +00:00
-U| --username)
2002-04-29 18:36:04 +00:00
_pg_users
2002-02-13 18:20:59 +00:00
return 0
; ;
2002-04-30 20:16:35 +00:00
-d| --dbname)
2002-04-29 18:36:04 +00:00
_pg_databases
return 0
; ;
2002-04-30 20:16:35 +00:00
-@( o| f) | --output| --file)
2002-04-29 18:36:04 +00:00
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
# return list of available options
2002-04-30 20:16:35 +00:00
COMPREPLY = ( $( compgen -W ' -a --echo-all -A --no-align \
-c --command -d --dbname -e --echo-queries \
-E --echo-hidden -f --file -F --filed-separator \
-h --host -H --html -l --list -n -o --output \
-p --port -P --pset -q -R --record-separator \
-s --single-step -S --single-line -t --tuples-only \
-T --table-attr -U --username -v --variable \
-V --version -W --password -x --expanded -X --nopsqlrc \
-? --help ' -- $cur ) )
2002-04-29 18:36:04 +00:00
else
# return list of available databases
_pg_databases
fi
}
complete -F _psql $default psql
# createdb(1) completion
#
_createdb( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( h| -host= ) )
_known_hosts
return 0
; ;
-@( U| -username= ) )
_pg_users
2002-02-13 18:20:59 +00:00
return 0
; ;
esac
2002-04-29 18:36:04 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -D -T -E -h -p -U -W -e -q \
--location= --template= --encoding= --host= --port= \
2002-04-29 18:58:39 +00:00
--username= --password --echo --quiet --help' -- $cur ) )
2002-04-29 18:36:04 +00:00
else
_pg_databases
fi
}
complete -F _createdb $default createdb
# dropdb(1) completion
#
_dropdb( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( h| -host= ) )
_known_hosts
return 0
; ;
-@( U| -username= ) )
_pg_users
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -h -p -U -W -e -q \
--host= --port= --username= --password \
--interactive --echo --quiet --help' -- $cur ) )
else
_pg_databases
fi
}
complete -F _dropdb $default dropdb
2002-02-13 18:20:59 +00:00
}
2002-02-16 00:13:00 +00:00
_longopt( )
{
2002-03-01 22:41:42 +00:00
local cur opt
mkdir and rmdir now bound to _longopt(), default to dirnames
a2ps, autoconf, automake, bc, gprof, ld, nm, objcopy, objdump, readelf, strip,
bison, cpio, diff, patch, enscript, cp, df, dir, du, ln, ls, mkfifo, mknod,
mv, rm, touch, vdir, xargs, awk, gperf, grep, gpg, grub, indent, less, m4,
sed, shar, date, env, seq, su, tee, uname, who, texindex, cat, csplit, cut,
expand, fmt, fold, head, md5sum, nl, od, paste, pr, ptx, sha1sum, sort,
split, tac, tail, tr, unexpand, uniq, wc, units and rsync now all have
GNU long option completion from _longopt()
gpc completion added into _gcc()
cat, less, more, ln and strip no longer bound to _filedir()
2002-02-18 08:26:34 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-02-18 08:32:56 +00:00
2002-03-01 22:41:42 +00:00
if [ [ " $cur " = = --*= * ] ] ; then
opt = ${ cur %%=* }
# cut backlash that gets inserted before '=' sign
opt = ${ opt % \\ * }
cur = ${ cur #*= }
_filedir
COMPREPLY = ( $( compgen -P " $opt = " -W '${COMPREPLY[@]}' -- $cur ) )
return 0
fi
2002-02-18 10:09:59 +00:00
if [ [ " $cur " = = -* ] ] ; then
2002-09-09 13:46:17 +00:00
COMPREPLY = ( $( $1 --help 2>& 1 | sed -e '/--/!d' \
2002-02-20 05:26:08 +00:00
-e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | \
2002-04-03 21:17:10 +00:00
grep " ^ $cur " | sort -u ) )
2002-02-28 05:39:10 +00:00
elif [ [ " $1 " = = @( mk| rm) dir ] ] ; then
2002-02-22 15:48:21 +00:00
_filedir -d
2002-02-18 10:09:59 +00:00
else
_filedir
fi
2002-02-16 00:13:00 +00:00
}
mkdir and rmdir now bound to _longopt(), default to dirnames
a2ps, autoconf, automake, bc, gprof, ld, nm, objcopy, objdump, readelf, strip,
bison, cpio, diff, patch, enscript, cp, df, dir, du, ln, ls, mkfifo, mknod,
mv, rm, touch, vdir, xargs, awk, gperf, grep, gpg, grub, indent, less, m4,
sed, shar, date, env, seq, su, tee, uname, who, texindex, cat, csplit, cut,
expand, fmt, fold, head, md5sum, nl, od, paste, pr, ptx, sha1sum, sort,
split, tac, tail, tr, unexpand, uniq, wc, units and rsync now all have
GNU long option completion from _longopt()
gpc completion added into _gcc()
cat, less, more, ln and strip no longer bound to _filedir()
2002-02-18 08:26:34 +00:00
# makeinfo and texi2dvi are defined elsewhere
2002-02-18 17:26:54 +00:00
for i in a2ps autoconf automake bc gprof ld nm objcopy objdump readelf strip \
bison cpio diff patch enscript cp df dir du ln ls mkfifo mknod mv rm \
2002-12-31 01:59:25 +00:00
touch vdir xargs awk gperf grep grub indent less m4 sed shar date \
2003-02-10 06:55:22 +00:00
env seq tee uname who texindex cat csplit cut expand fmt fold head \
2002-02-18 17:26:54 +00:00
md5sum nl od paste pr ptx sha1sum sort split tac tail tr unexpand \
2003-01-30 07:56:28 +00:00
uniq wc units wget ldd bash id info irb mkdir rmdir netstat; do
2002-04-03 17:19:30 +00:00
have $i && complete -F _longopt $filenames $i
mkdir and rmdir now bound to _longopt(), default to dirnames
a2ps, autoconf, automake, bc, gprof, ld, nm, objcopy, objdump, readelf, strip,
bison, cpio, diff, patch, enscript, cp, df, dir, du, ln, ls, mkfifo, mknod,
mv, rm, touch, vdir, xargs, awk, gperf, grep, gpg, grub, indent, less, m4,
sed, shar, date, env, seq, su, tee, uname, who, texindex, cat, csplit, cut,
expand, fmt, fold, head, md5sum, nl, od, paste, pr, ptx, sha1sum, sort,
split, tac, tail, tr, unexpand, uniq, wc, units and rsync now all have
GNU long option completion from _longopt()
gpc completion added into _gcc()
cat, less, more, ln and strip no longer bound to _filedir()
2002-02-18 08:26:34 +00:00
done
unset i
2002-03-07 18:04:05 +00:00
# gcc(1) completion
2002-02-15 22:53:58 +00:00
#
# The only unusual feature is that we don't parse "gcc --help -v" output
# directly, because that would include the options of all the other backend
# tools (linker, assembler, preprocessor, etc) without any indication that
# you cannot feed such options to the gcc driver directly. (For example, the
# linker takes a -z option, but you must type -Wl,-z for gcc.) Instead, we
# ask the driver ("g++") for the name of the compiler ("cc1"), and parse the
# --help output of the compiler.
#
have gcc &&
_gcc( )
{
2002-02-18 10:09:59 +00:00
local cur cc backend
2002-02-15 22:53:58 +00:00
2002-02-18 08:39:02 +00:00
COMPREPLY = ( )
mkdir and rmdir now bound to _longopt(), default to dirnames
a2ps, autoconf, automake, bc, gprof, ld, nm, objcopy, objdump, readelf, strip,
bison, cpio, diff, patch, enscript, cp, df, dir, du, ln, ls, mkfifo, mknod,
mv, rm, touch, vdir, xargs, awk, gperf, grep, gpg, grub, indent, less, m4,
sed, shar, date, env, seq, su, tee, uname, who, texindex, cat, csplit, cut,
expand, fmt, fold, head, md5sum, nl, od, paste, pr, ptx, sha1sum, sort,
split, tac, tail, tr, unexpand, uniq, wc, units and rsync now all have
GNU long option completion from _longopt()
gpc completion added into _gcc()
cat, less, more, ln and strip no longer bound to _filedir()
2002-02-18 08:26:34 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-02-15 22:53:58 +00:00
2002-02-27 01:18:08 +00:00
_expand || return 0
2002-02-18 10:09:59 +00:00
case " $1 " in
2002-02-15 22:53:58 +00:00
gcj)
backend = jc1
; ;
mkdir and rmdir now bound to _longopt(), default to dirnames
a2ps, autoconf, automake, bc, gprof, ld, nm, objcopy, objdump, readelf, strip,
bison, cpio, diff, patch, enscript, cp, df, dir, du, ln, ls, mkfifo, mknod,
mv, rm, touch, vdir, xargs, awk, gperf, grep, gpg, grub, indent, less, m4,
sed, shar, date, env, seq, su, tee, uname, who, texindex, cat, csplit, cut,
expand, fmt, fold, head, md5sum, nl, od, paste, pr, ptx, sha1sum, sort,
split, tac, tail, tr, unexpand, uniq, wc, units and rsync now all have
GNU long option completion from _longopt()
gpc completion added into _gcc()
cat, less, more, ln and strip no longer bound to _filedir()
2002-02-18 08:26:34 +00:00
gpc)
backend = gpc1
; ;
2002-02-15 22:53:58 +00:00
*77)
backend = f771
; ;
*)
2002-02-27 01:18:08 +00:00
backend = cc1 # (near-)universal backend
2002-02-15 22:53:58 +00:00
; ;
2002-02-18 10:09:59 +00:00
esac
2002-02-15 22:53:58 +00:00
2002-02-18 10:09:59 +00:00
if [ [ " $cur " = = -* ] ] ; then
cc = $( $1 -print-prog-name= $backend )
# sink stderr:
# for C/C++/ObjectiveC it's useless
# for FORTRAN/Java it's an error
COMPREPLY = ( $( $cc --help 2>/dev/null | tr '\t' ' ' | \
sed -e '/^ *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | \
2002-04-03 21:17:10 +00:00
grep " ^ $cur " | sort -u ) )
2002-02-18 10:09:59 +00:00
else
_filedir
fi
2002-02-15 22:53:58 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete $filenames -F _gcc gcc g++ c++ g77 gcj gpc
2002-05-09 16:20:53 +00:00
[ $UNAME = GNU -o $UNAME = Linux ] && complete $filenames -F _gcc cc
2002-02-15 22:53:58 +00:00
2002-02-26 20:48:32 +00:00
# Linux cardctl(8) completion
#
have cardctl &&
2002-02-27 06:47:09 +00:00
_cardctl( )
2002-02-26 20:48:32 +00:00
{
local cur
2002-05-16 07:05:04 +00:00
COMPREPLY = ( )
2002-02-26 20:48:32 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
if [ $COMP_CWORD -eq 1 ] ; then
COMPREPLY = ( $( compgen -W ' status config ident suspend \
resume reset eject insert scheme' \
2002-02-27 01:02:43 +00:00
-- $cur ) )
2002-02-26 20:48:32 +00:00
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _cardctl cardctl
2002-02-26 20:48:32 +00:00
2002-03-24 18:44:55 +00:00
# This function is required by _dpkg() and _dpkg-reconfigure()
2002-04-02 05:27:50 +00:00
#
2002-05-05 15:42:42 +00:00
have dpkg && {
2002-03-24 18:44:55 +00:00
_comp-dpkg-installed-packages( )
{
2002-05-30 18:17:29 +00:00
grep -B 2 'ok installed' /var/lib/dpkg/status | grep " Package: $1 " | \
2002-05-20 22:36:07 +00:00
cut -d\ -f2
2002-05-05 15:42:42 +00:00
2002-03-24 18:44:55 +00:00
}
2002-05-09 16:20:53 +00:00
# Debian dpkg(8) completion
2002-02-27 06:47:09 +00:00
#
_dpkg( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-05-11 07:28:58 +00:00
_expand || return 0
2002-03-27 18:33:34 +00:00
# find the last option flag
if [ [ $cur != -* ] ] ; then
while [ [ $prev != -* && $COMP_CWORD != 1 ] ] ; do
COMP_CWORD = $(( COMP_CWORD-1))
prev = ${ COMP_WORDS [COMP_CWORD-1] }
done
fi
2002-02-27 06:47:09 +00:00
case " $prev " in
2002-12-04 06:17:47 +00:00
-@( c| i| A| I| f| e| X| -@( install| unpack| record-avail| contents| info| \
2002-10-02 01:32:40 +00:00
fsys-tarfile| field| control| extract) ) )
2002-12-04 06:25:47 +00:00
_filedir '?(u)deb'
2002-02-27 06:47:09 +00:00
return 0
; ;
2002-10-02 01:32:40 +00:00
-@( b| -build) )
2002-05-18 21:00:14 +00:00
_filedir -d
2002-03-11 01:10:17 +00:00
return 0
; ;
2002-10-02 01:32:40 +00:00
-@( s| p| l| -@( status| print-avail| list) ) )
2002-10-05 06:08:53 +00:00
COMPREPLY = ( $( apt-cache pkgnames $cur 2>/dev/null ) )
2002-03-16 19:49:44 +00:00
return 0
; ;
2002-10-02 01:32:40 +00:00
-@( S| -search) )
2002-03-16 19:49:44 +00:00
_filedir
2002-02-27 06:47:09 +00:00
return 0
; ;
2002-10-02 01:32:40 +00:00
-@( r| L| -@( remove| purge| listfiles) ) )
2002-03-24 18:44:55 +00:00
COMPREPLY = ( $( _comp-dpkg-installed-packages $cur ) )
return 0
; ;
2002-02-27 06:47:09 +00:00
*)
COMPREPLY = ( $( compgen -W ' -i --install --unpack -A --record-avail \
--configure -r --remove --purge --get-selections \
--set-selections --update-avail --merge-avail \
--clear-avail --command-fd --forget-old-unavail -s \
--status -p --print-avail -L --listfiles -l --list \
-S --search -C --audit --print-architecture \
--print-gnu-build-architecture \
--print-installation-architecture \
2002-03-27 18:33:34 +00:00
--compare-versions --help --version --force-help \
--force-all --force-auto-select --force-downgrade \
--force-configure-any --force-hold --force-bad-path \
--force-not-root --force-overwrite \
--force-overwrite-diverted --force-bad-verify \
2002-09-28 16:12:24 +00:00
--force-depends-version --force-depends \
2002-03-27 18:33:34 +00:00
--force-confnew --force-confold --force-confdef \
2002-10-09 05:29:14 +00:00
--force-confmiss --force-conflicts --force-architecture\
2002-03-27 18:33:34 +00:00
--force-overwrite-dir --force-remove-reinstreq \
--force-remove-essential -Dh \
2002-02-27 06:47:09 +00:00
--debug= help --licence --admindir= --root= --instdir= \
-O --selected-only -E --skip-same-version \
-G --refuse-downgrade -B --auto-deconfigure \
--no-debsig --no-act -D --debug= --status-fd \
2002-03-11 01:10:17 +00:00
-b --build -I --info -f --field -c --contents \
-x --extract -X --vextract --fsys-tarfile -e --control \
2002-02-27 06:47:09 +00:00
--ignore-depends= --abort-after' -- $cur ) )
2002-10-02 01:32:40 +00:00
; ;
esac
2002-02-27 06:47:09 +00:00
}
2002-06-01 18:58:06 +00:00
complete -F _dpkg $filenames dpkg dpkg-deb
2002-05-05 15:42:42 +00:00
}
2002-02-27 06:47:09 +00:00
2002-05-09 16:20:53 +00:00
# Debian GNU dpkg-reconfigure(8) completion
2002-03-24 18:44:55 +00:00
#
have dpkg-reconfigure &&
2002-10-13 01:46:49 +00:00
_dpkg_reconfigure( )
2002-03-24 18:44:55 +00:00
{
2002-04-02 05:27:50 +00:00
local cur prev opt
2002-03-24 18:44:55 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-04-02 05:27:50 +00:00
case " $prev " in
-@( f| -frontend) )
opt = ( $( echo /usr/share/perl5/Debconf/FrontEnd/* ) )
opt = ( ${ opt [@]##*/ } )
opt = ( ${ opt [@]%.pm } )
2002-09-28 16:12:24 +00:00
COMPREPLY = ( $( compgen -W '${opt[@]}' -- $cur ) )
return 0
2002-04-02 05:27:50 +00:00
; ;
-@( p| -priority) )
2002-09-28 16:12:24 +00:00
COMPREPLY = ( $( compgen -W 'low medium high critical' -- $cur ) )
return 0
2002-04-02 05:27:50 +00:00
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -f --frontend -p --priority -a --all \
-u --unseen-only -h --help -s --showold \
--force --terse' -- $cur ) )
else
COMPREPLY = ( $( _comp-dpkg-installed-packages $cur ) )
fi
2002-03-24 18:44:55 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _dpkg_reconfigure $default dpkg-reconfigure
2002-03-24 18:44:55 +00:00
2002-04-22 06:39:07 +00:00
# Debian Linux dselect(8) completion.
#
have dselect &&
_dselect( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-10-02 01:32:40 +00:00
case " $prev " in
--admindir)
_filedir -d
; ;
-@( D| debug) )
_filedir
; ;
esac
2002-10-13 01:46:49 +00:00
COMPREPLY = ( $( compgen -W -- $cur ) )
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --admindir --help --version --licence \
--license --expert --debug' -- $cur ) )
else
COMPREPLY = ( $( compgen -W ' access update select install config \
remove quit' -- $cur ) )
fi
2002-04-22 06:39:07 +00:00
return 0
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _dselect $filenames dselect
2002-04-22 06:39:07 +00:00
2002-06-01 18:58:06 +00:00
# Java completion
#
# available path elements completion
have java && {
_java_path( )
{
cur = ${ cur ##* : }
_filedir '@(jar|zip)'
}
# exact classpath determination
_java_find_classpath( )
{
local i
# search first in current options
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = -@( cp| classpath) ] ] ; then
classpath = ${ COMP_WORDS [i+1] }
break
fi
done
# default to environment
[ -z " $classpath " ] && classpath = $CLASSPATH
# default to current directory
[ -z " $classpath " ] && classpath = .
}
# exact sourcepath determination
_java_find_sourcepath( )
{
local i
# search first in current options
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = -sourcepath ] ] ; then
sourcepath = ${ COMP_WORDS [i+1] }
break
fi
done
# default to classpath
[ -z " $sourcepath " ] && _java_find_classpath
sourcepath = $classpath
}
# available classes completion
_java_classes( )
{
local classpath i
# find wich classpath to use
_java_find_classpath
# convert package syntax to path syntax
cur = ${ cur //.// }
# parse each classpath element for classes
for i in ${ classpath // : / } ; do
if [ -r $i ] && [ [ " $i " = = *.@( jar| zip) ] ] ; then
2003-01-09 10:44:29 +00:00
if type zipinfo & > /dev/null; then
COMPREPLY = ( ${ COMPREPLY [@] } $( zipinfo -1 $i |
grep " ^ $cur " | grep -v "META-INF" |
sed -e 's|\(' $cur '[^/]*/\).*|\1|' | sort |
uniq ) )
else
COMPREPLY = ( ${ COMPREPLY [@] } $( jar tf $i $cur |
grep -v "META-INF" | sed -e \
's|\(' $cur '[^/]*/\).*|\1|' | sort | uniq ) )
fi
2002-06-01 18:58:06 +00:00
elif [ -d $i ] ; then
2002-06-04 03:45:09 +00:00
COMPREPLY = ( ${ COMPREPLY [@] } $( command ls -F -d \
$i /$cur * 2>/dev/null | sed -e 's|^' $i '/||' ) )
2002-06-01 18:58:06 +00:00
fi
done
# keep only packages and classes
COMPREPLY = (
$( echo ${ COMPREPLY [@] } | tr " " "\n" | grep " / $" )
$( echo ${ COMPREPLY [@] } | tr " " "\n" | grep " \.class $" | \
grep -v " \\ $" )
)
# remove class extension
COMPREPLY = ( ${ COMPREPLY [@]%.class } )
# convert path syntax to package syntax
COMPREPLY = ( ${ COMPREPLY [@]// \/ /. } )
}
# available packages completion
_java_packages( )
{
local sourcepath i
# find wich sourcepath to use
_java_find_sourcepath
# convert package syntax to path syntax
cur = ${ cur //.// }
# parse each sourcepath element for packages
for i in ${ sourcepath // : / } ; do
if [ -d $i ] ; then
2002-06-04 03:45:09 +00:00
COMPREPLY = ( ${ COMPREPLY [@] } $( command ls -F -d \
$i /$cur * 2>/dev/null | sed -e 's|^' $i '/||' ) )
2002-06-01 18:58:06 +00:00
fi
done
# keep only packages
COMPREPLY = ( $( echo ${ COMPREPLY [@] } | tr " " "\n" | grep " / $" ) )
# remove packages extension
COMPREPLY = ( ${ COMPREPLY [@]%/ } )
# convert path syntax to package syntax
cur = ${ COMPREPLY [@]// \/ /. }
}
2002-10-05 07:31:43 +00:00
# java completion
#
2002-03-07 17:44:48 +00:00
_java( )
{
2002-10-05 07:31:43 +00:00
local cur prev i
2002-03-07 17:44:48 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-10-05 07:31:43 +00:00
for ( ( i = 1; i < $COMP_CWORD ; i++) ) ; do
case ${ COMP_WORDS [ $i ] } in
-cp| -classpath)
2002-12-22 17:29:34 +00:00
continue # skip the classpath string.
2002-10-05 07:31:43 +00:00
; ;
-*)
# this is an option, not a class/jarfile name.
; ;
*)
# once we've seen a class, just do filename completion
_filedir
return 0
; ;
esac
done
2002-06-01 18:58:06 +00:00
case $prev in
2002-03-07 17:44:48 +00:00
-@( cp| classpath) )
2002-06-01 18:58:06 +00:00
_java_path
2002-05-28 18:34:11 +00:00
return 0
; ;
2002-03-07 17:44:48 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
2002-03-29 15:33:08 +00:00
COMPREPLY = ( $( compgen -W ' -client -hotspot -server -classic \
2002-10-05 07:31:43 +00:00
-cp -classpath -D -verbose -verbose:class \
2002-10-13 01:46:49 +00:00
-verbose:gc -version:jni -version \
2002-10-05 07:31:43 +00:00
-showversion -? -help -X -jar \
2002-10-13 01:46:49 +00:00
-ea -enableassertions -da -disableassertions \
-esa -enablesystemassertions \
-dsa -disablesystemassertions ' -- $cur ) )
2002-03-07 17:44:48 +00:00
else
2002-06-01 18:58:06 +00:00
if [ [ " $prev " = = -jar ] ] ; then
# jar file completion
_filedir jar
2002-03-07 17:44:48 +00:00
else
2002-06-01 18:58:06 +00:00
# classes completion
_java_classes
2002-03-07 17:44:48 +00:00
fi
fi
}
2002-06-01 18:58:06 +00:00
complete -F _java $filenames java
}
# javadoc completion
#
have javadoc &&
_javadoc( )
{
COMPREPLY = ( )
local cur prev
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
-@( overview| helpfile| stylesheetfile) )
_filedir
return 0
; ;
-d)
_filedir -d
return 0
; ;
-@( classpath| bootclasspath| docletpath| sourcepath| extdirs) )
_java_path
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
COMPREPLY = ( $( compgen -W ' -overview -public -protected \
-package -private -help -doclet -docletpath \
-sourcepath -classpath -exclude -subpackages \
-breakiterator -bootclasspath -source -extdirs \
-verbose -locale -encoding -J -d -use -version \
-author -docfilessubdirs -splitindex \
-windowtitle -doctitle -header -footer -bottom \
-link -linkoffline -excludedocfilessubdir \
-group -nocomment -nodeprecated -noqualifier \
-nosince -nodeprecatedlist -notree -noindex \
-nohelp -nonavbar -quiet -serialwarn -tag \
-taglet -tagletpath -charset -helpfile \
-linksource -stylesheetfile -docencoding' -- \
$cur ) )
else
# source files completion
_filedir java
# packages completion
_java_packages
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _javadoc $filenames javadoc
2002-06-01 18:58:06 +00:00
# javac completion
#
have javac &&
_javac( )
{
COMPREPLY = ( )
local cur prev
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
-d)
_filedir -d
return 0
; ;
-@( classpath| bootclasspath| sourcepath| extdirs) )
_java_path
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
COMPREPLY = ( $( compgen -W ' -g -g:none -g:lines -g:vars\
-g:source -O -nowarn -verbose -deprecation -classpath\
-sourcepath -bootclasspath -extdirs -d -encoding -source\
-target -help' -- $cur ) )
else
# source files completion
_filedir java
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _javac $filenames javac
2002-03-07 17:44:48 +00:00
2002-04-29 18:21:41 +00:00
# PINE address-book completion
#
have pine &&
_pineaddr( )
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-07-08 03:09:22 +00:00
COMPREPLY = ( $( compgen -W '$( awk "{print \$1}" ~/.addressbook 2>/dev/null)' \
2002-04-29 18:21:41 +00:00
-- $cur ) )
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _pineaddr $default pine
2002-04-29 18:21:41 +00:00
2002-02-18 08:39:02 +00:00
_configure_func( )
2001-03-05 19:12:48 +00:00
{
2002-04-02 17:22:40 +00:00
local cur
2001-03-05 19:12:48 +00:00
2002-02-18 08:39:02 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-04-02 17:22:40 +00:00
# if $COMP_CONFIGURE_HINTS is not null, then completions of the form
# --option=SETTING will include 'SETTING' as a contextual hint
2002-02-18 08:39:02 +00:00
[ [ " $cur " != -* ] ] && return 0
2002-07-15 21:07:02 +00:00
2002-04-02 17:22:40 +00:00
if [ -n " $COMP_CONFIGURE_HINTS " ] ; then
2002-08-06 20:04:47 +00:00
COMPREPLY = ( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[,[].*//g' | grep ^$cur ) )
2002-07-15 21:07:02 +00:00
2002-04-02 14:56:59 +00:00
else
2002-08-06 20:04:47 +00:00
COMPREPLY = ( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[,=[].*//g' | grep ^$cur ) )
2002-04-02 14:56:59 +00:00
fi
2001-03-05 19:12:48 +00:00
}
2002-04-03 17:19:30 +00:00
complete -F _configure_func $default configure
2001-07-08 23:14:13 +00:00
2002-03-07 18:00:48 +00:00
# urpmi media function required by other urpmi functions
#
2002-07-04 03:45:06 +00:00
have urpmq && {
2002-04-06 20:18:59 +00:00
_urpmi_media( )
2002-03-07 18:00:48 +00:00
{
2002-10-26 04:04:45 +00:00
local media
# first try new urpmq option to get media list
media = $( urpmq --list-media 2>/dev/null )
# default to old manual media extraction
[ -z " $media " ] && media = ( $( sed -ne " s/^\(.\+\) \(\(file\|removable\|ftp\|http\):\/\/.*\)\? { $/\1/p " /etc/urpmi/urpmi.cfg | grep " ^ ${ cur // \\ \\ / \\ \\ } " ) )
# return list of available media
COMPREPLY = ( $( echo $media | tr " " "\n" | grep " ^ $cur " ) )
2002-03-07 18:00:48 +00:00
}
2002-07-04 03:45:06 +00:00
_urpmi_packages( )
{
2002-10-26 04:04:45 +00:00
local packages media
# find if a particular media has been specified
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = --media ] ] ; then
media = ${ COMP_WORDS [i+1] }
break
fi
done
2002-07-04 03:45:06 +00:00
# first try new urpmq option to get package list
2002-10-26 04:04:45 +00:00
packages = $( urpmq --media $media --list 2>/dev/null )
2002-07-04 03:45:06 +00:00
# default to old manual database extraction
2002-10-26 04:04:45 +00:00
[ -z " $packages " ] && packages = $( gzip -dc /var/lib/urpmi/synthesis.hdlist.$media * | awk -F'@' '/info/ {print $1}' )
2002-07-04 03:45:06 +00:00
# return list of available packages
COMPREPLY = ( $( echo $packages | tr " " "\n" | grep " ^ $cur " ) )
}
2002-10-26 04:04:45 +00:00
_urpmi_aliases( )
{
# return list of available nodes
COMPREPLY = ( $( urpmq --list-aliases 2>/dev/null | grep " ^ $cur " ) )
}
2002-07-04 03:45:06 +00:00
}
2002-03-08 17:21:30 +00:00
# Mandrake urpmi completion
2002-03-07 18:00:48 +00:00
#
have urpmi &&
_urpmi( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-04-02 05:27:50 +00:00
case " $prev " in
2002-03-07 18:00:48 +00:00
--media)
2002-04-06 20:18:59 +00:00
_urpmi_media
2002-05-28 18:16:05 +00:00
return 0
; ;
2002-10-26 04:04:45 +00:00
--parallel)
_urpmi_aliases
return 0
; ;
2002-03-07 18:00:48 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
# return list of available options
2002-03-29 15:33:08 +00:00
COMPREPLY = ( $( compgen -W ' -a -p -P -y -s -q -v --help \
2002-10-26 04:04:45 +00:00
--update --media --synthesis --auto --auto-select \
--fuzzy --src --clean --noclean --force --allow-nodeps \
--allow-force --parallel --wget --curl --proxy \
--proxy-user --bug --env --X --best-output \
--verify-rpm --test' -- $cur ) )
2002-03-07 18:00:48 +00:00
else
2002-05-28 18:16:05 +00:00
# return rpm files and available packages
2002-07-04 03:45:06 +00:00
_urpmi_packages
2002-05-28 18:16:05 +00:00
_filedir rpm
2002-03-07 18:00:48 +00:00
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _urpmi urpmi
2002-03-07 18:00:48 +00:00
2002-05-28 18:16:05 +00:00
# Mandrake urpmq completion
#
have urpmq &&
_urpmq( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
--media)
_urpmi_media
return 0
; ;
2002-10-26 04:04:45 +00:00
--parallel)
_urpmi_nodes
return 0
; ;
2002-05-28 18:16:05 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
# return list of available options
2002-07-04 03:45:06 +00:00
COMPREPLY = ( $( compgen -W ' -h -v -d -u -c -P -y -s -g -r -f \
2002-10-26 04:04:45 +00:00
--help --update --media --synthesis --auto-select \
--fuzzy --all --list --list-media --list-nodes \
--list-aliases --src --headers --sources --force \
--parallel --wget --curl --proxy --proxy-user' -- $cur ) )
2002-05-28 18:16:05 +00:00
else
# return rpm files and available packages
2002-07-04 03:45:06 +00:00
_urpmi_packages
2002-05-28 18:16:05 +00:00
_filedir rpm
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _urpmq urpmq
2002-05-28 18:16:05 +00:00
# Mandrake urpme completion
#
have urpme &&
_urpme( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
if [ [ " $cur " = = -* ] ] ; then
# return list of available options
2002-10-26 04:04:45 +00:00
COMPREPLY = ( $( compgen -W '-a --help --auto' -- $cur ) )
2002-05-28 18:16:05 +00:00
else
# return list of available packages
2002-09-09 16:26:14 +00:00
_rpm_installed_packages
2002-05-28 18:16:05 +00:00
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _urpme urpme
2002-05-28 18:16:05 +00:00
# Mandrake urpmf completion
#
have urpmf &&
_urpmf( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
if [ [ " $cur " = = -* ] ] ; then
# return list of available options
COMPREPLY = ( $( compgen -W ' --help --quiet --all --name \
2002-10-26 04:04:45 +00:00
--group --size --serial --summary --description \
--provides --requires --files --conflicts --obsoletes \
--prereqs' -- $cur ) )
2002-05-28 18:16:05 +00:00
else
# return available files
_filedir
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _urpmf urpmf
2002-05-28 18:16:05 +00:00
2002-03-08 17:21:30 +00:00
# Mandrake urpmi.update completion
2002-03-07 18:00:48 +00:00
#
have urpmi.update &&
2002-04-06 20:18:59 +00:00
_urpmi_update( )
2002-03-07 18:00:48 +00:00
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
if [ [ " $cur " = = -* ] ] ; then
# return list of available options
2002-10-26 04:04:45 +00:00
COMPREPLY = ( $( compgen -W ' -a -c -d -f --help --curl --wget \
--proxy --proxy-user' -- $cur ) )
2002-03-07 18:00:48 +00:00
else
# return list of available media
2002-04-06 20:18:59 +00:00
_urpmi_media
2002-03-07 18:00:48 +00:00
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _urpmi_update urpmi.update
2002-03-07 18:00:48 +00:00
2002-03-08 17:21:30 +00:00
# Mandrake urpmi.addmedia completion
2002-03-07 18:00:48 +00:00
#
have urpmi.addmedia &&
2002-04-06 20:18:59 +00:00
_urpmi_addmedia( )
2002-03-07 18:00:48 +00:00
{
local cur i args
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
if [ [ " $cur " = = -* ] ] ; then
# return list of available options
2002-10-26 04:04:45 +00:00
COMPREPLY = ( $( compgen -W ' -c -h -f --help --wget --curl \
--proxy --proxy-user --update --distrib' -- $cur ) )
2002-03-07 18:00:48 +00:00
else
# count number of mandatory args given sofar
args = $COMP_CWORD
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = -* ] ] ; then
args = $(( $args - 1 ))
fi
done
case $args in
1)
# return list of available media
2002-04-06 20:18:59 +00:00
_urpmi_media
2002-03-07 18:00:48 +00:00
; ;
2)
# return list of available protocols
COMPREPLY = ( $( compgen -W ' file:// http:// \
ftp:// removable://' -- $cur ) )
; ;
3)
# return word "with"
COMPREPLY = ( 'with' )
; ;
esac
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _urpmi_addmedia urpmi.addmedia
2002-03-07 18:00:48 +00:00
2002-03-08 17:21:30 +00:00
# Mandrake urpmi.removemedia completion
2002-03-07 18:00:48 +00:00
#
2002-04-06 20:18:59 +00:00
have urpmi.removemedia &&
_urpmi_removemedia( )
2002-03-07 18:00:48 +00:00
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
if [ [ " $cur " = = -* ] ] ; then
# if word begins with a dash, return list of available options
2002-10-26 04:04:45 +00:00
COMPREPLY = ( $( compgen -W '-a -c --help' -- $cur ) )
2002-03-07 18:00:48 +00:00
else
# elsewhere, return list of available media
2002-04-06 20:18:59 +00:00
_urpmi_media
2002-03-07 18:00:48 +00:00
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _urpmi_removemedia urpmi.removemedia
2002-03-07 18:00:48 +00:00
2002-05-09 16:20:53 +00:00
# Debian reportbug(1) completion
2002-03-11 01:15:09 +00:00
#
have reportbug &&
_reportbug( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-f| --filename| -i| --include| --mta| -o| --output)
_filedir
return 0
; ;
-B| --bts)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W "debian guug kde mandrake help" -- \
$cur ) )
2002-03-11 01:15:09 +00:00
return 0
; ;
-e| --editor| --mua)
COMP_WORDS = ( COMP_WORDS[ 0] $cur )
COMP_CWORD = 1
_command
return 0
; ;
--mode)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W "novice standard expert" -- $cur ) )
2002-03-11 01:15:09 +00:00
return 0
; ;
-S| --severity)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W " grave serious important normal \
minor wishlist" -- $cur ) )
2002-09-28 16:12:24 +00:00
return 0
2002-03-11 01:15:09 +00:00
; ;
2002-03-26 18:45:45 +00:00
-u| --ui| --interface)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W "newt text gnome" -- $cur ) )
2002-03-11 01:15:09 +00:00
return 0
; ;
-t| --type)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W "gnats debbugs" -- $cur ) )
2002-09-28 16:12:24 +00:00
return 0
2002-03-11 01:15:09 +00:00
; ;
-T| --tags)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W " none patch security upstream sid \
woody potato sarge fixed" -- $cur ) )
2002-09-28 16:12:24 +00:00
return 0
2002-03-11 01:15:09 +00:00
; ;
*)
; ;
esac
COMPREPLY = ( $( compgen -W ' -h --help -v --version -a --af -b \
--no-query-bts --query-bts -B --bts -c --configure \
2002-09-28 16:12:24 +00:00
--no-config-files --check-available -d --debug \
--no-check-available -e --editor --email -f \
--filename -g --gnupg -H --header -i --include -j \
--justification -l --ldap --no-ldap -L --list-cc -m \
--maintonly --mode --mua --mta --mutt -n --mh --nmh \
-o --output -p --print -P --pgp --proxy --http_proxy\
-q --quiet -Q --query-only --realname --report-quiet \
--reply-to --replyto -s --subject -S --severity \
--smtphost -t --type -T --tags --template -V -x \
--no-cc --package-version -z --no-compress \
--ui --interface -u \
wnpp boot-floppies kernel-image' -- $cur ) \
2002-03-16 19:49:44 +00:00
$( apt-cache pkgnames -- $cur ) )
2002-03-11 01:15:09 +00:00
_filedir
return 0
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _reportbug $filenames reportbug
2002-03-11 01:15:09 +00:00
2002-05-09 16:20:53 +00:00
# Debian querybts(1) completion
2002-03-11 01:15:09 +00:00
#
have querybts &&
_querybts( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-B| --bts)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W "debian guug kde mandrake help" -- \
$cur ) )
2002-03-11 01:15:09 +00:00
return 0
; ;
2002-03-26 18:45:45 +00:00
-u| --ui| --interface)
2002-03-11 01:15:09 +00:00
COMPREPLY = ( $( compgen -W "newt text gnome" -- $cur ) )
return 0
; ;
*)
; ;
esac
COMPREPLY = ( $( compgen -W ' -h --help -v --version -A --archive \
-B --bts -l --ldap --no-ldap --proxy= --http_proxy= \
2002-09-28 16:12:24 +00:00
-s --source -w --web -u --ui --interface \
wnpp boot-floppies' -- $cur ) \
2002-03-16 19:49:44 +00:00
$( apt-cache pkgnames -- $cur ) )
2002-03-11 01:15:09 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _querybts $filenames querybts
2002-03-11 01:15:09 +00:00
2002-04-24 20:26:49 +00:00
# update-alternatives completion
#
have update-alternatives &&
_update_alternatives( )
{
installed_alternatives( )
{
local admindir
# find wich admin dir to use
if [ -f /etc/debian_version ] ; then
admindir = /var/lib/dpkg/alternatives
else
admindir = /var/lib/rpm/alternatives
fi
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = --admindir ] ] ; then
admindir = ${ COMP_WORDS [i+1] }
break
fi
done
2002-06-04 03:45:09 +00:00
COMPREPLY = ( $( command ls $admindir | grep " ^ $cur " ) )
2002-04-24 20:26:49 +00:00
}
local cur prev mode args
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
--@( altdir| admindir) )
_filedir -d
return 0
; ;
--@( help| version) )
return 0
; ;
esac
# find wich mode to use and how many real args used so far
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
2002-05-19 07:16:30 +00:00
if [ [ " ${ COMP_WORDS [i] } " = = --@( install| remove| auto| display| config) ] ] ; then
2002-04-24 20:26:49 +00:00
mode = ${ COMP_WORDS [i] }
args = $(( $COMP_CWORD - i))
break
fi
done
case $mode in
--install)
case $args in
1)
_filedir
; ;
2)
installed_alternatives
; ;
3)
_filedir
; ;
esac
; ;
--remove)
case $args in
1)
installed_alternatives
; ;
2)
_filedir
; ;
esac
; ;
--auto)
installed_alternatives
; ;
--display)
installed_alternatives
; ;
--config)
installed_alternatives
; ;
*)
COMPREPLY = ( $( compgen -W ' --verbose --quiet --help --version \
--altdir --admindir' -- $cur ) \
$( compgen -W ' --install --remove --auto --display \
--config' -- $cur ) )
esac
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _update_alternatives update-alternatives
2002-04-24 20:26:49 +00:00
2002-05-18 17:05:08 +00:00
# Python completion
#
have python &&
_python( )
{
2002-10-10 06:38:05 +00:00
local prev cur
2002-05-18 17:05:08 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-10-10 06:38:05 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-05-18 17:05:08 +00:00
2002-10-10 06:38:05 +00:00
case " $prev " in
-Q)
COMPREPLY = ( $( compgen -W "old new warn warnall" -- $cur ) )
return 0
; ;
-W)
COMPREPLY = ( $( compgen -W "ignore default all module once error" -- $cur ) )
return 0
; ;
-c)
2002-05-18 17:05:08 +00:00
_filedir '@(py|pyc|pyo)'
2002-10-10 06:38:05 +00:00
return 0
; ;
!( python| -?) )
2002-10-13 01:46:49 +00:00
[ [ ${ COMP_WORDS [COMP_CWORD-2] } != -@( Q| W) ] ] && _filedir
2002-10-10 06:38:05 +00:00
; ;
esac
# if '-c' is already given, complete all kind of files.
for ( ( i = 0; i < ${# COMP_WORDS } -1; i++ ) ) ; do
if [ [ ${ COMP_WORDS [i] } = = -c ] ] ; then
2002-10-13 01:46:49 +00:00
_filedir
2002-10-10 06:38:05 +00:00
fi
done
if [ [ " $cur " != -* ] ] ; then
_filedir '@(py|pyc|pyo)'
else
2002-10-13 01:46:49 +00:00
COMPREPLY = ( $( compgen -W " - -d -E -h -i -O -Q -S -t -u \
-U -v -V -W -x -c" -- $cur ) )
2002-05-18 17:05:08 +00:00
fi
2002-10-10 06:38:05 +00:00
2002-05-18 17:05:08 +00:00
return 0
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _python $filenames python
2002-05-18 17:05:08 +00:00
2002-07-29 16:05:59 +00:00
# Perl completion
#
have perl &&
{
_perlmodules( )
{
2002-10-17 01:05:29 +00:00
COMPREPLY = ( $( compgen -P " $prefix " -W " $( perl -e 'sub mods { my ($base,$dir)=@_; return if $base !~ /^\Q$ENV{cur}/; chdir($dir) or return; for (glob(q[*.pm])) {s/\.pm$//; print qq[$base$_\n]}; mods(/^(?:[.\d]+|$Config{archname}-$Config{osname}|auto)$/ ? undef : qq[${base}${_}\\\\:\\\\:],qq[$dir/$_]) for grep {-d} glob(q[*]); } mods(undef,$_) for @INC;' ) " -- $cur ) )
2002-07-29 16:05:59 +00:00
}
_perl( )
{
local cur prev prefix temp
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
prefix = ""
# completing an option (may or may not be separated by a space)
if [ [ " $cur " = = -?* ] ] ; then
temp = $cur
prev = ${ temp : 0 : 2 }
cur = ${ temp : 2 }
prefix = $prev
fi
# only handle module completion for now
case " $prev " in
-m| -M)
_perlmodules
return 0
; ;
esac
# handle case where first parameter is not a dash option
if [ $COMP_CWORD -eq 1 ] && [ [ " $cur " != -* ] ] ; then
_filedir -d
return 0
fi
# complete using basic options
COMPREPLY = ( $( compgen -W ' -C -s -T -u -U -W -X -h -v -V -c -w -d -D -p \
-n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) )
return 0
}
complete -F _perl $default perl
_perldoc( )
{
local cur prev prefix temp
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
prefix = ""
# completing an option (may or may not be separated by a space)
if [ [ " $cur " = = -?* ] ] ; then
temp = $cur
prev = ${ temp : 0 : 2 }
cur = ${ temp : 2 }
prefix = $prev
fi
# complete builtin perl functions
case $prev in
-f)
COMPREPLY = ( $( compgen -W ' chomp chop chr crypt hex index lc \
lcfirst length oct ord pack q qq reverse rindex sprintf \
substr tr uc ucfirst y m pos quotemeta s split study qr abs \
atan2 cos exp hex int log oct rand sin sqrt srand pop push \
shift splice unshift grep join map qw reverse sort unpack \
delete each exists keys values binmode close closedir \
dbmclose dbmopen die eof fileno flock format getc print \
printf read readdir rewinddir seek seekdir select syscall \
sysread sysseek syswrite tell telldir truncate warn write \
pack read syscall sysread syswrite unpack vec -X chdir chmod \
chown chroot fcntl glob ioctl link lstat mkdir open opendir \
readlink rename rmdir stat symlink umask unlink utime caller \
continue die do dump eval exit goto last next redo return \
sub wantarray caller import local my our package use defined \
dump eval formline local my our reset scalar undef wantarray \
alarm exec fork getpgrp getppid getpriority kill pipe qx \
setpgrp setpriority sleep system times wait waitpid do \
import no package require use bless dbmclose dbmopen package \
ref tie tied untie use accept bind connect getpeername \
getsockname getsockopt listen recv send setsockopt shutdown \
socket socketpair msgctl msgget msgrcv msgsnd semctl semget \
semop shmctl shmget shmread shmwrite endgrent endhostent \
endnetent endpwent getgrent getgrgid getgrnam getlogin \
getpwent getpwnam getpwuid setgrent setpwent endprotoent \
endservent gethostbyaddr gethostbyname gethostent \
getnetbyaddr getnetbyname getnetent getprotobyname \
getprotobynumber getprotoent getservbyname getservbyport \
getservent sethostent setnetent setprotoent setservent \
gmtime localtime time times' -- $cur ) )
return 0
; ;
esac
case $cur in
-*)
COMPREPLY = ( $( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- $cur ) )
return 0
; ;
*)
_perlmodules
2002-12-16 19:48:58 +00:00
COMPREPLY = ( ${ COMPREPLY [@] } $( compgen -W '$( PAGER=cat man perl | sed -ne "/perl.*Perl overview/,/perlwin32/s/^[^a-z0-9]*\([a-z0-9]*\).*$/\1/p")' -- $cur ) )
2002-07-29 16:05:59 +00:00
return 0
; ;
esac
}
complete -F _perldoc $default perldoc
}
2002-05-30 17:08:15 +00:00
# rcs(1) completion
#
have rcs &&
_rcs( )
{
local cur prev file dir
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
file = ${ cur ##*/ }
dir = ${ cur %/* }
# deal with relative directory
[ " $file " = " $dir " ] && dir = .
COMPREPLY = ( $( compgen -f " $dir /RCS/ $file " ) )
for ( ( i = 0; i < ${# COMPREPLY [@] } ; i++ ) ) ; do
file = ${ COMPREPLY [ $i ]##*/ }
file = ${ file %,v }
dir = ${ COMPREPLY [ $i ]%RCS/* }
COMPREPLY[ $i ] = $dir $file
done
# default to files if nothing returned and we're checking in.
# otherwise, default to directories
[ ${# COMPREPLY [@] } -eq 0 -a $1 = ci ] && _filedir || _filedir -d
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _rcs $filenames ci co rlog rcs rcsdiff
2002-05-30 17:08:15 +00:00
2002-06-01 19:01:05 +00:00
# lilo(8) completion
#
have lilo &&
_lilo( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
-@( C| i| m| s| S) )
_filedir
return 0
; ;
-r)
_filedir -d
return 0
; ;
-@( I| D| R) )
# label completion
COMPREPLY = ( $( awk -F'=' '/label/ {print $2}' \
/etc/lilo.conf | grep " ^ $cur " ) )
return 0
; ;
-@( A| b| M| u| U) )
# device completion
cur = ${ cur : =/dev/ }
_filedir
return 0
; ;
-T)
# topic completion
COMPREPLY = ( $( compgen -W ' help ChRul EBDA geom geom = \
table = video' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
COMPREPLY = ( $( compgen -W ' -A -b -c -C -d -f -g -i -I -l -L -m \
-M -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- \
$cur ) )
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _lilo lilo
2002-06-01 19:01:05 +00:00
2002-10-01 06:55:38 +00:00
# links completion
#
have links &&
_links( )
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
case " $cur " in
--*)
COMPREPLY = ( $( compgen -W '--help' -- $cur ) )
; ;
-*)
COMPREPLY = ( $( compgen -W ' -async-dns -max-connections \
-max-connections-to-host -retries \
-receive-timeout -unrestartable-receive-timeout\
-format-cache-size -memory-cache-size \
-http-proxy -ftp-proxy -download-dir \
-assume-codepage -anonymous -dump -no-connect \
-source -version -help' -- $cur ) )
; ;
*)
2002-10-01 07:06:01 +00:00
if [ -r ~/.links/links.his ] ; then
2002-10-01 06:55:38 +00:00
COMPREPLY = ( $( compgen -W '$( < ~/.links/links.his )' \
-- $cur ) )
2002-10-01 07:06:01 +00:00
fi
2002-10-01 06:55:38 +00:00
_filedir '@(htm|html)'
return 0
; ;
esac
return 0
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _links $filenames links
2002-10-01 06:55:38 +00:00
2002-12-05 01:47:49 +00:00
[ $UNAME = FreeBSD ] && {
2002-12-05 01:52:56 +00:00
# FreeBSD package management tool completion
2002-10-17 01:18:34 +00:00
#
_pkg_delete( )
{
2002-12-05 01:52:56 +00:00
local cur pkgdir prev
2002-10-17 03:01:21 +00:00
2003-04-19 06:52:57 +00:00
pkgdir = ${ PKG_DBDIR :- /var/db/pkg } /
2002-10-17 01:18:34 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-12-05 01:52:56 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
test " $prev " = "-o" -o " $prev " = "-p" -o " $prev " = "-W" && return 0
2002-10-17 01:18:34 +00:00
2002-10-17 03:01:21 +00:00
COMPREPLY = ( $( compgen -d $pkgdir $cur ) )
2002-10-17 18:51:25 +00:00
COMPREPLY = ( ${ COMPREPLY [@]# $pkgdir } )
2002-10-17 01:18:34 +00:00
return 0
}
2002-12-05 01:47:49 +00:00
complete -F _pkg_delete $dirnames pkg_delete pkg_info
2002-12-05 01:52:56 +00:00
# FreeBSD kernel module commands
2002-12-05 01:47:49 +00:00
#
_kldload( )
{
local cur moddir
moddir = /modules/
cur = ${ COMP_WORDS [COMP_CWORD] }
COMPREPLY = ( $( compgen -f $moddir $cur ) )
COMPREPLY = ( ${ COMPREPLY [@]# $moddir } )
COMPREPLY = ( ${ COMPREPLY [@]%.ko } )
return 0
}
complete -F _kldload $filenames kldload
_kldunload( )
{
local cur
cur = ${ COMP_WORDS [COMP_CWORD] }
COMPREPLY = ( $( kldstat | sed -ne " s/^.*[ \t]\+\( $cur [a-z_]\+\).ko $/\1/p " ) )
}
complete -F _kldunload $filenames kldunload
}
2002-10-17 01:18:34 +00:00
2002-12-05 01:52:56 +00:00
# FreeBSD portupgrade completion
#
have portupgrade &&
_portupgrade( )
{
local cur pkgdir prev
2003-04-19 06:52:57 +00:00
pkgdir = ${ PKG_DBDIR :- /var/db/pkg } /
2002-12-05 01:52:56 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
test " $prev " = "-l" -o " $prev " = "-L" -o " $prev " = "-o" && return 0
COMPREPLY = ( $( compgen -d $pkgdir $cur ) )
COMPREPLY = ( ${ COMPREPLY [@]# $pkgdir } )
COMPREPLY = ( ${ COMPREPLY [@]%-* } )
return 0
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _portupgrade $dirnames portupgrade
2002-12-05 01:52:56 +00:00
2002-10-17 03:01:21 +00:00
# Slackware Linux removepkg completion
#
have removepkg && [ -f /etc/slackware-version ] &&
_removepkg( )
{
local packages cur
2002-10-17 05:20:05 +00:00
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-10-17 03:01:21 +00:00
2002-10-17 05:20:05 +00:00
COMPREPLY = ( $( ( cd /var/log/packages; compgen -f -- " $cur " ) ) )
2002-10-17 03:01:21 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _removepkg $filenames removepkg &&
2002-12-19 20:57:36 +00:00
complete $dirnames -f -X '!*.tgz' installpkg upgradepkg explodepkg
2002-10-17 03:01:21 +00:00
2002-10-23 14:05:16 +00:00
# look(1) completion
#
have look &&
_look( )
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
if [ $COMP_CWORD = 1 ] ; then
2002-10-25 20:45:23 +00:00
COMPREPLY = ( $( compgen -W '$(look $cur)' ) )
2002-10-23 14:05:16 +00:00
fi
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _look $default look
2002-10-23 14:05:16 +00:00
2002-12-05 05:31:42 +00:00
# ypcat(1) and ypmatch(1) completion
#
have ypmatch &&
_ypmatch( )
{
2002-12-05 20:43:10 +00:00
local cur map
2002-12-05 05:31:42 +00:00
2002-12-05 20:43:10 +00:00
COMPREPLY = ( )
2002-12-05 05:31:42 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
2002-12-05 16:58:26 +00:00
[ $1 = ypcat ] && [ $COMP_CWORD -gt 1 ] && return 0
[ $1 = ypmatch ] && [ $COMP_CWORD -gt 2 ] && return 0
2002-12-05 20:43:10 +00:00
if [ $1 = ypmatch ] && [ $COMP_CWORD -eq 1 ] && \
[ ${# COMP_WORDS [@] } -eq 3 ] ; then
map = ${ COMP_WORDS [2] }
COMPREPLY = ( $( compgen -W ' $( ypcat $map | \
cut -d':' -f 1 ) ' -- $cur ) )
else
[ $1 = ypmatch ] && [ $COMP_CWORD -ne 2 ] && return 0
2002-12-05 05:31:42 +00:00
COMPREPLY = ( $( compgen -W \
'$( echo $(ypcat -x | cut -d"\"" -f 2))' -- $cur ) )
fi
2002-12-05 20:43:10 +00:00
return 0
2002-12-05 05:31:42 +00:00
}
2002-12-18 18:15:46 +00:00
[ -n " ${ have :- } " ] && complete -F _ypmatch ypmatch ypcat
2002-12-05 05:31:42 +00:00
2002-12-31 02:15:25 +00:00
# mplayer(1) completion
2002-12-19 20:56:47 +00:00
#
2002-12-30 21:23:21 +00:00
have mplayer && {
_mplayer_options_list( )
{
COMPREPLY = ( $( $1 $2 help 2> /dev/null | \
sed -e '1,/^Available/d' | awk '{print $1}' | \
sed -e 's/:$//' -e 's/^' ${ 2 #- } '$//' | grep " ^ $cur " ) )
}
2002-12-19 20:56:47 +00:00
_mplayer( )
{
2002-12-30 21:23:21 +00:00
local cmd cur prev
2002-12-19 20:56:47 +00:00
COMPREPLY = ( )
2002-12-30 21:23:21 +00:00
cmd = ${ COMP_WORDS [0] }
2002-12-19 20:56:47 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-12-30 21:23:21 +00:00
case " $prev " in
-@( ac| afm| vc| vfm| ao| vo| vop) )
_mplayer_options_list mplayer $prev
return 0
; ;
-@( oac| ovc) )
_mplayer_options_list mencoder $prev
return 0
; ;
2002-12-19 20:56:47 +00:00
-audiofile)
2002-12-30 21:23:21 +00:00
_filedir '@(mp3|MP3|mpg|MPG|ogg|OGG|wav|WAV)'
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-font)
_filedir '@(desc|ttf)'
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-sub)
_filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF)'
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-aop)
COMPREPLY = ( $( compgen -W ' list = delay = format = fout = \
volume = mul = softclip' -- $cur ) )
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-dxr2)
COMPREPLY = ( $( compgen -W ' ar-mode= iec958-encoded \
iec958-decoded mute ucode = 75ire bw \
color interlaced macrovision = norm = \
square-pixel ccir601-pixel cr-left= \
cr-right= cr-top= cr-bot= ck-min= \
ck-rgbmin= ck-max= ck-rgbmax= ck = \
ck-rgb= ignore-cache= ol-osd= ol-cor= \
olhwxy-cor= overlay overlay-ratio= \
update-cache' -- $cur ) )
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-tv)
COMPREPLY = ( $( compgen -W ' on noaudio driver = device = \
input = frequ = outfmt = width = height = \
buffersize = norm = channel = chanlist = \
audiorate = forceaudio alsa amode = \
forcechan = adevice = audioid = volume = \
bass = treble = balance = ' -- $cur ) )
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-mf)
COMPREPLY = ( $( compgen -W 'on w= h= fps= type=' -- $cur ) )
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-cdda)
COMPREPLY = ( $( compgen -W ' speed = paranoia = \
generic-dev= sector-size= overlap = \
toc-bias toc-offset= skip noskip' \
-- $cur ) )
return 0
; ;
-input)
COMPREPLY = ( $( compgen -W ' conf = ar-delay ar-rate \
keylist cmdlist js-dev file' -- $cur ) )
return 0
; ;
-af)
COMPREPLY = ( $( compgen -W ' resample = channels = format = \
volume = delay = ' -- $cur ) )
return 0
; ;
-af-adv)
COMPREPLY = ( $( compgen -W 'force= list=' -- $cur ) )
return 0
; ;
esac
2002-12-19 20:56:47 +00:00
2002-12-30 21:23:21 +00:00
case " $cur " in
--*)
COMPREPLY = ( $( compgen -W '--help --verbose' -- $cur ) )
; ;
-*)
COMPREPLY = ( $( compgen -W ' -aid -alang -audio-demuxer \
-audiofile -cdrom-device -cache -cdda \
-channels -chapter -csslib -demuxer \
-dvd -dvd-device -dvdangle -dvdauth \
-dvdkey -dvdnav -forceidx -fps -frames \
-hr-mp3-seek -idx -mc -mf -ni -nobps \
-passwd -rawaudio -rtsp-stream-over-tcp\
-skipopening -sb -srate -ss -tv -user \
-vcd -vid -vivo -ifo -ffactor -font \
-noautosub -nooverlapsub -sid -slang \
-sub -subcc -subcp -sub-demuxer \
-subdelay -subfont-autoscale \
-subfont-blur -subfont-encoding \
-subfont-osd-scale -subfont-outline \
-subfont-text-scale -subfps -subfile \
-subpos -unicode -utf8 -vobsub \
-vobsubid -ac -afm -aspect -flip \
-lavdopts -noaspect -nosound -pp -ssf \
-stereo -sws -vc -vfm -vop -x -xvidopts\
-xy -zoom' -- $cur ) )
# add mplayer specific options
[ [ " $cmd " = = @( ?( g) mplayer) ] ] && COMPREPLY = ( ${ COMPREPLY [@] } \
$( compgen -W ' -autoq -autosync -benchmark \
-framedrop -h -help -hardframedrop \
-identify -input -lircconf -loop \
-nojoystick -nolirc -nortc -playlist \
-quiet -really-quiet -rnd -sdp -skin \
-slave -softsleep -speed -sstep \
-use-stdin -dumpaudio -dumpfile \
-dumpstream -dumpvideo -dumpmicrodvdsub\
-dumpmpsub -dumpsrtsub -dumpjacosub \
-dumpsami -dumpsub -osdlevel -af \
-af-adv -ao -aofile -aop -delay -mixer \
-nowaveheader -bpp -brightness \
-contrast -display -double -dr -dxr2 \
-fb -fbmode -fbmodeconfig -forcexv -fs \
-geometry -hue -icelayer -jpeg \
-monitor_dotclock -monitor_hfreq \
-monitor_vfreq -monitoraspect \
-nograbpointer -noslices -panscan \
-rootwin -saturation -screenw -screenh \
-stop_xscreensaver -vm -vo -vsync -wid \
-xineramascreen -z -zrbw -zrcrop \
-zrdev -zrfd -zrhelp -zrnorm -zrquality\
-zrvdec -zrhdec -zrxdoff -zrydoff -y' \
-- $cur ) )
# add mencoder specific options
[ [ " $cmd " = mencoder ] ] && COMPREPLY = ( ${ COMPREPLY [@] } \
$( compgen -W ' -audio-density -audio-delay \
-audio-preload -divx4opts -endpos \
-ffourcc -include -info -lameopts \
-lavcopts -noskip -o -oac -ofps -ovc \
-passlogfile -skiplimit -vobsubout \
-vobsuboutindex -vobsuboutid \
-xvidencopts' -- $cur ) )
; ;
*)
_filedir '@(mpg|mpeg|MPG|MPEG|wma|avi|AVI|asf|vob|bin|vcd|ps|pes|fli|viv|rm|ram|yuv|mov|wmv|mp3|MP3|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV)'
; ;
2002-12-19 20:56:47 +00:00
esac
return 0
}
2002-12-30 21:23:21 +00:00
}
[ -n " ${ have :- } " ] && complete $filenames -F _mplayer mplayer mencoder gmplayer
2002-12-19 20:56:47 +00:00
2003-04-08 05:48:47 +00:00
# KDE dcop completion
#
have dcop &&
_dcop( )
{
local cur compstr
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
if [ -z $cur ] ; then
compstr = ${ COMP_WORDS [*] }
else
compstr = $( command echo ${ COMP_WORDS [*] } | sed " s/ $cur $// " )
fi
COMPREPLY = ( $( compgen -W '$( command $compstr | sed s/\(.*\)// )' -- $cur ) )
}
[ " ${ have :- } " ] && complete -F _dcop dcop
2002-12-31 01:40:22 +00:00
# wvdial(1) completion
#
have wvdial &&
_wvdial( )
{
local cur prev configfile i
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
--config)
_filedir
return 0
; ;
esac
case $cur in
-*)
COMPREPLY = ( $( compgen -W ' --config --chat \
--remotename --help --version --no-syslog' -- $cur ) )
; ;
*)
# find which config file to use
configfile = /etc/wvdial.conf
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = $1 ] ] ; then
configfile = ${ COMP_WORDS [i+1] }
break
fi
done
[ ! -f $configfile ] && return 0
# parse config file for sections
COMPREPLY = ( $( awk '/\[Dialer .+\]/ {print $0}' $configfile | \
sed -e '1d' -e 's/^\[Dialer //' -e 's/\]$//' | grep " ^ $cur " ) )
; ;
esac
}
[ -n " ${ have :- } " ] && complete -F _wvdial wvdial
2002-12-31 01:59:25 +00:00
# gpg(1) completion
#
have gpg &&
_gpg( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
2003-04-18 23:12:37 +00:00
-@( s| -sign| -clearsign| -decrypt-files| -load-extension) )
_filedir
return 0
; ;
--@( export| @( ?( l| nr| nrl) sign| edit) -key) )
# return list of public keys
COMPREPLY = ( $( compgen -W " $( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*/\([^ ]*\).*\(<\([^>]*\)>\).*$@\1 \3@p' ) " -- " $cur " ) )
return 0
; ;
-@( r| -recipient) )
COMPREPLY = ( $( compgen -W " $( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*<\([^>]*\)>.*$@\1@p' ) " -- " $cur " ) )
if [ -e ~/.gnupg/gpg.conf ] ; then
COMPREPLY = ( ${ COMPREPLY [@] } $( compgen -W " $( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf ) " -- " $cur " ) )
fi
return 0
; ;
2002-12-31 01:59:25 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -s -b -e -f -c -d -a -r -u -Z -o -v \
-q -n -N --sign --clearsign --detach-sign \
--encrypt --encrypt-files --symmetric --store \
--decrypt --decrypt-files --verify --list-keys \
--list-sigs --check-sigs --fingerprint \
--list-secret-keys --gen-key --delete-keys \
--delete-secret-keys --sign-key --lsign-key \
--nrsign-key --nrlsign-key --edit-key \
--gen-revoke --export --send-key --recv-keys \
--search-keys --refresh-keys --import \
--list-packets --export-ownertrust \
--import-ownertrust --update-trustdb \
--check-trustdb --fix-trustdb --dearmor \
--enarmor --print-md --armor --recipient \
--default-recipient --default-recipient-self \
--local-user --textmode --output --verbose \
--quiet --no-tty --force-v3-sigs \
--no-force-v3-sigs --force-v4-certs \
--no-force-v4-certs --force-mdc --disable-mdc \
--dry-run --use-agent --batch --yes --no \
--keyring --secret-keyring --show-keyring \
--default-key --keyserver --charset --options \
--status-fd --trusted-key --load-extension \
--rfc1991 --openpgp --pgp2 --s2k-mode \
--s2k-digest-algo --s2k-cipher-algo \
--cipher-algo --digest-algo --compress-algo \
--throw-keyid --show-photos --no-show-photos \
--photo-viewer --notation-data' -- $cur ) )
fi
}
[ " ${ have :- } " ] && complete -F _gpg $default gpg
2003-04-14 06:35:23 +00:00
# iconv(1) completion
#
have iconv &&
_iconv( )
{
local cur prev
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ " $cur " = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --from-code -f --to-code -t --list
--output -o --verbose' -- " $cur " ) )
return 0
fi
if [ [ " $prev " = = -@( f| t| -@( from| to) -code) ] ] ; then
COMPREPLY = ( $( compgen -W \
'$( iconv --list | sed "1,/^$/d; s@//@@;" )' -- " $cur " ) )
fi
return 0
}
[ -n " ${ have :- } " ] && complete -F _iconv $default iconv
2003-04-15 06:54:50 +00:00
# dict(1) completion
#
{ have dict || have rdict; } &&
_dictdata( )
{
dict $host $port $1 2>/dev/null | sed -ne \
's/^[' $'\t ' '][' $'\t ' ']*\([^' $'\t ' ']*\).*$/\1/p'
}
# dict(1) completion
#
_dict( )
{
local cur prev host port db dictfile
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD] }
prev = ${ COMP_WORDS [COMP_CWORD-1] }
dictfile = /usr/share/dict/words
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
case " ${ COMP_WORDS [i] } " in
-@( h| --host) )
host = ${ COMP_WORDS [i+1] }
[ -n " $host " ] && host = " -h $host "
i = $(( + + i))
; ;
-@( p| -port) )
port = ${ COMP_WORDS [i+1] }
[ -n " $port " ] && port = " -p $port "
i = $(( + + i))
; ;
-@( d| -database) )
db = ${ COMP_WORDS [i+1] }
[ -n " $db " ] && host = " -d $db "
i = $(( + + i))
; ;
*)
; ;
esac
done
if [ [ " $cur " = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -h --host -p --port -d --database \
-m --match -s --strategy -c --config -C \
--nocorrect -D --dbs -S --strats -H \
--serverhelp -i --info -I --serverinfo \
-a --noauth -u --user -k --key -V --version \
-L --license --help -v --verbose -r --raw \
-P --pager --debug --html --pipesize --client' \
-- " $cur " ) )
return 0
fi
case " $prev " in
-@( d| -database| i| info) )
COMPREPLY = ( $( compgen -W '$( _dictdata -D )' -- " $cur " ) )
return 0
; ;
-@( s| -strategy) )
COMPREPLY = ( $( compgen -W '$( _dictdata -S )' -- " $cur " ) )
return 0
; ;
*)
; ;
esac
[ -r $dictfile ] && \
COMPREPLY = ( $( compgen -W '$( cat $dictfile )' -- " $cur " ) )
}
[ -n " ${ have :- } " ] && complete -F _dict $default dict rdict
2002-01-23 23:36:30 +00:00
_filedir_xspec( )
2001-12-20 07:52:12 +00:00
{
2002-01-04 04:34:21 +00:00
local IFS cur xspec
2001-12-20 07:52:12 +00:00
2002-01-04 04:34:21 +00:00
IFS = $'\t\n'
2001-12-20 07:52:12 +00:00
COMPREPLY = ( )
2002-01-23 23:13:21 +00:00
cur = ${ COMP_WORDS [COMP_CWORD] }
_expand || return 0
2001-12-20 07:52:12 +00:00
# get first exclusion compspec that matches this command
2002-01-29 20:33:49 +00:00
xspec = $( sed -ne '/ ' ${ 1 ##*/ } '/{p;q;}' $BASH_COMPLETION )
2001-12-20 07:52:12 +00:00
# prune to leave nothing but the -X spec
xspec = ${ xspec #*-X }
xspec = ${ xspec %% * }
2002-07-31 23:18:51 +00:00
COMPREPLY = ( $( eval compgen -f -X " $xspec " -- \
\" ${ cur #[ \` \" \' ] } \" 2>/dev/null ) \
2002-02-27 15:48:20 +00:00
$( compgen -d -- $cur ) )
2001-12-20 07:52:12 +00:00
}
2001-12-20 16:12:44 +00:00
list = ( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' \
2002-01-29 20:33:49 +00:00
$BASH_COMPLETION | \
2001-12-20 16:12:44 +00:00
# read exclusion compspecs
(
while read line
do
2002-01-23 20:35:17 +00:00
# ignore compspecs that are commented out
if [ " ${ line # \# } " != " $line " ] ; then continue ; fi
2001-12-20 16:12:44 +00:00
line = ${ line %# START exclude* }
line = ${ line %# FINISH exclude* }
line = ${ line ##* \' }
2002-12-18 18:15:46 +00:00
list = ( ${ list [@] :- } $line )
2001-12-20 16:12:44 +00:00
done
echo ${ list [@] }
)
2001-12-20 18:26:49 +00:00
) )
2001-12-20 07:52:12 +00:00
# remove previous compspecs
2002-01-03 00:16:41 +00:00
if [ ${# list [@] } -gt 0 ] ; then
eval complete -r ${ list [@] }
# install new compspecs
2002-04-03 17:19:30 +00:00
eval complete -F _filedir_xspec $filenames ${ list [@] }
2002-01-03 00:16:41 +00:00
fi
2003-02-26 00:17:54 +00:00
unset list
2002-03-08 18:50:24 +00:00
# source completion directory definitions
2002-03-11 18:36:44 +00:00
if [ -d $BASH_COMPLETION_DIR -a -r $BASH_COMPLETION_DIR -a \
-x $BASH_COMPLETION_DIR ] ; then
2002-03-11 17:38:17 +00:00
for i in $BASH_COMPLETION_DIR /*; do
2002-12-05 04:22:22 +00:00
[ [ ${ i ##*/ } != @( *~| *.bak| *.swp| \# *\# | *.dpkg*) ] ] &&
[ -f $i -a -r $i ] && . $i
2002-03-11 17:38:17 +00:00
done
fi
2002-04-02 23:37:51 +00:00
unset i
2001-12-05 16:32:24 +00:00
# source user completion file
2002-03-05 23:23:30 +00:00
[ $BASH_COMPLETION != ~/.bash_completion -a -r ~/.bash_completion ] \
&& . ~/.bash_completion
2001-07-08 23:14:13 +00:00
unset -f have
2002-04-22 05:59:08 +00:00
unset UNAME RELEASE have default dirnames filenames nospace
2002-03-29 02:35:42 +00:00
### Local Variables:
### mode: shell-script
### End: