2001-11-29 00:37:54 +00:00
|
|
|
# bash_completion - some programmable completion functions for bash 2.05a
|
2000-08-08 22:17:29 +00:00
|
|
|
#
|
2002-04-03 16:56:55 +00:00
|
|
|
# $Id: bash_completion,v 1.252 2002/04/03 18:56:55 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.
|
|
|
|
|
2002-04-02 08:04:57 +00:00
|
|
|
# RELEASE: 20020402
|
2002-01-05 20:04:01 +00:00
|
|
|
|
2002-01-23 17:14:19 +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-01-29 22:06:26 +00:00
|
|
|
[ -z "$BASH_COMPLETION" ] && declare -r BASH_COMPLETION=/etc/bash_completion
|
2002-03-11 17:38:17 +00:00
|
|
|
[ -z "$BASH_COMPLETION_DIR" ] && \
|
|
|
|
declare -r BASH_COMPLETION_DIR=/etc/bash_completion.d
|
2002-01-29 20:33:49 +00:00
|
|
|
|
2001-07-08 23:14:13 +00:00
|
|
|
# Set a couple of useful vars
|
|
|
|
#
|
|
|
|
OS=$( uname -s )
|
|
|
|
RELEASE=$( uname -r )
|
2002-04-02 23:37:51 +00:00
|
|
|
[ ${BASH_VERSINFO[1]} = "05b" ] && nospace="-o 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-02-06 04:02:46 +00:00
|
|
|
complete -f -X '!*.bz2' bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
|
2002-02-06 15:54:09 +00:00
|
|
|
complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3)' unzip
|
2002-02-06 04:02:46 +00:00
|
|
|
complete -f -X '*.Z' compress znew
|
2002-02-13 15:46:15 +00:00
|
|
|
complete -f -X '!*.@(Z|gz|tgz|Gz)' gunzip zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
|
2001-12-20 07:52:12 +00:00
|
|
|
complete -f -X '!*.Z' uncompress
|
2002-03-22 03:18:54 +00:00
|
|
|
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|xpm|ico|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|XPM|ICO)' ee display
|
|
|
|
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|xpm|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|XPM)' xv qiv
|
2002-03-26 19:28:01 +00:00
|
|
|
complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ))' 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
|
2000-08-08 22:17:29 +00:00
|
|
|
complete -f -X '!*.texi*' makeinfo texi2dvi texi2html
|
2002-02-13 15:46:15 +00:00
|
|
|
complete -f -X '!*.@(tex|TEX)' tex latex slitex jadetex pdfjadetex pdftex pdflatex
|
2002-02-06 15:54:09 +00:00
|
|
|
complete -f -X '!*.@(mp3|MP3)' mpg123
|
2002-02-14 23:44:21 +00:00
|
|
|
complete -f -X '!*.@(mpg|mpeg|avi|asf|vob|bin|vcd|ps|pes|fli|viv|rm|ram|yuv|mov|wmv)' mplayer
|
2002-02-06 15:54:09 +00:00
|
|
|
complete -f -X '!*.@(avi|asf)' 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
|
|
|
|
complete -f -X '!*.@(mp3|MP3|ogg|OGG|pls)' xmms gqmpeg freeamp
|
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
|
2002-03-22 03:29:30 +00:00
|
|
|
complete -f -X '*.@(o|so|so.*|a|tar|?(t)gz|?(t)bz2|rpm|zip|ZIP|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mpg|MPG|avi|AVI|asf|ASF' vi vim emacs
|
|
|
|
complete -f -X '!*.@(exe|EXE|com|COM)' wine
|
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
|
2002-03-15 19:02:48 +00:00
|
|
|
complete -u finger su usermod userdel passwd chage write talk chfn
|
2000-08-08 22:17:29 +00:00
|
|
|
|
2001-11-29 00:37:54 +00:00
|
|
|
# group commands see only groups
|
2002-04-02 23:37:51 +00:00
|
|
|
[ ${BASH_VERSINFO[1]} '>' 05 ] && complete -g groupmod groupdel
|
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
|
2001-12-05 17:05:49 +00:00
|
|
|
type $1 &> /dev/null
|
2002-02-26 22:59:47 +00:00
|
|
|
[ $? -eq 0 ] && have="yes"
|
2001-07-08 23:14:13 +00:00
|
|
|
}
|
|
|
|
|
2002-03-02 00:13:23 +00:00
|
|
|
# This function performs file and directory completion. It's better than
|
|
|
|
# simply using 'compgen -f', because it honours spaces in filenames
|
|
|
|
#
|
|
|
|
_filedir()
|
|
|
|
{
|
|
|
|
local IFS=$'\t\n'
|
|
|
|
|
|
|
|
_expand || return 0
|
|
|
|
|
|
|
|
if [ "$1" = -d ]; then
|
|
|
|
COMPREPLY=( ${COMPREPLY[@]} $( compgen -d -- $cur ) )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
COMPREPLY=( ${COMPREPLY[@]} $( eval compgen -f -- \"$cur\" ) )
|
|
|
|
}
|
|
|
|
|
|
|
|
# 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()
|
|
|
|
{
|
|
|
|
[ "$cur" != "${cur%\\}" ] && cur="$cur"'\'
|
|
|
|
|
|
|
|
# expand ~username type directory specifications
|
|
|
|
if [[ "$cur" == \~*/* ]]; then
|
|
|
|
eval cur=$cur
|
|
|
|
elif [[ "$cur" == \~* ]]; then
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
COMPREPLY=( $( compgen -W '$( ps axo pid | sed 1d )' -- $cur ) )
|
|
|
|
}
|
|
|
|
|
|
|
|
# This function completes on process group IDs
|
|
|
|
#
|
|
|
|
_pgids()
|
|
|
|
{
|
|
|
|
COMPREPLY=( $( compgen -W '$( ps axo pgid | sed 1d )' -- $cur ) )
|
|
|
|
}
|
|
|
|
|
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=()
|
|
|
|
cur=${COMP_WORDS[$COMP_CWORD]};
|
|
|
|
|
|
|
|
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=()
|
|
|
|
cur=${COMP_WORDS[$COMP_CWORD]};
|
|
|
|
|
|
|
|
case "$COMP_LINE" in
|
|
|
|
*[^=])
|
|
|
|
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-03-05 23:23:30 +00:00
|
|
|
complete -F _export -o default 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
|
|
|
|
|
|
|
|
# start of section containing completion functions for external programs
|
|
|
|
|
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
|
|
|
|
|
|
|
# do not attempt completion if we're specifying an option
|
2002-02-26 23:13:04 +00:00
|
|
|
[[ "$cur" == -* ]] && return 0
|
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]*[.:]* ]] && \
|
|
|
|
[ ${BASH_VERSINFO[1]} '>' 05 ]; then
|
2002-03-26 15:17:12 +00:00
|
|
|
user=${cur%%?(\\)[.:]*}
|
|
|
|
group=${cur#*[.:]}
|
|
|
|
COMPREPLY=( $( compgen -P $user'\:' -g -- $group ) )
|
2000-08-29 00:41:27 +00:00
|
|
|
else
|
2002-03-26 15:17:12 +00:00
|
|
|
COMPREPLY=( $( compgen -S '\:' -u $cur ) )
|
2000-08-29 00:41:27 +00:00
|
|
|
fi
|
2000-08-08 22:17:29 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
2001-05-21 20:10:29 +00:00
|
|
|
complete -F _chown -o default 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]}
|
|
|
|
|
|
|
|
# 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
|
|
|
|
[ ${BASH_VERSINFO[1]} '>' 05 ] && \
|
|
|
|
COMPREPLY=( $( compgen -g $cur ) )
|
|
|
|
else
|
2002-01-24 04:03:26 +00:00
|
|
|
_expand || return 0
|
2002-01-08 04:49:06 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
complete -F _chgrp -o default chgrp
|
|
|
|
|
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 16:56:01 +00:00
|
|
|
complete -F _umount -o dirnames umount
|
2000-08-08 22:17:29 +00:00
|
|
|
|
|
|
|
# mount(8) completion. This will pull a list of possible mounts out of
|
|
|
|
# /etc/fstab, unless the word being completed contains a ':', which
|
|
|
|
# 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-01-03 00:16:41 +00:00
|
|
|
{ local cur i sm
|
2000-08-08 22:17:29 +00:00
|
|
|
|
2001-12-18 03:43:25 +00:00
|
|
|
COMPREPLY=()
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
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}' ) )
|
2000-08-29 00:41:27 +00:00
|
|
|
else
|
2000-08-08 22:17:29 +00:00
|
|
|
COMPREPLY=( $( awk '{if ($2 ~ /\//) print $2}' /etc/fstab | \
|
2000-10-09 18:07:50 +00:00
|
|
|
grep ^$cur ) )
|
2000-08-29 00:41:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
2000-08-08 22:17:29 +00:00
|
|
|
}
|
2001-07-09 00:55:01 +00:00
|
|
|
complete -F _mount -o default mount
|
2000-08-08 22:17:29 +00:00
|
|
|
|
|
|
|
# Linux rmmod(1) completion. This completes on a list of all currently
|
|
|
|
# installed kernel modules.
|
|
|
|
#
|
2001-07-08 23:14:13 +00:00
|
|
|
[ $OS = Linux ] &&
|
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 | \
|
2001-01-31 22:30:49 +00:00
|
|
|
awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' ) )
|
2000-08-08 22:17:29 +00:00
|
|
|
return 0
|
|
|
|
}
|
2001-07-08 23:14:13 +00:00
|
|
|
[ $OS = Linux ] && complete -F _rmmod rmmod
|
2000-08-08 22:17:29 +00:00
|
|
|
|
2001-03-05 19:12:48 +00:00
|
|
|
# Linux insmod(8) & modprobe(8) completion. This completes on a list of all
|
2000-08-08 22:17:29 +00:00
|
|
|
# available modules for the version of the kernel currently running.
|
|
|
|
#
|
2001-07-08 23:14:13 +00:00
|
|
|
[ $OS = Linux ] &&
|
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
|
2001-12-18 03:43:25 +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-01-08 04:49:06 +00:00
|
|
|
COMPREPLY=( $( \ls -R $modpath | \
|
2002-03-29 02:35:42 +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
|
|
|
|
}
|
2001-07-09 00:55:01 +00:00
|
|
|
[ $OS = Linux ] && complete -F _insmod -o filenames insmod modprobe
|
2000-08-08 22:17:29 +00:00
|
|
|
|
2002-03-02 00:56:21 +00:00
|
|
|
# man(1) completion. This is Linux and Darwin specific, in that
|
|
|
|
# 'man <section> <page>' is the expected syntax.
|
2000-08-08 22:17:29 +00:00
|
|
|
#
|
2002-03-02 00:56:21 +00:00
|
|
|
[ $OS = Linux -o $OS = Darwin ] &&
|
2000-08-29 00:41:27 +00:00
|
|
|
_man()
|
2000-08-08 22:17:29 +00:00
|
|
|
{
|
2002-03-02 00:56:21 +00:00
|
|
|
local cur prev sect manpath OS
|
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-03-02 00:56:21 +00:00
|
|
|
OS=$( uname -s )
|
|
|
|
if [ $OS = Linux ]; then
|
2002-03-06 17:38:37 +00:00
|
|
|
manpath=$( manpath 2>/dev/null || 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
|
|
|
|
[[ "$prev" == [0-9ln] ]] && sect=$prev || sect='?'
|
2002-02-14 22:39:04 +00:00
|
|
|
|
|
|
|
manpath=$manpath:
|
|
|
|
if [ -n "$cur" ]; then
|
|
|
|
manpath="${manpath//://man$sect/$cur* }"
|
|
|
|
else
|
|
|
|
manpath="${manpath//://man$sect/ }"
|
|
|
|
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-03-13 06:29:52 +00:00
|
|
|
COMPREPLY=( $( eval \\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)} )
|
|
|
|
COMPREPLY=( ${COMPREPLY[@]%.*} )
|
|
|
|
|
|
|
|
if [[ "$prev" != [0-9ln] ]]; then
|
2002-02-26 22:59:47 +00:00
|
|
|
COMPREPLY=( ${COMPREPLY[@]} $( compgen -d -- $cur ) \
|
|
|
|
$( compgen -f -X '!*.[0-9ln]' -- $cur ) )
|
2001-12-18 03:43:25 +00:00
|
|
|
fi
|
2000-08-29 00:41:27 +00:00
|
|
|
|
|
|
|
return 0
|
2000-08-08 22:17:29 +00:00
|
|
|
}
|
2002-03-02 00:56:21 +00:00
|
|
|
[ $OS = Linux -o $OS = Darwin ] && complete -F _man -o 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
|
|
|
|
# walk back throuh command line and find last option
|
|
|
|
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-03-24 00:34:33 +00:00
|
|
|
[ $OS = Linux -o $OS = 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-03-24 18:57:37 +00:00
|
|
|
COMPREPLY=( $( compgen -W '$( 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-03-24 00:34:33 +00:00
|
|
|
[ $OS = Linux -o $OS = 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-03-23 21:59:49 +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)
|
2002-04-02 23:37:51 +00:00
|
|
|
[ ${BASH_VERSINFO[1]} '>' 05 ] && \
|
|
|
|
COMPREPLY=( $( compgen -g -- $cur ) )
|
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
|
|
|
|
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-02-06 17:41:06 +00:00
|
|
|
complete -F _find -o filenames find
|
2000-08-08 22:17:29 +00:00
|
|
|
|
|
|
|
# Linux ifconfig(8) completion
|
|
|
|
#
|
2001-07-08 23:14:13 +00:00
|
|
|
[ $OS = Linux ] &&
|
2000-08-29 00:41:27 +00:00
|
|
|
_ifconfig()
|
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
|
|
|
|
|
|
|
case "${COMP_WORDS[1]}" in
|
|
|
|
-|*[0-9]*)
|
|
|
|
COMPREPLY=( $( compgen -W '-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' $cur ))
|
|
|
|
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
|
2001-12-18 03:43:25 +00:00
|
|
|
echo ${COMPREPLY[@]})
|
2000-08-08 22:17:29 +00:00
|
|
|
) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2002-02-26 23:35:39 +00:00
|
|
|
COMPREPLY=( $( /sbin/ifconfig -a | \
|
2002-03-01 00:42:13 +00:00
|
|
|
sed -ne 's|^\('$cur'[^ ]*\).*$|\1|p' ))
|
2000-08-08 22:17:29 +00:00
|
|
|
}
|
2001-07-08 23:14:13 +00:00
|
|
|
[ $OS = Linux ] && complete -F _ifconfig ifconfig
|
2000-08-08 22:17:29 +00:00
|
|
|
|
2002-01-29 22:06:26 +00:00
|
|
|
# RedHat & Debian Linux if{up,down} completion
|
2002-01-08 00:33:08 +00:00
|
|
|
#
|
|
|
|
[ $OS = Linux ] && ( have ifup || have ifdown ) &&
|
|
|
|
_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-03-01 00:42:13 +00:00
|
|
|
COMPREPLY=( $( \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
|
|
|
|
}
|
|
|
|
[ $OS = Linux ] && have ifup && complete -F _ifupdown ifup ifdown
|
|
|
|
|
2000-10-09 18:07:50 +00:00
|
|
|
# Linux ipsec(8) completion (for FreeS/WAN). Basic.
|
2000-08-08 22:17:29 +00:00
|
|
|
#
|
2001-07-08 23:14:13 +00:00
|
|
|
[ $OS = 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
|
|
|
}
|
2001-07-09 00:55:01 +00:00
|
|
|
[ $OS = Linux ] && [ "$have" ] && complete -F _ipsec ipsec
|
2000-08-11 21:20:41 +00:00
|
|
|
|
2000-08-29 00:41:27 +00:00
|
|
|
# cvs(1) completion
|
|
|
|
#
|
2002-02-18 10:09:59 +00:00
|
|
|
have cvs &&
|
2000-08-29 00:41:27 +00:00
|
|
|
_cvs()
|
2000-08-11 21:20:41 +00:00
|
|
|
{
|
2002-02-28 22:23:14 +00:00
|
|
|
set_prefix()
|
|
|
|
{
|
2002-03-01 06:58:23 +00:00
|
|
|
[ -z "$prefix" ] || prefix=${cur%/*}/
|
2002-02-28 22:23:14 +00:00
|
|
|
[ -r ${prefix}CVS/Entries ] || prefix=""
|
|
|
|
}
|
|
|
|
|
|
|
|
get_entries()
|
|
|
|
{
|
|
|
|
entries=( $( cut -d/ -f2 -s ${prefix}CVS/Entries | \
|
|
|
|
grep "^$cur" ) )
|
|
|
|
}
|
|
|
|
|
2002-03-01 18:29:34 +00:00
|
|
|
get_modules()
|
|
|
|
{
|
|
|
|
if [ -n "$prefix" ]; then
|
|
|
|
COMPREPLY=( $( \ls -d ${cvsroot}/${prefix}/!(CVSROOT) ))
|
|
|
|
else
|
|
|
|
COMPREPLY=( $( \ls -d ${cvsroot}/!(CVSROOT) ) )
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2002-04-02 17:22:40 +00:00
|
|
|
local cur count mode i cvsroot 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-02-28 22:23:14 +00:00
|
|
|
count=1
|
|
|
|
for i in ${COMP_WORDS[@]}; do
|
|
|
|
[ $count -eq $COMP_CWORD ] && break
|
|
|
|
if [ -z "$mode" ]; then
|
|
|
|
case $i in
|
|
|
|
-d)
|
|
|
|
cvsroot=${COMP_WORDS[((++count))]}
|
|
|
|
;;
|
|
|
|
@(add|new))
|
|
|
|
mode=add
|
|
|
|
;;
|
|
|
|
@(admin|rcs))
|
|
|
|
mode=admin
|
|
|
|
;;
|
|
|
|
@(checkout|co|get))
|
|
|
|
mode=checkout
|
|
|
|
;;
|
|
|
|
@(commit|ci))
|
|
|
|
mode=commit
|
|
|
|
;;
|
|
|
|
@(diff|@(ex|im)port|history|release|status|update))
|
|
|
|
mode=$i
|
|
|
|
;;
|
|
|
|
?(r)log)
|
|
|
|
mode=log
|
|
|
|
;;
|
|
|
|
@(rdiff|patch))
|
|
|
|
mode=rdiff
|
|
|
|
;;
|
|
|
|
@(remove|rm|delete))
|
|
|
|
mode=remove
|
|
|
|
;;
|
|
|
|
@(rtag|rfreeze))
|
|
|
|
mode=rtag
|
|
|
|
;;
|
|
|
|
@(tag|freeze))
|
|
|
|
mode=tag
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
continue
|
|
|
|
elif [[ "$i" = -* ]]; then
|
|
|
|
flags=( ${flags[@]} $i )
|
|
|
|
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
|
|
|
|
if [ $COMP_CWORD -gt 1 -a -r ${prefix}CVS/Entries ]; then
|
|
|
|
get_entries
|
|
|
|
[ -z "$cur" ] && \
|
2002-03-01 06:58:23 +00:00
|
|
|
files=$( \ls -A | grep -v '^CVS$' ) || \
|
2002-02-28 22:23:14 +00:00
|
|
|
files=$( \ls -d ${cur}* )
|
|
|
|
for i in ${entries[@]}; do
|
2002-03-01 06:58:23 +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-02-28 22:23:14 +00:00
|
|
|
# can only do for local repositories
|
|
|
|
[ -z "$cvsroot" ] && cvsroot=$CVSROOT
|
2002-03-01 06:58:23 +00:00
|
|
|
prefix=${cur%/*}
|
|
|
|
[ -r ${cvsroot}/${prefix} ] || prefix=""
|
|
|
|
if [ -r ${cvsroot}/${prefix} ]; then
|
2002-03-01 18:29:34 +00:00
|
|
|
get_modules
|
2002-03-01 06:58:23 +00:00
|
|
|
COMPREPLY=( ${COMPREPLY[@]#$cvsroot} )
|
|
|
|
COMPREPLY=( ${COMPREPLY[@]#/} )
|
2002-02-28 22:23:14 +00:00
|
|
|
COMPREPLY=( $( compgen -W \
|
2002-03-01 06:58:23 +00:00
|
|
|
'${COMPREPLY[@]}' -- $cur ) )
|
2002-02-28 22:23:14 +00:00
|
|
|
fi
|
|
|
|
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
|
|
|
|
2002-02-28 22:23:14 +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
|
|
|
|
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' ) )
|
|
|
|
COMPREPLY=( $( compgen -W '${changed[@]} \
|
2002-03-01 06:58:23 +00:00
|
|
|
${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
|
|
|
|
;;
|
|
|
|
remove)
|
2002-03-01 06:58:23 +00:00
|
|
|
if [[ "$cur" != -* ]]; then
|
2002-02-28 22:23:14 +00:00
|
|
|
set_prefix
|
|
|
|
if [ $COMP_CWORD -gt 1 -a -r ${prefix}CVS/Entries ]; then
|
|
|
|
get_entries
|
|
|
|
# find out what files are missing
|
|
|
|
for i in ${entries[@]}; do
|
|
|
|
[ ! -r "$i" ] && miss=( ${miss[@]} $i )
|
|
|
|
done
|
2002-03-01 06:58:23 +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-02-28 22:23:14 +00:00
|
|
|
COMPREPLY=( $( compgen -W 'add admin checkout ci co commit \
|
|
|
|
diff delete export freeze get \
|
|
|
|
history import log new patch rcs \
|
|
|
|
rdiff release remove rfreeze rlog \
|
|
|
|
rm rtag status tag update -H -Q -q \
|
|
|
|
-b -d -e -f -l -n -t -r -v -w -x \
|
|
|
|
-z --help --version' -- $cur ) )
|
|
|
|
;;
|
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-02-18 10:09:59 +00:00
|
|
|
[ "$have" ] && complete -F _cvs -o default cvs
|
2000-08-11 21:20:41 +00:00
|
|
|
|
2002-02-27 00:14:52 +00:00
|
|
|
# rpm(8) completion
|
2000-08-29 00:41:27 +00:00
|
|
|
#
|
2001-07-08 23:14:13 +00:00
|
|
|
have rpm &&
|
2000-08-11 21:20:41 +00:00
|
|
|
_rpm()
|
|
|
|
{
|
2002-03-29 07:30:47 +00:00
|
|
|
installed_packages()
|
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-02-04 18:11:42 +00:00
|
|
|
if [ -r /var/log/rpmpkgs -a \
|
|
|
|
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]; then
|
2001-12-20 07:52:12 +00:00
|
|
|
# using RHL 7.2 - this is quicker than querying the DB
|
2002-03-29 07:30:47 +00:00
|
|
|
COMPREPLY=( $( sed -ne \
|
|
|
|
's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.]\+.*\.rpm$|\1|p' \
|
|
|
|
/var/log/rpmpkgs ) )
|
2001-11-04 23:11:48 +00:00
|
|
|
else
|
2002-03-29 07:30:47 +00:00
|
|
|
COMPREPLY=( $( rpm -qa | sed -ne \
|
|
|
|
's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.]\+$|\1|p' ) )
|
2001-11-04 23:11:48 +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
|
|
|
}
|
|
|
|
|
2000-12-19 19:54:49 +00:00
|
|
|
file_glob()
|
|
|
|
{
|
2002-01-23 23:41:00 +00:00
|
|
|
_expand || return 0
|
2002-03-29 07:30:47 +00:00
|
|
|
COMPREPLY=( $( compgen -f -X "!*.$1" -- $cur ) \
|
|
|
|
$( compgen -d -- $cur ) )
|
2002-03-07 16:16:43 +00:00
|
|
|
}
|
|
|
|
|
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 \
|
|
|
|
--verify --querytags --rmsource --rmspec --clean' -- \
|
|
|
|
$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
|
|
|
|
file_glob spec
|
|
|
|
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 \
|
|
|
|
'%{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' | \
|
|
|
|
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 \
|
|
|
|
--eval --pipe --queryformat --repackage' -- $cur ) )
|
|
|
|
else
|
|
|
|
file_glob rpm
|
|
|
|
fi
|
2000-08-11 21:20:41 +00:00
|
|
|
;;
|
|
|
|
-*f)
|
2002-02-27 15:48:20 +00:00
|
|
|
_filedir
|
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
|
|
|
|
installed_packages
|
|
|
|
fi
|
2000-08-11 21:20:41 +00:00
|
|
|
;;
|
2002-03-29 07:30:47 +00:00
|
|
|
-@(q*|-query))
|
2002-03-07 16:16:43 +00:00
|
|
|
# check whether we're querying installed or uninstalled
|
|
|
|
if [ "${COMP_LINE#*-*([^ ])p}" != "$COMP_LINE" ]; then
|
|
|
|
# there's a -p on the line
|
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 \
|
|
|
|
--conflicts --obsoletes' -- $cur ) )
|
|
|
|
else
|
|
|
|
file_glob rpm
|
|
|
|
fi
|
2002-03-07 16:16:43 +00:00
|
|
|
else
|
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 \
|
|
|
|
--fileid --tid' -- $cur ) )
|
|
|
|
elif [ "${COMP_LINE#*-*([^ ])a}" == "$COMP_LINE" ]; then
|
|
|
|
installed_packages
|
|
|
|
fi
|
2002-03-07 16:16:43 +00:00
|
|
|
fi
|
2001-08-22 15:20:27 +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
|
|
|
-@(K|-checksig))
|
2002-03-29 07:30:47 +00:00
|
|
|
if [[ "$cur" == -* ]]; then
|
|
|
|
COMPREPLY=( $( compgen -W '--nopgp --nogpg --nomd5' \
|
|
|
|
-- $cur ) )
|
|
|
|
else
|
|
|
|
file_glob rpm
|
|
|
|
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 \
|
|
|
|
--specfile --whatrequires --whatprovides' -- $cur ) )
|
|
|
|
elif [ "${COMP_LINE#*-*([^ ])p}" != "$COMP_LINE" ]; then
|
2002-03-22 15:45:42 +00:00
|
|
|
file_glob rpm
|
|
|
|
else
|
2002-03-29 07:30:47 +00:00
|
|
|
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
|
2000-12-19 19:54:49 +00:00
|
|
|
file_glob 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-02-19 21:49:13 +00:00
|
|
|
file_glob '@(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
|
|
|
|
file_glob src.rpm
|
|
|
|
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-02-19 21:49:13 +00:00
|
|
|
file_glob '@(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)
|
2000-12-19 19:54:49 +00:00
|
|
|
file_glob rpm
|
2000-08-11 21:20:41 +00:00
|
|
|
;;
|
|
|
|
--set@(perms|gids))
|
2002-03-29 07:30:47 +00:00
|
|
|
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
|
|
|
|
file_glob spec
|
|
|
|
fi
|
2000-12-20 02:04:54 +00:00
|
|
|
;;
|
2001-03-05 19:12:48 +00:00
|
|
|
-*g)
|
|
|
|
# package group completion
|
2001-12-20 07:52:12 +00:00
|
|
|
local IFS=$'\t'
|
2001-03-05 19:12:48 +00:00
|
|
|
# remove trailing backslash, or grep will complain
|
|
|
|
cur=${cur%'\'}
|
|
|
|
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' ) )
|
|
|
|
;;
|
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
|
|
|
}
|
2001-07-09 00:55:01 +00:00
|
|
|
[ "$have" ] && complete -F _rpm -o filenames rpm
|
2000-08-11 21:20:41 +00:00
|
|
|
|
2000-10-09 18:07:50 +00:00
|
|
|
# Debian Linux apt-get(8) completion.
|
|
|
|
#
|
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
|
|
|
|
if [[ ${COMP_WORDS[i]} == @(install|remove|source) ]]; then
|
|
|
|
special=${COMP_WORDS[i]}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -n "$special" ]; then
|
|
|
|
case $special in
|
|
|
|
@(install|remove|source))
|
|
|
|
COMPREPLY=( $( apt-cache pkgnames $cur ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$prev" == -*c ]] || [ "$prev" = --config-file ]; then
|
2002-02-27 15:48:20 +00:00
|
|
|
_filedir
|
2000-10-09 18:07:50 +00:00
|
|
|
else
|
|
|
|
COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \
|
|
|
|
dist-upgrade install remove source check \
|
|
|
|
clean autoclean -d -f -h -v -m -q -s -y -u \
|
|
|
|
-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 \
|
|
|
|
--compile --build --ignore-hold \
|
|
|
|
--no-upgrade --force-yes --print-uris \
|
|
|
|
--purge --reinstall --list-cleanup \
|
|
|
|
--trivial-only --no-remove --diff-only \
|
2002-02-27 00:24:04 +00:00
|
|
|
--tar-only --config-file --option' -- $cur ) )
|
2000-10-09 18:07:50 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
2002-02-27 00:24:04 +00:00
|
|
|
[ "$have" ] && complete -F _apt_get -o filenames apt-get
|
2000-10-09 18:07:50 +00:00
|
|
|
|
|
|
|
# Debian Linux apt-cache(8) completion.
|
|
|
|
#
|
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
|
|
|
|
|
|
|
|
|
|
|
for (( i=0; i < ${#COMP_WORDS}-1; i++ )); do
|
2002-02-11 05:06:19 +00:00
|
|
|
if [[ ${COMP_WORDS[i]} == @(add|show?(pkg)|depends|dotty) ]]; then
|
2000-10-09 18:07:50 +00:00
|
|
|
special=${COMP_WORDS[i]}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -n "$special" ]; then
|
|
|
|
case $special in
|
|
|
|
add)
|
2002-02-27 15:48:20 +00:00
|
|
|
_filedir
|
2000-10-09 18:07:50 +00:00
|
|
|
return 0
|
|
|
|
;;
|
2002-02-11 05:06:19 +00:00
|
|
|
show?(pkg)|depends|dotty)
|
2000-10-09 18:07:50 +00:00
|
|
|
COMPREPLY=( $( apt-cache pkgnames $cur ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [[ "$prev" == -*c ]] || [ "$prev" = --config-file ]; then
|
2002-02-27 15:48:20 +00:00
|
|
|
_filedir
|
2000-10-09 18:07:50 +00:00
|
|
|
else
|
|
|
|
COMPREPLY=( $( compgen -W 'add gencaches showpkg stats dump \
|
2002-02-11 05:06:19 +00:00
|
|
|
dumpavail unmet check search show dotty \
|
2000-10-09 18:07:50 +00:00
|
|
|
depends pkgnames -h -v -p -s -q -i -f -a -g -c \
|
|
|
|
-o --help --version --pkg-cache --src-cache \
|
|
|
|
--quiet --important --full --all-versions \
|
|
|
|
--no-generate --names-only --all-names \
|
2002-02-27 00:24:04 +00:00
|
|
|
--config-file --option' -- $cur ) )
|
2000-10-09 18:07:50 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
2001-07-09 00:55:01 +00:00
|
|
|
[ "$have" ] && complete -F _apt-cache -o filenames apt-cache
|
2002-02-27 00:24:04 +00:00
|
|
|
complete -F _apt_cache -o filenames apt-cache
|
2000-10-09 18:07:50 +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
|
|
|
|
COMPREPLY=( $( chsh -l | grep ^$cur ) )
|
|
|
|
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
|
|
|
}
|
2001-07-09 00:55:01 +00:00
|
|
|
[ "$have" ] && complete -F _chkconfig chkconfig
|
2000-08-11 21:20:41 +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-02-28 22:23:14 +00:00
|
|
|
local cur user suffix
|
|
|
|
local -a kh
|
2000-08-29 00:41:27 +00:00
|
|
|
|
2001-12-18 03:43:25 +00:00
|
|
|
COMPREPLY=()
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
2002-02-11 02:14:08 +00:00
|
|
|
[ "$1" = -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
|
|
|
|
2001-03-05 19:12:48 +00:00
|
|
|
[ -r /etc/known_hosts ] && kh[0]=/etc/known_hosts
|
|
|
|
[ -r /etc/known_hosts2 ] && kh[1]=/etc/known_hosts2
|
|
|
|
[ -r ~/.ssh/known_hosts ] && kh[2]=~/.ssh/known_hosts
|
|
|
|
[ -r ~/.ssh/known_hosts2 ] && kh[3]=~/.ssh/known_hosts2
|
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//\./\\\.}
|
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
|
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} \
|
|
|
|
}}' ${kh[@]} ) )
|
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-02-13 18:23:52 +00:00
|
|
|
complete -F _known_hosts traceroute ping fping telnet host nslookup rsh \
|
|
|
|
rlogin ftp
|
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
|
|
|
#
|
2001-07-08 23:14:13 +00:00
|
|
|
have ssh &&
|
2000-09-25 21:38:11 +00:00
|
|
|
_ssh()
|
|
|
|
{
|
2001-12-05 16:32:24 +00:00
|
|
|
local cur prev
|
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
|
|
|
;;
|
|
|
|
-*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
|
|
|
*)
|
|
|
|
_known_hosts
|
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-01-16 07:14:14 +00:00
|
|
|
[ "$have" ] && 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
|
|
|
have scp &&
|
|
|
|
_scp()
|
|
|
|
{
|
2002-03-15 06:20:04 +00:00
|
|
|
local cur userhost path
|
2000-09-25 21:38:11 +00:00
|
|
|
|
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#*:}
|
|
|
|
if [ -z "$path" ]; then
|
|
|
|
# default to home dir of specified user on remote host
|
|
|
|
path=$( ssh -o 'Batchmode yes' $userhost pwd )
|
|
|
|
fi
|
|
|
|
COMPREPLY=( $( compgen -P "$userhost:" \
|
|
|
|
-W "`echo $( ssh -o 'Batchmode yes' $userhost \
|
2002-03-31 23:12:50 +00:00
|
|
|
compgen -f -- $path 2>/dev/null)`"))
|
2002-03-15 06:20:04 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2002-02-11 02:14:08 +00:00
|
|
|
[[ "$cur" == */* ]] || _known_hosts -c
|
2002-02-04 18:07:33 +00:00
|
|
|
_filedir
|
2000-09-25 21:38:11 +00:00
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
2001-12-05 16:32:24 +00:00
|
|
|
[ "$have" ] && complete -o filenames -F _scp scp
|
2001-11-20 04:15:48 +00:00
|
|
|
|
2002-03-15 16:39:18 +00:00
|
|
|
# Linux route(8) completion
|
2000-09-11 18:46:39 +00:00
|
|
|
#
|
2002-02-18 17:26:54 +00:00
|
|
|
[ $OS = 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-02-27 00:41:56 +00:00
|
|
|
window irtt reject mod dyn reinstate dev' \
|
|
|
|
-- $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-02-18 17:26:54 +00:00
|
|
|
[ $OS = 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
|
|
|
|
|
|
|
|
# make reads `makefile' before `Makefile'
|
|
|
|
if [ -f makefile ]; then
|
|
|
|
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
|
|
|
|
|
|
|
|
# if we don't want to use *.mk, we can take out the cat and use
|
|
|
|
# test -f $makef and input redirection
|
|
|
|
COMPREPLY=( $( cat $makef 2>/dev/null | \
|
2000-09-25 21:38:11 +00:00
|
|
|
awk 'BEGIN {FS=":"} /^[^.# ][^=]*:/ {print $1}' | \
|
|
|
|
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
|
|
|
|
}
|
2002-02-18 17:26:54 +00:00
|
|
|
[ "$have" ] && complete -F _make -X '+($*|*.[cho])' -o filenames make gmake pmake
|
2001-01-10 23:09:48 +00:00
|
|
|
|
|
|
|
# Red Hat Linux service completion. This completes on a list of all available
|
|
|
|
# service scripts in the SysV init.d directory, followed by that script's
|
|
|
|
# available commands
|
|
|
|
#
|
2001-07-08 23:14:13 +00:00
|
|
|
have service &&
|
2001-01-10 23:09:48 +00:00
|
|
|
_service()
|
|
|
|
{
|
|
|
|
local cur sysvdir
|
|
|
|
|
2001-12-18 03:43:25 +00:00
|
|
|
COMPREPLY=()
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
2001-01-10 23:09:48 +00:00
|
|
|
|
2001-03-05 19:12:48 +00:00
|
|
|
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
|
|
|
|
|| sysvdir=/etc/init.d
|
2001-01-10 23:09:48 +00:00
|
|
|
|
|
|
|
#[[ "$cur" == -* ]] && return 0
|
2002-02-26 22:59:47 +00:00
|
|
|
if [ $COMP_CWORD -eq 1 ]; then
|
2001-01-10 23:09:48 +00:00
|
|
|
COMPREPLY=( $( compgen -W '`echo $sysvdir/!(*.rpmsave|*.rpmorig)`' ) )
|
2002-02-27 01:02:43 +00:00
|
|
|
COMPREPLY=( $( compgen -W '${COMPREPLY[@]#$sysvdir/}' -- \
|
|
|
|
$cur ) )
|
2001-01-10 23:09:48 +00:00
|
|
|
else
|
|
|
|
COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
|
|
|
|
s/^.*Usage.*{\(.*\)}.*$/\1/p" \
|
2002-02-27 01:02:43 +00:00
|
|
|
$sysvdir/${COMP_WORDS[1]}`' -- \
|
|
|
|
$cur ) )
|
2001-01-10 23:09:48 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
2001-07-09 00:55:01 +00:00
|
|
|
[ "$have" ] && complete -F _service service
|
2001-07-08 23:14:13 +00:00
|
|
|
|
2002-03-19 15:19:58 +00:00
|
|
|
# GNU tar(1) completion
|
2001-07-08 23:14:13 +00:00
|
|
|
#
|
|
|
|
_tar()
|
|
|
|
{
|
|
|
|
local cur
|
|
|
|
|
2001-12-18 03:43:25 +00:00
|
|
|
COMPREPLY=()
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
2001-07-08 23:14:13 +00:00
|
|
|
|
2002-03-07 17:47:12 +00:00
|
|
|
if [ $COMP_CWORD = 1 ]; then
|
|
|
|
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
|
|
|
|
c*f)
|
|
|
|
_filedir
|
|
|
|
;;
|
2002-03-26 15:27:02 +00:00
|
|
|
+([^Izjy])f)
|
2002-02-27 01:02:43 +00:00
|
|
|
COMPREPLY=( $( compgen -d -- $cur ) \
|
|
|
|
$( compgen -f -X '!*.tar' -- $cur ) )
|
2002-02-18 18:21:14 +00:00
|
|
|
;;
|
|
|
|
*z*f)
|
2002-02-27 01:02:43 +00:00
|
|
|
COMPREPLY=( $( compgen -d -- $cur ) \
|
|
|
|
$( compgen -f -X '!*.t?(ar.)gz' -- $cur ) )
|
2002-02-18 18:21:14 +00:00
|
|
|
;;
|
2002-03-26 15:27:02 +00:00
|
|
|
*[Ijy]*f)
|
2002-02-27 01:02:43 +00:00
|
|
|
COMPREPLY=( $( compgen -d -- $cur ) \
|
|
|
|
$( compgen -f -X '!*.tar.bz2' -- $cur ) )
|
2002-02-18 18:21:14 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_filedir
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
2001-07-08 23:14:13 +00:00
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
2002-02-18 18:21:14 +00:00
|
|
|
complete -F _tar -o 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
|
|
|
|
c*f)
|
|
|
|
_filedir
|
|
|
|
;;
|
|
|
|
*f)
|
|
|
|
COMPREPLY=( $( compgen -d -- $cur ) \
|
|
|
|
$( compgen -f -X '!*.jar' -- $cur ) )
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_filedir
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _jar -o filenames jar
|
|
|
|
|
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
|
|
|
|
|
|
|
|
}
|
|
|
|
[ "$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
|
|
|
|
|
|
|
}
|
2001-07-09 00:55:01 +00:00
|
|
|
[ "$have" ] && complete -F _tcpdump tcpdump
|
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-04-03 05:11:06 +00:00
|
|
|
local IFS=$'\t\n' cur=${COMP_WORDS[COMP_CWORD]} dirs=() i
|
2001-03-05 19:12:48 +00:00
|
|
|
|
2002-01-23 23:13:21 +00:00
|
|
|
_expand || return 0
|
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 ../
|
|
|
|
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-03-29 02:43:09 +00:00
|
|
|
IFS=$'\t'
|
|
|
|
# we have a CDPATH, so loop on its contents
|
|
|
|
for i in ${CDPATH//:/$'\t'}; do
|
|
|
|
# create an array of matched subdirs
|
|
|
|
dirs=( $( compgen -d $i/$cur ) )
|
|
|
|
# add subdirs to list of completions as necessary
|
|
|
|
[ ${#dirs[@]} ] && COMPREPLY=( ${COMPREPLY[@]} ${dirs[@]#$i/})
|
|
|
|
done
|
2002-02-27 15:48:20 +00:00
|
|
|
_filedir -d
|
2002-04-03 05:11:06 +00:00
|
|
|
IFS=$' \t\n'
|
2002-03-28 22:41:44 +00:00
|
|
|
if [ -n "$CDPATH" ]; then
|
|
|
|
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
|
|
|
|
# remove leading ./ from completions
|
|
|
|
COMPREPLY[i]=${COMPREPLY[i]#.\/}
|
|
|
|
# turn relative paths from current dir into
|
|
|
|
# absolute ones
|
2002-04-03 05:11:06 +00:00
|
|
|
[ -d ./"${COMPREPLY[i]}" ] && \
|
2002-03-28 22:41:44 +00:00
|
|
|
COMPREPLY[i]=$PWD/${COMPREPLY[i]}
|
|
|
|
done
|
|
|
|
fi
|
2001-03-05 19:12:48 +00:00
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
2002-04-02 23:37:51 +00:00
|
|
|
complete -F _cd $nospace -o filenames cd
|
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()
|
|
|
|
{
|
|
|
|
local cur func cline cspec
|
|
|
|
|
|
|
|
COMPREPLY=()
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# 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
|
|
|
|
COMP_WORDS=( $cline )
|
2002-04-01 16:50:05 +00:00
|
|
|
# set current token number to 1 less than expanded line
|
|
|
|
COMP_CWORD=$(( ${#COMP_WORDS[@]} - 1 ))
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
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
|
2002-01-18 15:54:22 +00:00
|
|
|
}
|
2002-03-24 18:44:55 +00:00
|
|
|
complete -F _command -o filenames nohup exec nice eval strace time
|
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-03-26 19:28:58 +00:00
|
|
|
complete -F _root_command -o 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)
|
|
|
|
COMPREPLY=( $( compgen -f -X '!*.xml' -- $cur ) \
|
|
|
|
$( compgen -d -- $cur ) )
|
|
|
|
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
|
|
|
|
# find wich buildfile to use
|
|
|
|
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}' \
|
|
|
|
$buildfile | grep ^$cur ) )
|
2002-03-07 17:32:03 +00:00
|
|
|
fi
|
2001-12-11 20:25:53 +00:00
|
|
|
}
|
2002-03-07 17:32:03 +00:00
|
|
|
[ "$have" ] && complete -F _ant -o 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
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _nslookup nslookup
|
|
|
|
|
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
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _mysqladmin mysqladmin
|
|
|
|
|
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]}
|
|
|
|
|
|
|
|
[ ${COMP_WORDS[0]} = "gzip" ] && xspec="*.gz"
|
|
|
|
[ ${COMP_WORDS[0]} = "bzip2" ] && xspec="*.bz2"
|
|
|
|
[[ "$prev" == -*d* ]] && xspec="!"$xspec
|
|
|
|
|
|
|
|
_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
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _zip -o filenames gzip bzip2
|
|
|
|
|
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
|
|
|
}
|
|
|
|
[ $have ] && complete -F _openssl -o default openssl
|
|
|
|
|
|
|
|
# screen(1) completion
|
|
|
|
#
|
|
|
|
have screen &&
|
|
|
|
_screen()
|
|
|
|
{
|
|
|
|
local cur prev
|
|
|
|
|
|
|
|
COMPREPLY=()
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
|
|
|
|
case "$prev" in
|
|
|
|
-[rR])
|
|
|
|
# list detached
|
2002-03-01 00:42:13 +00:00
|
|
|
COMPREPLY=( $( \screen -ls | sed -ne 's|^['$'\t'']\+\('$cur'[^'$'\t'']\+\).*Detached.*$|\1|p' ) )
|
2002-02-04 02:12:10 +00:00
|
|
|
;;
|
|
|
|
-[dDx])
|
|
|
|
# list attached
|
2002-03-01 00:42:13 +00:00
|
|
|
COMPREPLY=( $( \screen -ls | sed -ne 's|^['$'\t'']\+\('$cur'[^'$'\t'']\+\).*Attached.*$|\1|p' ) )
|
2002-02-04 02:12:10 +00:00
|
|
|
;;
|
|
|
|
-s)
|
|
|
|
# shells
|
2002-03-24 19:05:07 +00:00
|
|
|
COMPREPLY=( $( grep ^${cur:-[^#]} /etc/shells ) )
|
2002-02-04 02:12:10 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
2002-03-07 18:04:05 +00:00
|
|
|
esac
|
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
|
|
|
}
|
|
|
|
[ $have ] && complete -F _screen -o default screen
|
|
|
|
|
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
|
|
|
}
|
|
|
|
[ $have ] && complete -F _ncftp -o default ncftp
|
|
|
|
|
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-03-01 00:42:13 +00:00
|
|
|
# escaoe slashes for awk
|
|
|
|
prev=${prev//\//\\\/}
|
2002-02-11 22:28:47 +00:00
|
|
|
COMPREPLY=( ${COMPREPLY[@]} $( ps ahx | sed -e 's#[]\[()]##g' |\
|
2002-02-19 17:37:15 +00:00
|
|
|
awk '{p=$5;sub("^.*/","",p); \
|
|
|
|
if (p ~ /^'$prev'/) print $1}' | \
|
|
|
|
sed -e 's#^.*/##' ))
|
2002-02-11 22:28:47 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
[ $have ] && complete -F _gdb -o default gdb
|
|
|
|
|
2002-02-13 18:20:59 +00:00
|
|
|
# psql(1) completion
|
|
|
|
#
|
|
|
|
have psql &&
|
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
|
|
|
|
-h)
|
|
|
|
_known_hosts
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-U)
|
2002-02-24 05:43:48 +00:00
|
|
|
COMPREPLY=( $( psql -qtc 'select usename from pg_user' \
|
|
|
|
2>/dev/null | grep "^ $cur" ) )
|
2002-02-27 01:02:43 +00:00
|
|
|
[ ${#COMPREPLY[@]} -eq 0 ] && \
|
|
|
|
COMPREPLY=( $( compgen -u -- $cur ) )
|
2002-02-13 18:20:59 +00:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
*)
|
2002-03-01 00:42:13 +00:00
|
|
|
COMPREPLY=( $( psql -l | sed -ne 's|^ \('$cur'[^ ]*\).*$|\1|p' ) )
|
2002-02-13 18:20:59 +00:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
2002-02-27 09:34:17 +00:00
|
|
|
[ "$have" ] && complete -F _psql -o default psql
|
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-04-02 06:22:27 +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-02-18 10:09:59 +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 \
|
|
|
|
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 \
|
2002-04-02 06:17:35 +00:00
|
|
|
uniq wc units wget rsync ldd bash id info irb mkdir rmdir netstat; do
|
2002-02-18 10:09:59 +00:00
|
|
|
have $i && complete -F _longopt -o 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/' | \
|
|
|
|
grep ^$cur | sort -u ) )
|
|
|
|
else
|
|
|
|
_filedir
|
|
|
|
fi
|
2002-02-15 22:53:58 +00:00
|
|
|
}
|
2002-02-18 10:09:59 +00:00
|
|
|
[ "$have" ] && complete -o filenames -F _gcc gcc g++ c++ g77 gcj gpc
|
|
|
|
[ $OS = Linux ] && complete -o 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
|
|
|
|
COMPREPLY=()
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _cardctl cardctl
|
|
|
|
|
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-03-24 18:44:55 +00:00
|
|
|
have dpkg &&
|
|
|
|
_comp-dpkg-installed-packages()
|
|
|
|
{
|
|
|
|
grep-dctrl -r -F package -s package,status "^$1" /var/lib/dpkg/status \
|
|
|
|
| grep-dctrl -n -F status -s package installed
|
|
|
|
}
|
|
|
|
|
2002-02-27 06:47:09 +00:00
|
|
|
# Debian Linux dpkg(8) completion
|
|
|
|
#
|
|
|
|
have dpkg &&
|
|
|
|
_dpkg()
|
|
|
|
{
|
|
|
|
local cur prev
|
|
|
|
|
|
|
|
COMPREPLY=()
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
|
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-03-16 19:49:44 +00:00
|
|
|
-i|--install|--unpack|-A|--record-avail|-c|--contents|-I|--info| \
|
|
|
|
--fsys-tarfile|-f|--field|-e|--control|-X|--extract)
|
2002-03-08 17:21:30 +00:00
|
|
|
COMPREPLY=( $( compgen -f -X '!*.deb' -- $cur ) \
|
|
|
|
$( compgen -d -- $cur ) )
|
2002-02-27 06:47:09 +00:00
|
|
|
return 0
|
|
|
|
;;
|
2002-03-11 01:10:17 +00:00
|
|
|
-b|--build)
|
|
|
|
COMPREPLY=( $( compgen -d -- $cur ) )
|
|
|
|
return 0
|
|
|
|
;;
|
2002-03-27 18:33:34 +00:00
|
|
|
-s|--status|-p|--print-avail|-l|--list)
|
2002-03-16 19:49:44 +00:00
|
|
|
COMPREPLY=( $( apt-cache pkgnames $cur ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-S|--search)
|
|
|
|
_filedir
|
2002-02-27 06:47:09 +00:00
|
|
|
return 0
|
|
|
|
;;
|
2002-03-27 18:33:34 +00:00
|
|
|
-r|--remove|--purge|-L|--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
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
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 \
|
|
|
|
--force-depends-version --force-depends \
|
|
|
|
--force-confnew --force-confold --force-confdef \
|
|
|
|
--force-miss --force-conflicts --force-architecture \
|
|
|
|
--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-03-11 01:10:17 +00:00
|
|
|
[ "$have" ] && complete -F _dpkg -o filenames dpkg dpkg-deb
|
2002-02-27 06:47:09 +00:00
|
|
|
|
2002-03-24 18:44:55 +00:00
|
|
|
# Debian Linux dpkg-reconfigure(8) completion
|
|
|
|
#
|
|
|
|
have dpkg-reconfigure &&
|
|
|
|
_dpkg-reconfigure()
|
|
|
|
{
|
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} )
|
|
|
|
COMPREPLY=( $( compgen -W '${opt[@]}' -- $cur ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-@(p|-priority))
|
|
|
|
COMPREPLY=( $( compgen -W 'low medium high critical' -- $cur ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
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-04-02 05:27:50 +00:00
|
|
|
[ "$have" ] && complete -F _dpkg-reconfigure -o default dpkg-reconfigure
|
2002-03-24 18:44:55 +00:00
|
|
|
|
2002-03-07 17:44:48 +00:00
|
|
|
have java &&
|
|
|
|
_java()
|
|
|
|
{
|
|
|
|
local cur prev classpath i
|
|
|
|
|
|
|
|
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 17:44:48 +00:00
|
|
|
-@(cp|classpath))
|
|
|
|
_filedir
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
|
|
# relevant options completion
|
2002-03-29 15:33:08 +00:00
|
|
|
COMPREPLY=( $( compgen -W '-client -hotspot -server -classic \
|
|
|
|
-cp -classpath -D -verbose -version \
|
|
|
|
-showversion -? -help -X' -- $cur ) )
|
2002-03-07 17:44:48 +00:00
|
|
|
else
|
|
|
|
# available classes completion
|
|
|
|
# find wich classpath to use
|
|
|
|
if [ -n "$CLASSPATH" ]; then
|
|
|
|
classpath=$CLASSPATH
|
|
|
|
else
|
|
|
|
classpath=.
|
|
|
|
fi
|
|
|
|
for (( i=1; i < COMP_CWORD; i++ )); do
|
|
|
|
if [[ "${COMP_WORDS[i]}" == -classpath ]] || \
|
|
|
|
[[ "${COMP_WORDS[i]}" == -cp ]]; then
|
|
|
|
classpath=${COMP_WORDS[i+1]}
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
# parse each classpath element for classes
|
|
|
|
for i in ${classpath//:/ }; do
|
|
|
|
if [ -f $i ] && [[ "$i" == *.@(jar|zip) ]]; then
|
|
|
|
COMPREPLY=( ${COMPREPLY[@]} $( jar tf $i | \
|
2002-03-26 18:41:47 +00:00
|
|
|
grep '\.class' | sed -e 's|\.class||g' \
|
2002-03-07 17:44:48 +00:00
|
|
|
-e 's|/|.|g' | grep ^$cur ) )
|
|
|
|
elif [ -d $i ]; then
|
|
|
|
COMPREPLY=( ${COMPREPLY[@]} $( find $i -type f \
|
2002-03-29 15:33:08 +00:00
|
|
|
-name \*.class | \
|
2002-03-08 17:26:41 +00:00
|
|
|
sed -e 's|^'$i'/||' \
|
2002-03-07 18:04:05 +00:00
|
|
|
-e 's|\.class$||' \
|
2002-03-07 17:44:48 +00:00
|
|
|
-e 's|/|.|g' | grep ^$cur ) )
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _java java
|
|
|
|
|
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-04-02 17:22:40 +00:00
|
|
|
if [ -n "$COMP_CONFIGURE_HINTS" ]; then
|
2002-04-02 14:56:59 +00:00
|
|
|
COMPREPLY=( $( $1 --help | sed -ne 's|^ *\('$cur'[^ '$'\t'',[]\+\).*$|\1|p' ) )
|
|
|
|
else
|
|
|
|
COMPREPLY=( $( $1 --help | sed -ne 's|^ *\('$cur'[^ '$'\t'',=[]\+=\?\).*$|\1|p' ) )
|
|
|
|
fi
|
2001-03-05 19:12:48 +00:00
|
|
|
}
|
2002-03-05 23:23:30 +00:00
|
|
|
complete -F _configure_func -o 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
|
|
|
|
#
|
|
|
|
have urpmi &&
|
|
|
|
_urpmi.media()
|
|
|
|
{
|
|
|
|
# return list of available urpmi media
|
2002-03-28 18:36:19 +00:00
|
|
|
COMPREPLY=( $( awk -F'{' '/{/ {print $1}' /etc/urpmi/urpmi.cfg | \
|
|
|
|
grep ^$cur ))
|
2002-03-07 18:00:48 +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)
|
|
|
|
_urpmi.media
|
|
|
|
return 0;;
|
|
|
|
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 \
|
|
|
|
--update --media --auto --auto-select --fuzzy --src \
|
|
|
|
--noclean --complete --force --wget --curl --X \
|
|
|
|
--best-output' -- $cur ) )
|
2002-03-07 18:00:48 +00:00
|
|
|
else
|
|
|
|
# return list of available packages
|
|
|
|
COMPREPLY=( $( gzip -dc /var/lib/urpmi/synthesis.hdlist.* | \
|
2002-03-28 18:36:19 +00:00
|
|
|
awk -F'@' '/info/ {print $1}' | grep ^$cur ) )
|
2002-03-07 18:00:48 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _urpmi urpmi
|
|
|
|
|
2002-03-08 17:21:30 +00:00
|
|
|
# Mandrake urpmi.update completion
|
2002-03-07 18:00:48 +00:00
|
|
|
#
|
|
|
|
have urpmi.update &&
|
|
|
|
_urpmi.update()
|
|
|
|
{
|
|
|
|
local cur
|
|
|
|
|
|
|
|
COMPREPLY=()
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
|
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
|
|
# return list of available options
|
2002-03-29 15:33:08 +00:00
|
|
|
COMPREPLY=( $( compgen -W '-a -c -d -f --curl --wget' -- $cur))
|
2002-03-07 18:00:48 +00:00
|
|
|
else
|
|
|
|
# return list of available media
|
|
|
|
_urpmi.media
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _urpmi.update urpmi.update
|
|
|
|
|
2002-03-08 17:21:30 +00:00
|
|
|
# Mandrake urpmi.addmedia completion
|
2002-03-07 18:00:48 +00:00
|
|
|
#
|
|
|
|
have urpmi.addmedia &&
|
|
|
|
_urpmi.addmedia()
|
|
|
|
{
|
|
|
|
local cur i args
|
|
|
|
|
|
|
|
COMPREPLY=()
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
|
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
|
|
# return list of available options
|
2002-03-29 15:33:08 +00:00
|
|
|
COMPREPLY=( $( compgen -W '-c -h -f --wget --curl --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
|
|
|
|
_urpmi.media
|
|
|
|
;;
|
|
|
|
2)
|
|
|
|
# return list of available protocols
|
|
|
|
COMPREPLY=( $( compgen -W 'file:// http:// \
|
|
|
|
ftp:// removable://' -- $cur ) )
|
|
|
|
;;
|
|
|
|
3)
|
|
|
|
# return word "with"
|
|
|
|
COMPREPLY=( 'with' )
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _urpmi.addmedia urpmi.addmedia
|
|
|
|
|
2002-03-08 17:21:30 +00:00
|
|
|
# Mandrake urpmi.removemedia completion
|
2002-03-07 18:00:48 +00:00
|
|
|
#
|
|
|
|
_urpmi.removemedia()
|
|
|
|
{
|
|
|
|
local cur
|
|
|
|
|
|
|
|
COMPREPLY=()
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
|
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
|
|
# if word begins with a dash, return list of available options
|
2002-03-29 15:33:08 +00:00
|
|
|
COMPREPLY=( $( compgen -W '-a -c' -- $cur ) )
|
2002-03-07 18:00:48 +00:00
|
|
|
else
|
|
|
|
# elsewhere, return list of available media
|
|
|
|
_urpmi.media
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _urpmi.removemedia urpmi.removemedia
|
|
|
|
|
2002-03-11 01:15:09 +00:00
|
|
|
# Debian Linux reportbug(1) completion
|
|
|
|
#
|
|
|
|
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-03-11 01:15:09 +00:00
|
|
|
return 0;
|
|
|
|
;;
|
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-03-11 01:15:09 +00:00
|
|
|
return 0;
|
|
|
|
;;
|
|
|
|
-T|--tags)
|
2002-03-16 19:49:44 +00:00
|
|
|
COMPREPLY=( $( compgen -W "none patch security upstream sid \
|
|
|
|
woody potato sarge fixed" -- $cur ) )
|
2002-03-11 01:15:09 +00:00
|
|
|
return 0;
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
COMPREPLY=($( compgen -W '-h --help -v --version -a --af -b \
|
|
|
|
--no-query-bts --query-bts -B --bts -c --configure \
|
|
|
|
--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
|
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _reportbug -o filenames reportbug
|
|
|
|
|
|
|
|
# Debian Linux querybts(1) completion
|
|
|
|
#
|
|
|
|
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-03-26 18:45:45 +00:00
|
|
|
-s --source -w --web -u --ui --interface \
|
2002-03-11 01:15:09 +00:00
|
|
|
wnpp boot-floppies' -- $cur ) \
|
2002-03-16 19:49:44 +00:00
|
|
|
$( apt-cache pkgnames -- $cur ) )
|
2002-03-11 01:15:09 +00:00
|
|
|
}
|
|
|
|
[ "$have" ] && complete -F _querybts -o filenames querybts
|
|
|
|
|
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-02-27 15:48:20 +00:00
|
|
|
COMPREPLY=( $( eval compgen -f -X "$xspec" -- \"$cur\" ) \
|
|
|
|
$( 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##*\'}
|
|
|
|
list=( ${list[@]} $line )
|
|
|
|
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-01-23 23:36:30 +00:00
|
|
|
eval complete -F _filedir_xspec -o filenames ${list[@]}
|
2002-01-03 00:16:41 +00:00
|
|
|
fi
|
2001-12-20 16:12:44 +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
|
|
|
|
[ -r $i ] && . $i
|
|
|
|
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-02 23:37:51 +00:00
|
|
|
unset OS RELEASE have nospace
|
2002-03-29 02:35:42 +00:00
|
|
|
|
|
|
|
### Local Variables:
|
|
|
|
### mode: shell-script
|
|
|
|
### End:
|