2009-01-14 22:17:14 +02:00
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
2009-01-17 11:38:33 +02:00
# ex: ts=8 sw=8 noet filetype=sh
2009-01-14 22:17:14 +02:00
#
2006-02-24 11:04:52 +00:00
# bash_completion - programmable completion functions for bash 3.x
# (backwards compatible with bash 2.05b)
2000-08-08 22:17:29 +00:00
#
2008-06-21 22:37:16 +02:00
# Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
2009-01-29 21:34:57 +01:00
# © 2009, Bash Completion Maintainers
# <bash-completion-devel@lists.alioth.debian.org>
2000-08-08 22:17:29 +00:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2003-10-20 19:05:20 +00:00
#
# The latest version of this software can be obtained here:
#
2008-06-21 22:37:16 +02:00
# http://bash-completion.alioth.debian.org/
2003-10-20 19:05:20 +00:00
#
2009-02-17 09:23:24 +01:00
# RELEASE: 1.x
2002-01-05 20:04:01 +00:00
2008-06-23 12:03:06 +02:00
if [ [ $- = = *v* ] ] ; then
BASH_COMPLETION_ORIGINAL_V_VALUE = "-v"
else
BASH_COMPLETION_ORIGINAL_V_VALUE = "+v"
fi
if [ [ -n $BASH_COMPLETION_DEBUG ] ] ; then
set -v
else
set +v
fi
2002-01-29 20:33:49 +00:00
2005-07-07 23:47:14 +00:00
# Alter the following to reflect the location of this file.
#
2008-09-27 12:28:09 +02:00
[ -n " $BASH_COMPLETION " ] || BASH_COMPLETION = /etc/bash_completion
[ -n " $BASH_COMPLETION_DIR " ] || BASH_COMPLETION_DIR = /etc/bash_completion.d
2009-02-20 22:58:01 +01:00
[ -n " $BASH_COMPLETION_COMPAT_DIR " ] || BASH_COMPLETION_COMPAT_DIR = /etc/bash_completion.d
readonly BASH_COMPLETION BASH_COMPLETION_DIR BASH_COMPLETION_COMPAT_DIR
2002-01-29 20:33:49 +00:00
2001-07-08 23:14:13 +00:00
# Set a couple of useful vars
#
2002-04-22 05:59:08 +00:00
UNAME = $( uname -s )
2004-03-30 19:02:46 +00:00
# strip OS type and version under Cygwin (e.g. CYGWIN_NT-5.1 => Cygwin)
UNAME = ${ UNAME /CYGWIN_*/Cygwin }
2001-07-08 23:14:13 +00:00
RELEASE = $( uname -r )
2003-10-07 06:02:00 +00:00
# features supported by bash 2.05 and higher
if [ ${ BASH_VERSINFO [0] } -eq 2 ] && [ [ ${ BASH_VERSINFO [1] } > 04 ] ] ||
[ ${ BASH_VERSINFO [0] } -gt 2 ] ; then
2005-07-08 02:20:58 +00:00
declare -r bash205 = $BASH_VERSION 2>/dev/null || :
2002-04-03 17:19:30 +00:00
default = "-o default"
dirnames = "-o dirnames"
filenames = "-o filenames"
fi
2003-10-07 06:02:00 +00:00
# features supported by bash 2.05b and higher
if [ ${ BASH_VERSINFO [0] } -eq 2 ] && [ [ ${ BASH_VERSINFO [1] } = "05b" ] ] ||
[ ${ BASH_VERSINFO [0] } -gt 2 ] ; then
2005-07-08 02:20:58 +00:00
declare -r bash205b = $BASH_VERSION 2>/dev/null || :
2003-10-07 06:02:00 +00:00
nospace = "-o nospace"
fi
# features supported by bash 3.0 and higher
if [ ${ BASH_VERSINFO [0] } -gt 2 ] ; then
2005-07-08 02:20:58 +00:00
declare -r bash3 = $BASH_VERSION 2>/dev/null || :
2003-10-07 06:02:00 +00:00
bashdefault = "-o bashdefault"
plusdirs = "-o plusdirs"
fi
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
2008-05-11 16:47:01 +02:00
complete -f -X '!*.?(t)bz?(2)' bunzip2
# TODO: see #455510
#complete -f -X '!*.?(t)bz?(2)' bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
2008-06-21 23:55:32 +02:00
complete -f -X '!*.*' bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
2008-09-06 16:53:04 +02:00
complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo|xpi|sxw|ott|od[fgpst]|epub)' unzip zipinfo
2002-02-06 04:02:46 +00:00
complete -f -X '*.Z' compress znew
2008-05-11 16:47:01 +02:00
complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip
# TODO: see #455510
#complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
2008-06-21 23:55:32 +02:00
complete -f -X '!*.*' zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
2001-12-20 07:52:12 +00:00
complete -f -X '!*.Z' uncompress
2008-05-11 18:35:16 +02:00
complete -f -X '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX)' ee
2002-07-12 07:21:06 +00:00
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|X[BP]M|RLE|RGB|PCX|FITS|PM)' xv qiv
2004-09-30 07:48:57 +00:00
complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview
2002-02-06 16:05:12 +00:00
complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi
2008-05-01 22:22:11 +02:00
complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' kdvi
2008-05-01 22:59:32 +02:00
complete -f -X '!*.@(dvi|DVI)' dvips dviselect dvitype dvipdf advi dvipdfm dvipdfmx
2008-05-01 22:22:11 +02:00
complete -f -X '!*.@(pdf|PDF)' acroread gpdf xpdf
complete -f -X '!*.@(?(e)ps|?(E)PS|pdf|PDF)' kpdf
2009-02-23 19:20:42 +02:00
complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2)|cb[rz]|CB[RZ]|djv?(u)|DJV?(U)|dvi|DVI|gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX)' evince okular
2009-02-26 23:20:39 +02:00
complete -f -X '!*.@(?(e)ps|?(E)PS|pdf|PDF)' ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 ps2pdfwr
2002-12-04 04:02:12 +00:00
complete -f -X '!*.texi*' makeinfo texi2html
complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
2005-07-19 04:28:48 +00:00
complete -f -X '!*.@(mp3|MP3)' mpg123 mpg321 madplay
2009-01-14 00:00:38 +02:00
complete -f -X '!*@(.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|ogg|OGG|ogm|OGM|wav|WAV|asx|ASX|mng|MNG|srt)|+([0-9]).@(vdr|VDR))' xine aaxine fbxine kaffeine
2002-08-05 05:39:37 +00:00
complete -f -X '!*.@(avi|asf|wmv)' aviplay
2004-10-24 17:01:56 +00:00
complete -f -X '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay
2003-07-20 07:52:57 +00:00
complete -f -X '!*.@(mpg|mpeg|avi|mov|qt)' xanim
2003-12-24 15:11:43 +00:00
complete -f -X '!*.@(ogg|OGG|m3u|flac|spx)' ogg123
2002-08-12 14:04:58 +00:00
complete -f -X '!*.@(mp3|MP3|ogg|OGG|pls|m3u)' gqmpeg freeamp
2002-02-10 20:32:39 +00:00
complete -f -X '!*.fig' xfig
2008-05-10 18:04:06 +02:00
complete -f -X '!*.@(mid?(i)|MID?(I)|cmf|CMF)' playmidi
2008-08-05 13:21:29 +02:00
complete -f -X '!*.@(mid?(i)|MID?(I)|rmi|RMI|rcp|RCP|[gr]36|[GR]36|g18|G18|mod|MOD|xm|XM|it|IT|x3m|X3M|kar|KAR)' timidity
2008-06-22 19:57:44 +02:00
complete -f -X '*.@(o|so|so.!(conf)|a|rpm|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' vi vim gvim rvim view rview rgvim rgview gview
2004-07-03 22:03:19 +00:00
complete -f -X '*.@(o|so|so.!(conf)|a|rpm|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' emacs
2006-02-24 10:51:39 +00:00
complete -f -X '!*.@(exe|EXE|com|COM|scr|SCR|exe.so)' wine
2002-05-21 03:35:40 +00:00
complete -f -X '!*.@(zip|ZIP|z|Z|gz|GZ|tgz|TGZ)' bzme
2005-01-25 00:41:25 +00:00
complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera galeon curl dillo elinks amaya
2005-07-19 15:38:39 +00:00
complete -f -X '!*.@(sxw|stw|sxg|sgl|doc|dot|rtf|txt|htm|html|odt|ott|odm)' oowriter
2005-07-07 19:52:03 +00:00
complete -f -X '!*.@(sxi|sti|pps|ppt|pot|odp|otp)' ooimpress
complete -f -X '!*.@(sxc|stc|xls|xlw|xlt|csv|ods|ots)' oocalc
2005-07-19 15:38:39 +00:00
complete -f -X '!*.@(sxd|std|sda|sdd|odg|otg)' oodraw
complete -f -X '!*.@(sxm|smf|mml|odf)' oomath
complete -f -X '!*.odb' oobase
2005-07-11 22:24:19 +00:00
complete -f -X '!*.rpm' rpm2cpio
2009-01-12 00:35:56 +02:00
complete -f -X '!*.sqlite' sqlite3
2009-02-03 20:32:07 +01:00
complete -f -X '!*.aux' bibtex
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
2008-05-01 22:59:32 +02:00
complete -u su usermod userdel passwd chage write chfn groups slay w sux
2000-08-08 22:17:29 +00:00
2001-11-29 00:37:54 +00:00
# group commands see only groups
2003-10-07 06:42:33 +00:00
[ -n " $bash205 " ] && complete -g groupmod groupdel newgrp 2>/dev/null
2001-11-29 00:37:54 +00:00
2000-08-08 22:17:29 +00:00
# bg completes with stopped jobs
2008-05-11 14:32:21 +02:00
complete -A stopped -P '"%' -S '"' bg
2000-08-08 22:17:29 +00:00
# other job commands
2008-05-11 14:32:21 +02:00
complete -j -P '"%' -S '"' fg jobs disown
2000-08-08 22:17:29 +00:00
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
2004-05-11 16:06:08 +00:00
# builtin completes on builtins
complete -b builtin
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
2004-10-13 18:58:48 +00:00
# This function checks whether we have a given program on the system.
2002-03-02 00:13:23 +00:00
# No need for bulky functions in memory if we don't.
2001-07-08 23:14:13 +00:00
#
have( )
{
2001-07-09 00:55:01 +00:00
unset -v have
2003-04-20 20:15:38 +00:00
PATH = $PATH :/sbin:/usr/sbin:/usr/local/sbin type $1 & >/dev/null &&
have = "yes"
2001-07-08 23:14:13 +00:00
}
2002-06-17 14:38:37 +00:00
# use GNU sed if we have it, since its extensions are still used in our code
#
[ $UNAME != Linux ] && have gsed && alias sed = gsed
2004-07-03 22:56:08 +00:00
# This function checks whether a given readline variable
# is `on'.
#
2008-05-06 20:20:14 +01:00
_rl_enabled( )
2004-07-03 22:56:08 +00:00
{
2006-02-23 23:12:41 +00:00
[ [ " $( bind -v ) " = *$1 +( [ [ :space:] ] ) on* ] ]
2004-07-03 22:56:08 +00:00
}
2008-06-23 11:03:01 +02:00
# This function shell-quotes the argument
quote( )
{
echo \' ${ 1 // \' / \' \\ \' \' } \' #'# Help vim syntax highlighting
}
# This function quotes the argument in a way so that readline dequoting
# results in the original argument
quote_readline( )
{
local t = " ${ 1 // \\ / \\ \\ } "
echo \' ${ t // \' / \' \\ \' \' } \' #'# Help vim syntax highlighting
}
# This function shell-dequotes the argument
dequote( )
{
eval echo " $1 "
}
2008-05-01 22:22:11 +02:00
# Get the word to complete
# This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases
# where the user is completing in the middle of a word.
# (For example, if the line is "ls foobar",
# and the cursor is here --------> ^
# it will complete just "foo", not "foobar", which is what the user wants.)
2008-05-01 22:59:32 +02:00
#
#
# Accepts an optional parameter indicating which characters out of
# $COMP_WORDBREAKS should NOT be considered word breaks. This is useful
# for things like scp where we want to return host:path and not only path.
2008-05-01 22:22:11 +02:00
_get_cword( )
{
2008-06-23 11:09:32 +02:00
if [ [ " ${# COMP_WORDS [COMP_CWORD] } " -eq 0 ] ] || [ [ " $COMP_POINT " = = " ${# COMP_LINE } " ] ] ; then
2008-09-07 10:43:23 +02:00
printf "%s" " ${ COMP_WORDS [COMP_CWORD] } "
2008-06-23 11:09:32 +02:00
else
local i
local cur = " $COMP_LINE "
local index = " $COMP_POINT "
for ( ( i = 0; i <= COMP_CWORD; ++i ) ) ; do
2008-06-23 14:36:03 +02:00
while [ [ " ${# cur } " -ge ${# COMP_WORDS [i] } ] ] && [ [ " ${ cur : 0 : ${# COMP_WORDS [i] } } " != " ${ COMP_WORDS [i] } " ] ] ; do
2008-06-23 11:09:32 +02:00
cur = " ${ cur : 1 } "
index = " $(( index - 1 )) "
done
if [ [ " $i " -lt " $COMP_CWORD " ] ] ; then
local old_size = " ${# cur } "
cur = " ${ cur # ${ COMP_WORDS [i] } } "
local new_size = " ${# cur } "
index = " $(( index - old_size + new_size )) "
fi
2008-05-01 22:59:32 +02:00
done
2008-06-23 11:09:32 +02:00
if [ [ " ${ COMP_WORDS [COMP_CWORD] : 0 : ${# cur } } " != " $cur " ] ] ; then
# We messed up! At least return the whole word so things
# keep working
2008-09-07 10:43:23 +02:00
printf "%s" " ${ COMP_WORDS [COMP_CWORD] } "
2008-06-23 11:09:32 +02:00
else
2008-09-07 10:43:23 +02:00
printf "%s" " ${ cur : 0 : $index } "
2008-05-01 22:59:32 +02:00
fi
2008-06-23 11:09:32 +02:00
fi
2008-05-01 22:22:11 +02:00
}
2004-07-03 22:56:08 +00:00
2002-03-02 00:13:23 +00:00
# This function performs file and directory completion. It's better than
2002-05-18 17:05:08 +00:00
# simply using 'compgen -f', because it honours spaces in filenames.
# If passed -d, it completes only on directories. If passed anything else,
2002-05-19 14:56:19 +00:00
# it's assumed to be a file glob to complete on.
2002-03-02 00:13:23 +00:00
#
_filedir( )
{
2008-06-23 11:13:08 +02:00
local IFS = $'\t\n' xspec
2002-03-02 00:13:23 +00:00
_expand || return 0
2008-10-25 14:33:12 +02:00
local toks = ( ) tmp
2009-03-01 16:59:38 +01:00
# TODO: I've removed a "[ -n $tmp ] &&" before `echo $tmp',
# and everything works again. If this bug
# suddenly appears again (i.e. "cd /b<TAB>"
# becomes "cd /"), remember to check for
# other similar conditionals (here and
# _filedir_xspec()). --David
# NOTE: The comment above has been moved outside of the subshell below,
# because quotes-in-comments-in-a-subshell cause errors on
# bash-3.1. See also:
# http://www.mail-archive.com/bug-bash@gnu.org/msg01667.html
2008-11-01 09:49:57 +01:00
toks = ( ${ toks [@]- } $(
2008-10-24 19:17:23 +02:00
compgen -d -- " $( quote_readline " $cur " ) " | {
while read -r tmp; do
2008-10-25 14:33:12 +02:00
echo $tmp
2008-10-24 19:17:23 +02:00
done
}
) )
2008-06-23 11:13:08 +02:00
if [ [ " $1 " != -d ] ] ; then
xspec = ${ 1 : + " !*. $1 " }
2008-11-01 09:49:57 +01:00
toks = ( ${ toks [@]- } $(
2008-10-24 19:17:23 +02:00
compgen -f -X " $xspec " -- " $( quote_readline " $cur " ) " | {
while read -r tmp; do
2008-10-25 14:33:12 +02:00
[ -n $tmp ] && echo $tmp
2008-10-24 19:17:23 +02:00
done
}
) )
2002-03-02 00:13:23 +00:00
fi
2002-05-18 17:05:08 +00:00
2008-06-23 11:13:08 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " " ${ toks [@] } " )
2002-03-02 00:13:23 +00:00
}
2009-01-17 00:31:39 +01:00
# This function tries to parse the output of $command --help
#
_parse_help( ) {
local cmd
cmd = $1
$cmd --help | \
grep -- "^[[:space:]]*-" | \
tr "," " " | \
awk '{print $1; if ($2 ~ /-.*/) { print $2 } }' | \
sed -e "s:=.*::g"
}
2002-03-02 00:13:23 +00:00
# This function completes on signal names
#
_signals( )
{
local i
# standard signal completion is rather braindead, so we need
# to hack around to get what we want here, which is to
# complete on a dash, followed by the signal name minus
# the SIG prefix
COMPREPLY = ( $( compgen -A signal SIG${ cur #- } ) )
for ( ( i = 0; i < ${# COMPREPLY [@] } ; i++ ) ) ; do
COMPREPLY[ i] = -${ COMPREPLY [i]#SIG }
done
}
2005-01-10 22:39:56 +00:00
# This function completes on configured network interfaces
2003-08-03 00:57:49 +00:00
#
2005-01-10 22:39:56 +00:00
_configured_interfaces( )
2003-08-03 00:57:49 +00:00
{
if [ -f /etc/debian_version ] ; then
# Debian system
COMPREPLY = ( $( sed -ne 's|^iface \([^ ]\+\).*$|\1|p' \
/etc/network/interfaces ) )
2004-05-24 07:12:31 +00:00
elif [ -f /etc/SuSE-release ] ; then
# SuSE system
2005-01-13 01:22:45 +00:00
COMPREPLY = ( $( command ls \
2005-01-10 22:39:56 +00:00
/etc/sysconfig/network/ifcfg-* | \
sed -ne 's|.*ifcfg-\(' $cur '.*\)|\1|p' ) )
2006-02-25 10:37:32 +00:00
elif [ -f /etc/pld-release ] ; then
# PLD Linux
COMPREPLY = ( $( command ls -B \
/etc/sysconfig/interfaces | \
sed -ne 's|.*ifcfg-\(' $cur '.*\)|\1|p' ) )
2003-08-03 00:57:49 +00:00
else
# Assume Red Hat
COMPREPLY = ( $( command ls \
/etc/sysconfig/network-scripts/ifcfg-* | \
sed -ne 's|.*ifcfg-\(' $cur '.*\)|\1|p' ) )
fi
}
2009-01-25 23:39:09 +02:00
# This function completes on available kernels
2009-01-19 21:30:58 +01:00
#
_kernel_versions( )
{
COMPREPLY = ( $( command ls /lib/modules | grep " ^ $cur " ) )
}
2005-01-10 22:39:56 +00:00
# This function completes on all available network interfaces
# -a: restrict to active interfaces only
# -w: restrict to wireless interfaces only
#
_available_interfaces( )
{
local cmd
if [ " ${ 1 :- } " = -w ] ; then
cmd = "iwconfig"
elif [ " ${ 1 :- } " = -a ] ; then
cmd = "ifconfig"
else
cmd = "ifconfig -a"
fi
COMPREPLY = ( $( eval $cmd 2>/dev/null | \
sed -ne 's|^\(' $cur '[^[:space:][:punct:]]\{1,\}\).*$|\1|p' ) )
}
2002-03-02 00:13:23 +00:00
# This function expands tildes in pathnames
#
_expand( )
{
2008-06-23 11:14:11 +02:00
# FIXME: Why was this here?
#[ "$cur" != "${cur%\\}" ] && cur="$cur\\"
2002-06-24 19:40:04 +00:00
2009-02-06 23:26:34 +02:00
# Expand ~username type directory specifications. We want to expand
# ~foo/... to /home/foo/... to avoid problems when $cur starting with
# a tilde is fed to commands and ending up quoted instead of expanded.
2002-06-24 19:40:04 +00:00
if [ [ " $cur " = = \~ */* ] ] ; then
2009-02-06 23:26:34 +02:00
eval cur = $cur
2002-06-24 19:40:04 +00:00
elif [ [ " $cur " = = \~ * ] ] ; then
2002-03-02 00:13:23 +00:00
cur = ${ cur # \~ }
COMPREPLY = ( $( compgen -P '~' -u $cur ) )
2009-02-06 23:57:05 +02:00
[ ${# COMPREPLY [@] } -eq 1 ] && eval COMPREPLY[ 0] = ${ COMPREPLY [0] }
2002-03-02 00:13:23 +00:00
return ${# COMPREPLY [@] }
fi
}
2005-07-07 21:09:39 +00:00
# This function completes on process IDs.
# AIX and Solaris ps prefers X/Open syntax.
2004-06-01 06:08:18 +00:00
[ $UNAME = SunOS -o $UNAME = AIX ] &&
_pids( )
{
2005-01-13 01:22:45 +00:00
COMPREPLY = ( $( compgen -W '$( command ps -efo pid | sed 1d )' -- $cur ) )
2005-07-07 21:09:39 +00:00
} ||
_pids( )
2002-04-02 06:17:35 +00:00
{
2005-07-07 21:09:39 +00:00
COMPREPLY = ( $( compgen -W '$( command ps axo pid | sed 1d )' -- $cur ) )
2002-04-02 06:17:35 +00:00
}
2005-07-07 21:09:39 +00:00
# This function completes on process group IDs.
# AIX and SunOS prefer X/Open, all else should be BSD.
2004-06-01 06:08:18 +00:00
[ $UNAME = SunOS -o $UNAME = AIX ] &&
_pgids( )
{
2005-01-13 01:22:45 +00:00
COMPREPLY = ( $( compgen -W '$( command ps -efo pgid | sed 1d )' -- $cur ) )
2005-07-07 21:09:39 +00:00
} ||
_pgids( )
{
COMPREPLY = ( $( compgen -W '$( command ps axo pgid | sed 1d )' -- $cur ) )
2004-06-01 06:08:18 +00:00
}
2009-02-15 18:47:34 +02:00
# This function completes on process names.
# AIX and SunOS prefer X/Open, all else should be BSD.
[ $UNAME = SunOS -o $UNAME = AIX ] &&
_pnames( )
{
COMPREPLY = ( $( compgen -W ' $( command ps -efo comm | \
sed -e 1d -e "s:.*/::" -e "s/^-//" \
-e " s/^<defunct> $// " ) ' \
-- $cur ) )
} ||
_pnames( )
{
# FIXME: completes "[kblockd/0]" to "0". Previously it was completed
# to "kblockd" which isn't correct either. "kblockd/0" would be
# arguably most correct, but killall from psmisc 22 treats arguments
# containing "/" specially unless -r is given so that wouldn't quite
# work either. Perhaps it'd be best to not complete these to anything
# for now.
2009-02-15 18:51:09 +02:00
# Not using "ps axo comm" because under some Linux kernels, it
# truncates command names (see e.g. http://bugs.debian.org/497540#19)
2009-02-15 18:47:34 +02:00
COMPREPLY = ( $( compgen -W ' $( command ps axo command | \
sed -e " 1d; s/ .*//; s:.*/::; s/: $//; " \
-e " s/^[[(-]//; s/[])] $// " \
-e " s/^<defunct> $// " ) ' \
-- $cur ) )
}
2003-08-04 03:15:28 +00:00
# This function completes on user IDs
#
_uids( )
{
2004-07-03 22:31:33 +00:00
if type getent & >/dev/null; then
COMPREPLY = ( $( getent passwd | \
awk -F: '{if ($3 ~ /^' $cur '/) print $3}' ) )
elif type perl & >/dev/null; then
2003-08-04 22:32:25 +00:00
COMPREPLY = ( $( compgen -W '$( perl -e ' "'" 'while (($uid) = (getpwent)[2]) { print $uid . "\n" }' "'" ' )' -- $cur ) )
else
# make do with /etc/passwd
COMPREPLY = ( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^' $cur '/) print $3}' \
/etc/passwd ) )
fi
2003-08-04 03:15:28 +00:00
}
# This function completes on group IDs
#
_gids( )
{
2004-07-03 22:31:33 +00:00
if type getent & >/dev/null; then
COMPREPLY = ( $( getent group | \
awk -F: '{if ($3 ~ /^' $cur '/) print $3}' ) )
elif type perl & >/dev/null; then
2003-08-04 22:32:25 +00:00
COMPREPLY = ( $( compgen -W '$( perl -e ' "'" 'while (($gid) = (getgrent)[2]) { print $gid . "\n" }' "'" ' )' -- $cur ) )
else
# make do with /etc/group
COMPREPLY = ( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^' $cur '/) print $3}' \
/etc/group ) )
fi
2003-08-04 03:15:28 +00:00
}
2004-07-19 06:45:15 +00:00
# This function completes on services
2004-05-24 07:50:30 +00:00
#
_services( )
{
2004-07-03 22:26:29 +00:00
local sysvdir famdir
2004-05-24 07:50:30 +00:00
[ -d /etc/rc.d/init.d ] && sysvdir = /etc/rc.d/init.d || sysvdir = /etc/init.d
2005-01-13 01:22:45 +00:00
famdir = /etc/xinetd.d
2009-01-11 15:37:05 +02:00
COMPREPLY = ( $( builtin echo $sysvdir /!( *.rpm@( orig| new| save) | *~| functions) ) )
2004-05-24 07:50:30 +00:00
2004-07-03 22:26:29 +00:00
if [ -d $famdir ] ; then
2009-01-11 15:37:05 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $( builtin echo $famdir /!( *.rpm@( orig| new| save) | *~) ) )
2004-07-03 22:26:29 +00:00
fi
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- $cur ) )
2004-05-24 07:50:30 +00:00
}
2009-01-25 23:39:09 +02:00
# This function completes on modules
2005-01-03 01:24:14 +00:00
#
_modules( )
{
local modpath
modpath = /lib/modules/$1
COMPREPLY = ( $( command ls -R $modpath | \
sed -ne 's/^\(' $cur '.*\)\.k\?o\(\|.gz\)$/\1/p' ) )
}
2009-01-25 23:40:44 +02:00
# This function completes on installed modules
#
_installed_modules( )
{
COMPREPLY = ( $( compgen -W " $( /sbin/lsmod | \
awk '{if (NR != 1) print $1}' ) " -- $1 ) )
}
2009-01-25 23:39:09 +02:00
# This function completes on user:group format
2005-07-11 22:23:30 +00:00
#
_usergroup( )
{
local IFS = $'\n'
cur = ${ cur // \\ \\ / }
if [ [ $cur = *@( \\ :| .) * ] ] && [ -n " $bash205 " ] ; then
user = ${ cur %%*([^ : .]) }
COMPREPLY = ( $( compgen -P ${ user / \\ \\ } -g -- ${ cur ##*[. : ] } ) )
elif [ [ $cur = *:* ] ] && [ -n " $bash205 " ] ; then
COMPREPLY = ( $( compgen -g -- ${ cur ##*[. : ] } ) )
else
COMPREPLY = ( $( compgen -S : -u -- $cur ) )
fi
}
# this function count the number of mandatory args
#
_count_args( )
{
args = 1
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " != -* ] ] ; then
args = $(( $args + 1 ))
fi
done
}
2009-02-10 23:50:04 +01:00
# This function complete on PCI IDs
#
_pci_ids( )
{
COMPREPLY = ( ${ COMPREPLY [@] :- } \
$( compgen -W " $( lspci -n | awk '{print $3}' ) " -- $cur ) )
}
# This function complete on USB IDs
#
_usb_ids( )
{
COMPREPLY = ( ${ COMPREPLY [@] :- } \
$( compgen -W " $( lsusb | awk '{print $6}' ) " -- $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 = ( )
2009-02-21 23:13:41 +01:00
cur = ` _get_cword`
2002-03-02 00:13:23 +00:00
case " $COMP_LINE " in
*[ ^= ] )
2009-02-12 22:24:35 +01:00
COMPREPLY = ( $( compgen -A alias -- $cur ) )
2002-03-02 00:13:23 +00:00
; ;
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
}
2006-02-24 11:48:59 +00:00
complete -F _alias $nospace alias
2002-03-02 00:13:23 +00:00
# bash export completion
#
_export( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-03-02 00:13:23 +00:00
case " $COMP_LINE " in
2002-04-23 00:51:54 +00:00
*= \$ *)
COMPREPLY = ( $( compgen -v -P '$' -- ${ cur #*= \$ } ) )
; ;
2002-03-02 00:13:23 +00:00
*[ ^= ] )
COMPREPLY = ( $( compgen -v -S '=' -- $cur ) )
; ;
2002-03-07 18:04:05 +00:00
*= )
2004-02-09 19:52:56 +00:00
COMPREPLY = ( " $( eval echo -n \" $` echo ${ cur %= } ` \" |
( echo -n \'
sed -e 's/' \' '/' \' '\\\' \' '' \' '/g'
echo -n \' ) ) " )
2002-03-02 00:13:23 +00:00
; ;
2002-03-28 07:41:09 +00:00
esac
2002-03-02 00:13:23 +00:00
}
2002-08-05 05:47:30 +00:00
complete -F _export $default $nospace export
2002-03-02 00:13:23 +00:00
# bash shell function completion
#
_function( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-03-02 00:13:23 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ $1 = = @( declare| typeset ) ] ] ; then
if [ " $prev " = -f ] ; then
COMPREPLY = ( $( compgen -A function -- $cur ) )
elif [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '-a -f -F -i -r -x -p' -- \
$cur ) )
fi
elif [ $COMP_CWORD -eq 1 ] ; then
COMPREPLY = ( $( compgen -A function -- $cur ) )
else
COMPREPLY = ( " () $( type -- ${ COMP_WORDS [1] } | sed -e 1,2d ) " )
fi
}
complete -F _function function declare typeset
2002-06-01 19:16:20 +00:00
# bash complete completion
#
_complete( )
{
local cur prev options
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-06-01 19:16:20 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
-o)
options = "default dirnames filenames"
2003-10-07 06:42:33 +00:00
[ -n " $bash205b " ] && options = " $options nospace "
[ -n " $bash3 " ] && options = " $options bashdefault plusdirs "
2002-06-01 19:16:20 +00:00
COMPREPLY = ( $( compgen -W " $options " -- $cur ) )
return 0
; ;
-A)
COMPREPLY = ( $( compgen -W ' alias arrayvar binding \
builtin command directory disabled enabled \
export file function group helptopic hostname \
job keyword running service setopt shopt \
signal stopped user variable' -- $cur ) )
return 0
; ;
-C)
COMPREPLY = ( $( compgen -A command -- $cur ) )
return 0
; ;
-F)
COMPREPLY = ( $( compgen -A function -- $cur ) )
return 0
; ;
-@( p| r) )
COMPREPLY = ( $( complete -p | sed -e 's|.* ||' | \
grep " ^ $cur " ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
options = "-a -b -c -d -e -f -g -j -k -s -v -u -A -G -W -P -S -X -F -C"
2003-10-07 06:42:33 +00:00
[ -n " $bash205 " ] && options = " $options -o "
2002-06-01 19:16:20 +00:00
COMPREPLY = ( $( compgen -W " $options " -- $cur ) )
else
COMPREPLY = ( $( compgen -A command -- $cur ) )
fi
}
complete -F _complete complete
2002-03-02 00:13:23 +00:00
# start of section containing completion functions for external programs
2003-08-03 23:40:25 +00:00
# a little help for FreeBSD ports users
[ $UNAME = FreeBSD ] && complete -W ' index search fetch fetch-list \
extract patch configure build install reinstall \
deinstall clean clean-depends kernel buildworld' make
2003-03-27 06:48:09 +00:00
# This completes on a list of all available service scripts for the
# 'service' command and/or the SysV init.d directory, followed by
# that script's available commands
#
{ have service || [ -d /etc/init.d/ ] ; } &&
_service( )
{
local cur sysvdir
COMPREPLY = ( )
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-03-27 06:48:09 +00:00
# don't complete for things like killall, ssh and mysql if it's
# the standalone command, rather than the init script
2003-09-10 22:50:30 +00:00
[ [ ${ COMP_WORDS [0] } != @( *init.d/!( functions| ~) | service) ] ] && return 0
# don't complete past 2nd token
[ $COMP_CWORD -gt 2 ] && return 0
2003-03-27 06:48:09 +00:00
[ -d /etc/rc.d/init.d ] && sysvdir = /etc/rc.d/init.d \
|| sysvdir = /etc/init.d
if [ [ $COMP_CWORD -eq 1 ] ] && [ [ $prev = = "service" ] ] ; then
2004-05-24 07:50:30 +00:00
_services
2003-03-27 06:48:09 +00:00
else
COMPREPLY = ( $( compgen -W ' ` sed -ne " y/|/ /; \
2004-10-08 14:31:28 +00:00
s/^.*Usage.*{ \( .*\) } .*$/\1 /p" \
$sysvdir /${ prev ##*/ } 2>/dev/null` ' -- $cur ) )
2003-03-27 06:48:09 +00:00
fi
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _service service
2003-03-27 06:48:09 +00:00
[ -d /etc/init.d/ ] && complete -F _service $default \
$( for i in /etc/init.d/*; do echo ${ i ##*/ } ; done )
2002-03-26 15:17:12 +00:00
# chown(1) completion
2000-08-08 22:17:29 +00:00
#
2000-08-29 00:41:27 +00:00
_chown( )
2000-08-08 22:17:29 +00:00
{
2005-07-11 22:23:30 +00:00
local cur
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2000-08-08 22:17:29 +00:00
2002-09-08 20:04:26 +00:00
# options completion
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -c -h -f -R -v --changes \
--dereference --no-dereference --from= --silent --quiet \
2002-10-01 03:57:54 +00:00
--reference= --recursive --verbose --help --version' -- $cur ) )
2002-06-26 03:30:50 +00:00
else
2005-07-11 22:23:30 +00:00
_count_args
case $args in
1)
_usergroup
; ;
*)
_filedir
; ;
esac
2000-08-08 22:17:29 +00:00
fi
}
2002-06-26 03:30:50 +00:00
complete -F _chown $filenames chown
2000-08-08 22:17:29 +00:00
2002-01-08 04:49:06 +00:00
# chgrp(1) completion
#
_chgrp( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-01-12 21:45:16 +00:00
cur = ${ cur // \\ \\ / }
2002-01-08 04:49:06 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-09-08 20:04:26 +00:00
# options completion
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -c -h -f -R -v --changes \
--dereference --no-dereference --silent --quiet \
2002-10-01 03:57:54 +00:00
--reference= --recursive --verbose --help --version' -- $cur ) )
2002-09-08 20:04:26 +00:00
return 0
fi
2002-01-08 04:49:06 +00:00
# first parameter on line or first since an option?
2002-04-02 23:37:51 +00:00
if [ $COMP_CWORD -eq 1 ] && [ [ " $cur " != -* ] ] || \
2003-10-07 06:42:33 +00:00
[ [ " $prev " = = -* ] ] && [ -n " $bash205 " ] ; then
2005-01-13 01:22:45 +00:00
local IFS = $'\n'
2003-10-07 06:42:33 +00:00
COMPREPLY = ( $( compgen -g $cur 2>/dev/null ) )
2002-04-02 23:37:51 +00:00
else
2005-01-12 21:45:16 +00:00
_filedir || return 0
2002-01-08 04:49:06 +00:00
fi
return 0
}
2005-01-12 21:45:16 +00:00
complete -F _chgrp $filenames chgrp
2002-01-08 04:49:06 +00:00
2000-08-08 22:17:29 +00:00
# umount(8) completion. This relies on the mount point being the third
# space-delimited field in the output of mount(8)
#
2000-08-29 00:41:27 +00:00
_umount( )
2000-08-08 22:17:29 +00:00
{
2008-05-06 20:14:12 +01:00
local cur IFS = $'\n'
2000-08-08 22:17:29 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2000-08-08 22:17:29 +00:00
2002-04-03 16:56:01 +00:00
COMPREPLY = ( $( compgen -W '$( mount | cut -d" " -f 3 )' -- $cur ) )
2000-08-29 00:41:27 +00:00
2000-08-08 22:17:29 +00:00
return 0
}
2002-04-03 17:19:30 +00:00
complete -F _umount $dirnames umount
2000-08-08 22:17:29 +00:00
# mount(8) completion. This will pull a list of possible mounts out of
2003-01-17 09:01:29 +00:00
# /etc/{,v}fstab, unless the word being completed contains a ':', which
2000-08-08 22:17:29 +00:00
# would indicate the specification of an NFS server. In that case, we
# query the server for a list of all available exports and complete on
# that instead.
#
2000-08-29 00:41:27 +00:00
_mount( )
2008-05-10 18:04:06 +02:00
{
local cur i sm host
2000-08-08 22:17:29 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-10-05 06:03:21 +00:00
[ [ " $cur " = = \\ ] ] && cur = "/"
2002-03-24 18:57:37 +00:00
for i in { ,/usr} /{ ,s} bin/showmount; do [ -x $i ] && sm = $i && break; done
2000-08-08 22:17:29 +00:00
2001-12-21 07:56:18 +00:00
if [ -n " $sm " ] && [ [ " $cur " = = *:* ] ] ; then
2002-03-24 18:57:37 +00:00
COMPREPLY = ( $( $sm -e ${ cur %% : * } | sed 1d | \
2000-10-09 18:07:50 +00:00
grep ^${ cur #* : } | awk '{print $1}' ) )
2002-07-15 23:07:03 +00:00
elif [ [ " $cur " = = //* ] ] ; then
host = ${ cur #// }
host = ${ host %%/* }
2003-06-02 00:41:33 +00:00
if [ -n " $host " ] ; then
2006-02-23 17:01:37 +00:00
COMPREPLY = ( $( compgen -W " $( echo $( smbclient -d 0 -NL $host 2>/dev/null|
sed -ne '/^[' " $'\t ' " ']*Sharename/,/^$/p' |
sed -ne '3,$s|^[^A-Za-z]*\([^' " $'\t ' " ']*\).*$|//' $host '/\1|p' ) ) " -- " $cur " ) )
2002-07-15 23:07:03 +00:00
fi
2003-01-17 09:01:29 +00:00
elif [ -r /etc/vfstab ] ; then
# Solaris
COMPREPLY = ( $( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \
/etc/vfstab | grep " ^ $cur " ) )
2005-01-03 02:42:12 +00:00
elif [ ! -e /etc/fstab ] ; then
# probably Cygwin
COMPREPLY = ( $( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \
| grep " ^ $cur " ) )
2000-08-29 00:41:27 +00:00
else
2003-01-17 09:01:29 +00:00
# probably Linux
COMPREPLY = ( $( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' \
/etc/fstab | grep " ^ $cur " ) )
2000-08-29 00:41:27 +00:00
fi
return 0
2000-08-08 22:17:29 +00:00
}
2008-09-06 18:12:52 +02:00
complete -F _mount $default $dirnames mount
2000-08-08 22:17:29 +00:00
2002-12-05 04:22:22 +00:00
# Linux rmmod(8) completion. This completes on a list of all currently
2000-08-08 22:17:29 +00:00
# installed kernel modules.
#
2002-12-05 04:22:22 +00:00
have rmmod && {
2000-08-29 00:41:27 +00:00
_rmmod( )
2000-08-08 22:17:29 +00:00
{
local cur
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2000-08-08 22:17:29 +00:00
2009-01-25 23:40:44 +02:00
_installed_modules " $cur "
2000-08-08 22:17:29 +00:00
return 0
}
2002-12-05 04:22:22 +00:00
complete -F _rmmod rmmod
2000-08-08 22:17:29 +00:00
2003-01-21 06:37:44 +00:00
# Linux insmod(8), modprobe(8) and modinfo(8) completion. This completes on a
# list of all available modules for the version of the kernel currently
# running.
2000-08-08 22:17:29 +00:00
#
2000-08-29 00:41:27 +00:00
_insmod( )
2000-08-08 22:17:29 +00:00
{
2000-09-25 21:38:11 +00:00
local cur prev modpath
2000-08-08 22:17:29 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2001-12-18 03:43:25 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-08-08 22:17:29 +00:00
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
2009-01-25 23:40:44 +02:00
_installed_modules " $cur "
2001-01-31 22:57:06 +00:00
return 0
fi
# do filename completion if we're giving a path to a module
2004-07-05 21:31:47 +00:00
if [ [ " $cur " = = */* ] ] ; then
_filedir '@(?(k)o?(.gz))'
2001-12-18 03:43:25 +00:00
return 0
fi
2001-01-31 22:57:06 +00:00
2008-05-06 20:20:14 +01:00
if [ $COMP_CWORD -gt 1 ] &&
2003-04-29 05:38:32 +00:00
[ [ " ${ COMP_WORDS [COMP_CWORD-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 } } ' ) )
2005-01-03 01:24:14 +00:00
else
_modules $( uname -r)
2000-09-25 21:38:11 +00:00
fi
2000-08-29 00:41:27 +00:00
2000-08-08 22:17:29 +00:00
return 0
}
2003-01-21 06:37:44 +00:00
complete -F _insmod $filenames insmod modprobe modinfo
2002-12-05 04:22:22 +00:00
}
2000-08-08 22:17:29 +00:00
2003-01-17 08:54:32 +00:00
# man(1) completion
2000-08-08 22:17:29 +00:00
#
2003-01-17 08:54:32 +00:00
[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
2006-02-23 23:25:33 +00:00
-o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
-o $UNAME = OpenBSD ] &&
2000-08-29 00:41:27 +00:00
_man( )
2000-08-08 22:17:29 +00:00
{
2009-01-12 00:31:40 +02:00
local cur prev sect manpath manext mansect UNAME
2009-01-12 00:23:32 +02:00
manext = "@([0-9lnp]|[0-9][px]|man)?(.@(gz|bz2|lzma))"
2009-01-12 00:31:40 +02:00
mansect = "@([0-9lnp]|[0-9][px])"
2000-08-08 22:17:29 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2001-12-18 03:43:25 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2008-09-06 15:00:25 +02:00
2009-01-12 00:31:40 +02:00
if [ [ " $prev " = = -l ] ] ; then
_filedir $manext
return 0
fi
2000-08-08 22:17:29 +00:00
2002-01-24 04:03:26 +00:00
_expand || return 0
2009-01-12 00:23:32 +02:00
# file based completion if parameter contains /
2002-02-18 22:40:23 +00:00
if [ [ " $cur " = = */* ] ] ; then
2009-01-12 00:23:32 +02:00
_filedir $manext
2002-02-18 22:40:23 +00:00
return 0
fi
2002-02-14 22:39:04 +00:00
2002-04-22 05:59:08 +00:00
UNAME = $( uname -s )
2004-03-30 19:02:46 +00:00
# strip OS type and version under Cygwin
UNAME = ${ UNAME /CYGWIN_*/Cygwin }
if [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = FreeBSD \
-o $UNAME = Cygwin ] ; then
2002-06-04 03:45:09 +00:00
manpath = $( manpath 2>/dev/null || command man --path )
2002-03-02 00:56:21 +00:00
else
manpath = $MANPATH
fi
2002-02-14 22:39:04 +00:00
if [ -z " $manpath " ] ; then
2002-02-26 23:13:04 +00:00
COMPREPLY = ( $( compgen -c -- $cur ) )
2001-12-18 03:25:04 +00:00
return 0
fi
2000-08-08 22:17:29 +00:00
2002-02-12 16:05:22 +00:00
# determine manual section to search
2009-01-12 00:31:40 +02:00
[ [ " $prev " = = $mansect ] ] && sect = $prev || sect = '*'
2002-02-14 22:39:04 +00:00
manpath = $manpath :
if [ -n " $cur " ] ; then
2006-02-23 23:25:33 +00:00
manpath = " ${ manpath // : //*man $sect / $cur * } ${ manpath // : //*cat $sect / $cur * } "
2002-02-14 22:39:04 +00:00
else
2006-02-23 23:25:33 +00:00
manpath = " ${ manpath // : //*man $sect / } ${ manpath // : //*cat $sect / } "
2002-02-14 22:39:04 +00:00
fi
2008-05-06 20:20:14 +01:00
2002-02-08 16:49:05 +00:00
# redirect stderr for when path doesn't exist
2002-06-04 03:45:09 +00:00
COMPREPLY = ( $( eval command ls " $manpath " 2>/dev/null ) )
2002-02-14 22:39:04 +00:00
# weed out directory path names and paths to man pages
COMPREPLY = ( ${ COMPREPLY [@]##*/?( : ) } )
2002-02-08 16:49:05 +00:00
# strip suffix from man pages
2009-01-12 00:23:32 +02:00
COMPREPLY = ( ${ COMPREPLY [@]%.@(gz|bz2|lzma) } )
2002-10-23 13:50:04 +00:00
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]%.*}' -- " ${ cur // \\ \\ / } " ) )
2002-02-08 16:49:05 +00:00
2009-01-12 00:31:40 +02:00
if [ [ " $prev " != $mansect ] ] ; then
2009-01-12 00:23:32 +02:00
# File based completion for the rest, prepending ./ if needed
# (man 1.6f needs that for man pages in current dir)
local start = ${# COMPREPLY [@] }
_filedir $manext
for ( ( i = $start ; i < ${# COMPREPLY [@] } ; i++ ) ) ; do
[ [ ${ COMPREPLY [i] } = = */* ] ] || COMPREPLY[ i] = ./${ COMPREPLY [i] }
done
fi
2000-08-29 00:41:27 +00:00
return 0
2000-08-08 22:17:29 +00:00
}
2003-01-17 08:54:32 +00:00
[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
2006-02-23 23:25:33 +00:00
-o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
-o $UNAME = OpenBSD ] && \
2008-05-01 22:22:11 +02:00
complete -F _man $filenames man apropos whatis
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 = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-04-02 06:17:35 +00:00
command = $1
i = 0
2003-04-15 06:54:50 +00:00
# walk back through command line and find last option
2002-04-02 06:17:35 +00:00
while [ $i -le $COMP_CWORD -a ${# COMPREPLY [@] } -eq 0 ] ; do
curopt = ${ COMP_WORDS [COMP_CWORD- $i ] }
case " $curopt " in
-u)
COMPREPLY = ( $( compgen -u -- $cur ) )
; ;
-g)
_pgids
; ;
-p| $command )
_pids
; ;
esac
i = $(( + + i ))
done
}
complete -F _renice renice
2002-02-19 17:37:15 +00:00
# kill(1) completion
#
_kill( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-02-19 17:37:15 +00:00
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
2009-02-15 19:12:05 +02:00
# killall(1) (Linux and FreeBSD) and pkill(1) completion.
2000-08-08 22:17:29 +00:00
#
2009-02-15 19:12:05 +02:00
[ $UNAME = Linux -o $UNAME = FreeBSD ] || have pkill &&
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 = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_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
2009-02-15 18:47:34 +02:00
_pnames
2000-08-08 22:17:29 +00:00
fi
return 0
}
2009-02-15 19:12:05 +02:00
[ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _killall killall
have pkill && complete -F _killall pkill
2000-08-08 22:17:29 +00:00
2009-02-15 19:04:51 +02:00
# pgrep(1) completion.
2004-07-03 22:51:18 +00:00
#
2009-02-15 19:04:51 +02:00
[ $UNAME = Linux ] || have pgrep &&
2004-07-03 22:51:18 +00:00
_pgrep( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-07-03 22:51:18 +00:00
2009-02-15 18:53:09 +02:00
_pnames
2004-07-03 22:51:18 +00:00
return 0
}
2009-02-15 19:04:51 +02:00
have pgrep && complete -F _pgrep pgrep
2004-07-03 22:51:18 +00:00
# Linux pidof(8) completion.
[ $UNAME = Linux ] && complete -F _pgrep pidof
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
{
2003-12-15 08:49:51 +00:00
local cur prev i exprfound onlyonce
2000-08-08 22:17:29 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_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
; ;
2008-05-01 22:22:11 +02:00
-?( a| c) newer| -fls| -fprint?( 0| f) | -?( i) ?( l) name| -?( i) wholename)
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
2005-01-03 02:42:12 +00:00
[ -e /proc/filesystems ] &&
2002-04-03 21:17:10 +00:00
COMPREPLY = ( $( cut -d$'\t' -f 2 /proc/filesystems | \
grep " ^ $cur " ) )
2000-08-08 22:17:29 +00:00
return 0
; ;
-gid)
2003-08-04 03:15:28 +00:00
_gids
2000-08-08 22:17:29 +00:00
return 0
; ;
-group)
2003-10-07 06:42:33 +00:00
if [ -n " $bash205 " ] ; then
2002-04-14 22:41:04 +00:00
COMPREPLY = ( $( compgen -g -- $cur 2>/dev/null) )
2003-10-07 06:02:00 +00:00
fi
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)
2003-08-04 03:15:28 +00:00
_uids
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
; ;
2003-12-15 17:57:49 +00:00
-exec| -ok)
COMP_WORDS = ( COMP_WORDS[ 0] $cur )
COMP_CWORD = 1
_command
return 0
; ;
2008-12-12 19:45:28 +01:00
-[ acm] min| -[ acm] time| -?( i) ?( l) ?( whole) name| -inum| -?( i) path| -?( i) regex| \
2003-12-15 17:57:49 +00:00
-links| -perm| -size| -used| -printf)
2000-08-08 22:17:29 +00:00
# do nothing, just wait for a parameter to be given
return 0
; ;
esac
2002-01-24 04:03:26 +00:00
_expand || return 0
2003-12-15 08:49:51 +00:00
# set exprfound to 1 if there is already an expression present
2003-07-11 07:22:55 +00:00
for i in ${ COMP_WORDS [@] } ; do
2003-12-15 08:49:51 +00:00
[ [ " $i " = [ -\( \) ,\! ] * ] ] && exprfound = 1 && break
2003-07-11 07:22:55 +00:00
done
2002-01-30 18:48:45 +00:00
# handle case where first parameter is not a dash option
2003-12-15 08:49:51 +00:00
if [ " $exprfound " != 1 ] && [ [ " $cur " != [ -\( \) ,\! ] * ] ] ; then
2002-02-27 15:48:20 +00:00
_filedir -d
2002-01-30 18:48:45 +00:00
return 0
fi
2002-02-26 23:29:54 +00:00
# complete using basic options
2002-10-05 19:33:03 +00:00
COMPREPLY = ( $( compgen -W ' -daystart -depth -follow -help -maxdepth \
-mindepth -mount -noleaf -version -xdev -amin -anewer \
-atime -cmin -cnewer -ctime -empty -false -fstype \
-gid -group -ilname -iname -inum -ipath -iregex \
2008-05-01 22:22:11 +02:00
-wholename \
2002-10-05 19:33:03 +00:00
-links -lname -mmin -mtime -name -newer -nouser \
-nogroup -perm -regex -size -true -type -uid -used \
-user -xtype -exec -fls -fprint -fprint0 -fprintf -ok \
2008-12-11 20:04:37 +01:00
-print -print0 -printf -prune -ls -wholename -iwholename' -- $cur ) )
2000-08-08 22:17:29 +00:00
# this removes any options from the list of completions that have
2003-12-15 08:49:51 +00:00
# already been specified somewhere on the command line, as long as
# these options can only be used once (in a word, "options", in
# opposition to "tests" and "actions", as in the find(1) manpage).
onlyonce = ' -daystart -depth -follow -help -maxdepth -mindepth -mount \
-noleaf -version -xdev '
2002-02-26 23:29:54 +00:00
COMPREPLY = ( $( echo " ${ COMP_WORDS [@] } " | \
( while read -d ' ' i; do
2003-12-15 08:49:51 +00:00
[ " $i " = = "" ] ||
[ " ${ onlyonce / ${ i %% * } / } " = = " $onlyonce " ] &&
continue
2000-08-08 22:17:29 +00:00
# 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
2008-06-21 22:19:37 +02:00
echo " ${ COMPREPLY [@] } " )
2000-08-08 22:17:29 +00:00
) )
2008-05-06 20:20:14 +01:00
2003-08-03 00:42:45 +00:00
_filedir
2008-05-06 20:20:14 +01:00
2000-08-08 22:17:29 +00:00
return 0
}
2002-04-03 17:19:30 +00:00
complete -F _find $filenames find
2000-08-08 22:17:29 +00:00
2002-08-19 14:56:55 +00:00
# Linux iwconfig(8) completion
#
[ $UNAME = Linux ] && have iwconfig &&
_iwconfig( )
{
2005-01-03 01:02:16 +00:00
local cur prev
2002-08-19 14:56:55 +00:00
2005-01-03 01:02:16 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-01-03 01:02:16 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2008-05-06 20:20:14 +01:00
2005-01-10 22:39:56 +00:00
case $prev in
2005-01-03 01:02:16 +00:00
mode)
2005-07-20 22:57:24 +00:00
COMPREPLY = ( $( compgen -W ' managed ad-hoc master \
repeater secondary monitor' -- $cur ) )
2005-01-10 22:39:56 +00:00
return 0
; ;
essid)
COMPREPLY = ( $( compgen -W 'on off any' -- $cur ) )
2005-07-20 22:57:24 +00:00
if [ -n " ${ COMP_IWLIST_SCAN :- } " ] ; then
2008-06-23 11:16:05 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " \
2005-07-20 22:57:24 +00:00
$( iwlist ${ COMP_WORDS [1] } scan | \
awk -F '"' '/ESSID/ {print $2}' | \
grep " ^ $cur " ) )
fi
2005-01-10 22:39:56 +00:00
return 0
; ;
nwid)
COMPREPLY = ( $( compgen -W 'on off' -- $cur ) )
return 0
; ;
channel)
2005-07-20 22:57:24 +00:00
COMPREPLY = ( $( iwlist ${ COMP_WORDS [1] } channel | \
awk '/^[[:space:]]*Channel/ {print $2}' | \
grep " ^ $cur " ) )
2005-01-10 22:39:56 +00:00
return 0
; ;
freq)
2005-07-20 22:57:24 +00:00
COMPREPLY = ( $( iwlist ${ COMP_WORDS [1] } channel | \
awk '/^[[:space:]]*Channel/ {print $4"G"}' | \
grep " ^ $cur " ) )
2005-01-10 22:39:56 +00:00
return 0
; ;
ap)
2005-07-20 22:57:24 +00:00
COMPREPLY = ( $( compgen -W 'on off any' -- $cur ) )
if [ -n " ${ COMP_IWLIST_SCAN :- } " ] ; then
2008-06-23 11:16:05 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " \
2005-07-20 22:57:24 +00:00
$( iwlist ${ COMP_WORDS [1] } scan | \
awk -F ': ' '/Address/ {print $2}' | \
grep " ^ $cur " ) )
fi
2005-01-10 22:39:56 +00:00
return 0
; ;
rate)
2005-07-20 22:57:24 +00:00
COMPREPLY = ( $( compgen -W 'auto fixed' -- $cur ) )
2008-06-23 11:16:05 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " \
2005-07-20 22:57:24 +00:00
$( iwlist ${ COMP_WORDS [1] } rate | \
awk '/^[[:space:]]*[0-9]/ {print $1"M"}' | \
grep " ^ $cur " ) )
2005-01-10 22:39:56 +00:00
return 0
; ;
rts)
COMPREPLY = ( $( compgen -W 'auto fixed off' -- $cur ) )
return 0
; ;
frag)
COMPREPLY = ( $( compgen -W 'auto fixed off' -- $cur ) )
return 0
; ;
key)
COMPREPLY = ( $( compgen -W 'off on open restricted' -- $cur ) )
return 0
; ;
enc)
COMPREPLY = ( $( compgen -W 'off on open restricted' -- $cur ) )
return 0
; ;
power)
COMPREPLY = ( $( compgen -W 'period timeout off on' -- $cur ) )
return 0
; ;
txpower)
COMPREPLY = ( $( compgen -W 'off on auto' -- $cur ) )
return 0
; ;
retry)
COMPREPLY = ( $( compgen -W 'limit lifetime' -- $cur ) )
2005-01-03 01:02:16 +00:00
return 0
; ;
esac
2005-01-10 22:39:56 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
if [ [ " $cur " = = -* ] ] ; then
2008-05-06 20:20:14 +01:00
COMPREPLY = ( $( compgen -W '--help --version' -- $cur ) )
2005-01-10 22:39:56 +00:00
else
_available_interfaces -w
fi
else
COMPREPLY = ( $( compgen -W ' essid nwid mode freq channel sens mode \
2008-05-06 20:20:14 +01:00
ap nick rate rts frag enc key power txpower commit' -- $cur ) )
2005-01-10 22:39:56 +00:00
fi
2000-08-08 22:17:29 +00:00
2005-07-07 23:36:51 +00:00
} &&
complete -F _iwconfig iwconfig
2005-01-10 22:39:56 +00:00
2005-01-03 01:02:16 +00:00
# Linux iwlist(8) completion
#
[ $UNAME = Linux ] && have iwlist &&
_iwlist( )
{
2005-01-10 22:39:56 +00:00
local cur prev
2005-01-03 01:02:16 +00:00
2005-01-10 22:39:56 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-01-10 22:39:56 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2008-05-06 20:20:14 +01:00
2005-01-10 22:39:56 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
if [ [ " $cur " = = -* ] ] ; then
2008-05-06 20:20:14 +01:00
COMPREPLY = ( $( compgen -W '--help --version' -- $cur ) )
2005-01-10 22:39:56 +00:00
else
_available_interfaces -w
fi
else
2005-07-20 22:57:24 +00:00
COMPREPLY = ( $( compgen -W ' scan scanning freq frequency \
channel rate bit bitrate key enc encryption power \
2008-05-06 20:20:14 +01:00
txpower retry ap accesspoint peers event' -- $cur ) )
2005-01-10 22:39:56 +00:00
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _iwlist iwlist
2005-01-03 01:02:16 +00:00
# Linux iwspy(8) completion
#
[ $UNAME = Linux ] && have iwspy &&
_iwspy( )
{
2005-01-10 22:39:56 +00:00
local cur
2005-01-03 01:02:16 +00:00
2005-01-10 22:39:56 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-01-03 01:02:16 +00:00
2005-01-10 22:39:56 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
if [ [ " $cur " = = -* ] ] ; then
2008-05-06 20:20:14 +01:00
COMPREPLY = ( $( compgen -W '--help --version' -- $cur ) )
2005-01-10 22:39:56 +00:00
else
_available_interfaces -w
fi
else
2008-05-06 20:20:14 +01:00
COMPREPLY = ( $( compgen -W 'setthr getthr off' -- $cur ) )
2005-01-10 22:39:56 +00:00
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _iwspy iwspy
2005-01-03 01:02:16 +00:00
2005-01-10 22:39:56 +00:00
# Linux iwpriv(8) completion
2005-01-03 01:02:16 +00:00
#
[ $UNAME = Linux ] && have iwpriv &&
_iwpriv( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-01-03 01:02:16 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
roam)
COMPREPLY = ( $( compgen -W 'on off' -- $cur ) )
return 0
; ;
port)
COMPREPLY = ( $( compgen -W 'ad-hoc managed' -- $cur ) )
return 0
; ;
esac
2005-01-10 22:39:56 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
if [ [ " $cur " = = -* ] ] ; then
2008-05-06 20:20:14 +01:00
COMPREPLY = ( $( compgen -W '--help --version' -- $cur ) )
2005-01-10 22:39:56 +00:00
else
_available_interfaces -w
fi
else
2008-05-06 20:20:14 +01:00
COMPREPLY = ( $( compgen -W '--all roam port' -- $cur ) )
2005-01-10 22:39:56 +00:00
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _iwpriv iwpriv
2000-08-08 22:17:29 +00:00
2009-01-11 00:27:23 +02:00
# Red Hat & Debian GNU/Linux if{up,down} completion
2002-01-08 00:33:08 +00:00
#
2005-07-07 23:36:51 +00:00
[ $UNAME = Linux ] && { have ifup || have ifdown; } &&
2002-01-08 00:33:08 +00:00
_ifupdown( )
{
2002-01-29 22:06:26 +00:00
local cur
2002-01-08 00:33:08 +00:00
2002-01-29 22:06:26 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-01-08 00:33:08 +00:00
2002-02-26 22:59:47 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
2005-01-10 22:39:56 +00:00
_configured_interfaces
2008-05-01 22:22:11 +02:00
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]}' -- " $cur " ) )
2002-01-08 00:33:08 +00:00
fi
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _ifupdown ifup ifdown
2004-05-24 07:12:31 +00:00
[ $UNAME = Linux ] && have ifstatus && complete -F _ifupdown ifstatus
2002-01-08 00:33:08 +00:00
2002-08-19 14:56:55 +00:00
# Linux ipsec(8) completion (for FreeS/WAN)
2000-08-08 22:17:29 +00:00
#
2002-04-22 05:59:08 +00:00
[ $UNAME = Linux ] && have ipsec &&
2000-08-29 00:41:27 +00:00
_ipsec( )
2000-08-08 22:17:29 +00:00
{
local cur
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2000-08-08 22:17:29 +00:00
2008-05-06 20:20:14 +01: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 \
2003-10-07 04:45:03 +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' \
2003-10-07 04:45:03 +00:00
-- $cur ) )
2000-10-09 18:07:50 +00:00
; ;
manual)
COMPREPLY = ( $( compgen -W ' --up --down --route --unroute \
2003-10-07 04:45:03 +00:00
--union' -- $cur ) )
2000-10-09 18:07:50 +00:00
; ;
ranbits)
2003-10-07 04:45:03 +00:00
COMPREPLY = ( $( compgen -W '--quick --continuous --bytes' \
-- $cur ) )
2000-10-09 18:07:50 +00:00
; ;
setup)
2003-10-07 04:45:03 +00:00
COMPREPLY = ( $( compgen -W '--start --stop --restart' -- $cur ) )
2000-10-09 18:07:50 +00:00
; ;
*)
; ;
esac
2000-08-29 00:41:27 +00:00
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _ipsec ipsec
2000-08-11 21:20:41 +00:00
2002-05-05 20:46:30 +00:00
# Postfix completion.
#
have postfix && {
2002-05-08 15:23:51 +00:00
# postfix(1)
#
2002-12-05 01:47:49 +00:00
_postfix( )
2002-05-08 15:23:51 +00:00
{
2003-12-31 23:58:30 +00:00
local cur prev
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-12-31 23:58:30 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ $cur = = '-' ] ] ; then
COMPREPLY = ( -c -D -v)
return 0
fi
if [ [ $prev = = '-c' ] ] ; then
_filedir -d
return 0
fi
if [ [ $prev = = '-D' ] ] ; then
2008-05-01 22:22:11 +02:00
COMPREPLY = ( $( compgen -W 'start' -- "`_get_cword`" ) )
2003-12-31 23:58:30 +00:00
return 0
fi
2002-05-08 15:23:51 +00:00
COMPREPLY = ( $( compgen -W 'start stop reload abort flush check' -- \
2008-05-01 22:22:11 +02:00
"`_get_cword`" ) )
2002-05-08 15:23:51 +00:00
}
complete -F _postfix postfix
2002-05-05 20:46:30 +00:00
# postalias(1) and postmap(1)
#
_postmap( )
{
local cur prev len idx
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-05-05 20:46:30 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ $cur = = '-' ] ] ; then
2003-08-18 19:31:45 +00:00
COMPREPLY = ( -N -f -i -n -o -p -r -v -w -c -d -q)
2002-05-05 20:46:30 +00:00
return 0
fi
if [ [ $prev = = '-c' ] ] ; then
_filedir -d
return 0
fi
if [ [ $prev = = -[ dq] ] ] ; then
return 0
fi
if [ [ " $cur " = = *:* ] ] ; then
COMPREPLY = ( $( compgen -f -- ${ cur #* : } ) )
else
len = ${# cur }
idx = 0
2003-06-07 20:46:04 +00:00
for pval in $( /usr/sbin/postconf -m ) ; do
2002-05-05 20:46:30 +00:00
if [ [ " $cur " = = " ${ pval : 0 : $len } " ] ] ; then
COMPREPLY[ $idx ] = " $pval : "
idx = $(( $idx + 1 ))
fi
done
if [ [ $idx -eq 0 ] ] ; then
COMPREPLY = ( $( compgen -f -- " $cur " ) )
fi
fi
return 0
}
complete -F _postmap postmap postalias
2003-08-18 19:31:45 +00:00
# postcat(1)
#
_postcat( )
{
local cur prev pval len idx qfile
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-08-18 19:31:45 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ $cur = = '-' ] ] ; then
COMPREPLY = ( -c -q -v)
return 0
fi
if [ [ $prev = = '-c' ] ] ; then
_filedir -d
return 0
fi
qfile = 0
2008-06-21 22:19:37 +02:00
for idx in " ${ COMP_WORDS [@] } " ; do
2003-08-18 19:31:45 +00:00
[ [ " $idx " = -q ] ] && qfile = 1 && break
done
if [ [ $qfile = = 1 ] ] ; then
len = ${# cur }
idx = 0
for pval in $( mailq | \
2003-09-13 14:49:49 +00:00
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ) ; do
2003-08-18 19:31:45 +00:00
if [ [ " $cur " = = " ${ pval : 0 : $len } " ] ] ; then
COMPREPLY[ $idx ] = $pval
idx = $(( $idx + 1 ))
fi
done
return 0
else
_filedir
return 0
fi
}
complete -F _postcat postcat
2002-05-05 20:46:30 +00:00
# postconf(1)
#
_postconf( )
{
2003-08-18 19:31:45 +00:00
local cur prev pval len idx eqext
2002-05-05 20:46:30 +00:00
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-05-05 20:46:30 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ $cur = = '-' ] ] ; then
COMPREPLY = ( -c -d -e -h -m -l -n -v)
return 0
fi
if [ [ $prev = = '-c' ] ] ; then
_filedir -d
return 0
fi
if [ [ $prev = = '-e' ] ] ; then
cur = ${ cur #[ \" \' ] }
eqext = '='
fi
len = ${# cur }
idx = 0
2003-06-07 20:46:04 +00:00
for pval in $( /usr/sbin/postconf | cut -d ' ' -f 1 ) ; do
2002-05-05 20:46:30 +00:00
if [ [ " $cur " = = " ${ pval : 0 : $len } " ] ] ; then
COMPREPLY[ $idx ] = " $pval $eqext "
idx = $(( $idx + 1 ))
fi
done
return 0
}
complete -F _postconf postconf
# postsuper(1)
#
_postsuper( )
{
2003-08-18 19:31:45 +00:00
local cur prev pval len idx
2002-05-05 20:46:30 +00:00
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-05-05 20:46:30 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ $cur = = '-' ] ] ; then
2003-08-18 19:31:45 +00:00
COMPREPLY = ( -c -d -h -H -p -r -s -v)
2002-05-05 20:46:30 +00:00
return 0
fi
2003-09-13 14:49:49 +00:00
case $prev in
-[ dr] )
2002-05-05 20:46:30 +00:00
len = ${# cur }
idx = 0
2003-09-13 14:49:49 +00:00
for pval in $( echo ALL; mailq | \
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ) ; do
2002-05-05 20:46:30 +00:00
if [ [ " $cur " = = " ${ pval : 0 : $len } " ] ] ; then
COMPREPLY[ $idx ] = $pval
idx = $(( $idx + 1 ))
fi
done
return 0
2003-09-13 14:49:49 +00:00
; ;
-h)
len = ${# cur }
idx = 0
for pval in $( echo ALL; mailq | \
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//; /!$/d' ) ; do
if [ [ " $cur " = = " ${ pval : 0 : $len } " ] ] ; then
COMPREPLY[ $idx ] = $pval
idx = $(( $idx + 1 ))
fi
done
return 0
; ;
-H)
len = ${# cur }
idx = 0
for pval in $( echo ALL; mailq | \
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ) ; do
if [ [ " $cur " = = " ${ pval : 0 : $len } " ] ] ; then
COMPREPLY[ $idx ] = $pval
idx = $(( $idx + 1 ))
fi
done
return 0
; ;
esac
COMPREPLY = ( $( compgen -W 'hold incoming active deferred' -- $cur ) )
2002-05-05 20:46:30 +00:00
return 0
}
complete -F _postsuper postsuper
}
2000-08-29 00:41:27 +00:00
# cvs(1) completion
#
2002-05-02 22:43:50 +00:00
have cvs && {
set_prefix( )
2000-08-11 21:20:41 +00:00
{
2002-12-18 18:15:46 +00:00
[ -z ${ prefix :- } ] || prefix = ${ cur %/* } /
[ -r ${ prefix :- } CVS/Entries ] || prefix = ""
2002-05-02 22:43:50 +00:00
}
2002-03-01 18:29:34 +00:00
2002-05-02 22:43:50 +00:00
get_entries( )
{
2004-07-19 06:45:15 +00:00
local IFS = $'\n'
2002-12-18 18:15:46 +00:00
[ -r ${ prefix :- } CVS/Entries ] && \
2005-01-02 23:53:47 +00:00
entries = $( cut -d/ -f2 -s ${ prefix :- } CVS/Entries)
2002-05-02 22:43:50 +00:00
}
get_modules( )
{
2008-05-06 20:20:14 +01:00
if [ -n " $prefix " ] ; then
2002-06-04 03:45:09 +00:00
COMPREPLY = ( $( command ls -d ${ cvsroot } /${ prefix } /!( CVSROOT) ) )
2002-05-02 22:43:50 +00:00
else
2002-06-04 03:45:09 +00:00
COMPREPLY = ( $( command ls -d ${ cvsroot } /!( CVSROOT) ) )
2002-05-02 22:43:50 +00:00
fi
}
_cvs( )
{
2003-02-08 06:33:51 +00:00
local cur count mode i cvsroot cvsroots pwd
2002-02-28 22:23:14 +00:00
local -a flags miss files entries changed newremoved
2000-08-11 21:20:41 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2000-08-11 21:20:41 +00:00
2002-10-05 07:33:14 +00:00
count = 0
2008-06-21 22:19:37 +02:00
for i in " ${ COMP_WORDS [@] } " ; do
2002-02-28 22:23:14 +00:00
[ $count -eq $COMP_CWORD ] && break
2003-02-08 06:33:51 +00:00
# Last parameter was the CVSROOT, now go back to mode selection
if [ " ${ COMP_WORDS [((count))] } " = = " $cvsroot " -a " $mode " = = "cvsroot" ] ; then
mode = ""
fi
2002-02-28 22:23:14 +00:00
if [ -z " $mode " ] ; then
case $i in
-d)
2003-02-08 06:33:51 +00:00
mode = cvsroot
2002-10-05 07:33:14 +00:00
cvsroot = ${ COMP_WORDS [((count+1))] }
2002-02-28 22:23:14 +00:00
; ;
2004-03-30 20:12:09 +00:00
@( ad?( d) | new) )
2002-02-28 22:23:14 +00:00
mode = add
; ;
2004-03-30 20:12:09 +00:00
@( adm?( in) | rcs) )
2002-02-28 22:23:14 +00:00
mode = admin
; ;
2004-03-30 20:12:09 +00:00
ann?( notate) )
2005-01-02 23:53:47 +00:00
mode = annotate
2004-03-30 20:12:09 +00:00
; ;
2002-02-28 22:23:14 +00:00
@( checkout| co| get) )
mode = checkout
; ;
2004-03-30 20:12:09 +00:00
@( com?( mit) | ci) )
2002-02-28 22:23:14 +00:00
mode = commit
; ;
2004-03-30 20:12:09 +00:00
di?( f?( f) ) )
mode = diff
; ;
ex?( p?( ort) ) )
2003-01-17 09:09:59 +00:00
mode = export
; ;
2004-03-30 20:12:09 +00:00
?( un) edit)
2002-02-28 22:23:14 +00:00
mode = $i
; ;
2004-03-30 20:12:09 +00:00
hi?( s?( tory) ) )
mode = history
; ;
im?( p?( ort) ) )
mode = import
; ;
re?( l?( ease) ) )
mode = release
2004-02-09 19:50:56 +00:00
; ;
2002-02-28 22:23:14 +00:00
?( r) log)
mode = log
; ;
@( rdiff| patch) )
mode = rdiff
; ;
@( remove| rm| delete) )
mode = remove
; ;
@( rtag| rfreeze) )
mode = rtag
; ;
2006-02-23 19:27:59 +00:00
st?( at?( us) ) )
2004-03-30 20:12:09 +00:00
mode = status
; ;
2002-02-28 22:23:14 +00:00
@( tag| freeze) )
mode = tag
; ;
2004-03-30 20:12:09 +00:00
up?( d?( ate) ) )
mode = update
; ;
2002-02-28 22:23:14 +00:00
*)
; ;
esac
elif [ [ " $i " = -* ] ] ; then
2008-06-23 11:18:05 +02:00
flags = ( " ${ flags [@] } " $i )
2002-02-28 22:23:14 +00:00
fi
count = $(( + + count))
done
2000-08-29 00:41:27 +00:00
2002-02-28 22:23:14 +00:00
case " $mode " in
add)
2002-03-01 06:58:23 +00:00
if [ [ " $cur " != -* ] ] ; then
2002-02-28 22:23:14 +00:00
set_prefix
2003-02-06 18:06:29 +00:00
if [ $COMP_CWORD -gt 1 -a -r ${ prefix :- } CVS/Entries ] ; then
2002-02-28 22:23:14 +00:00
get_entries
[ -z " $cur " ] && \
2002-09-09 13:46:17 +00:00
files = $( command ls -Ad !( CVS) ) || \
2002-06-04 03:45:09 +00:00
files = $( command ls -d ${ cur } * 2>/dev/null )
2008-06-23 11:18:05 +02:00
for i in " ${ entries [@] } " ; do
2002-09-09 13:46:17 +00:00
files = ( ${ files [@]/# $i // } )
2002-02-28 22:23:14 +00:00
done
2008-12-14 14:05:40 +01:00
COMPREPLY = ( $( compgen -X '*~' -W '${files[@]}' -- \
2002-03-01 06:58:23 +00:00
$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
; ;
2005-01-02 23:53:47 +00:00
annotate)
if [ [ " $cur " = -* ] ] ; then
COMPREPLY = ( $( compgen -W '-D -F -f -l -R -r' -- $cur ) )
else
get_entries
COMPREPLY = ( $( compgen -W '${entries[@]}' -- $cur ) )
fi
; ;
2002-02-28 22:23:14 +00:00
checkout)
2002-03-01 06:58:23 +00:00
if [ [ " $cur " != -* ] ] ; then
2002-05-08 15:26:18 +00:00
[ -z " $cvsroot " ] && cvsroot = $CVSROOT
2004-07-03 22:23:57 +00:00
COMPREPLY = ( $( cvs -d " $cvsroot " co -c 2> /dev/null | \
awk '{print $1}' ) )
2002-05-05 18:29:35 +00:00
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
2002-02-28 22:23:14 +00:00
else
COMPREPLY = ( $( compgen -W ' -A -N -P -R -c -f -l -n -p \
-s -r -D -d -k -j' -- $cur ) )
fi
; ;
commit)
set_prefix
2002-04-02 17:22:40 +00:00
2003-01-25 21:22:16 +00:00
if [ [ " $cur " != -* ] ] && [ -r ${ prefix :- } CVS/Entries ] ; then
2002-04-02 17:22:40 +00:00
# if $COMP_CVS_REMOTE is not null, 'cvs commit' will
# complete on remotely checked-out files (requires
# passwordless access to the remote repository
2003-01-30 07:41:42 +00:00
if [ -n " ${ COMP_CVS_REMOTE :- } " ] ; then
2002-04-01 14:45:45 +00:00
# this is the least computationally intensive
# way found so far, but other changes
# (something other than changed/removed/new)
# may be missing
2006-02-23 23:46:30 +00:00
changed = ( $( cvs -q diff --brief 2>& 1 | \
2002-04-01 14:45:45 +00:00
sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ) )
2006-02-23 23:46:30 +00:00
newremoved = ( $( cvs -q diff --brief 2>& 1 | \
2002-04-01 14:45:45 +00:00
sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ) )
2003-01-25 21:22:16 +00:00
COMPREPLY = ( $( compgen -W ' ${ changed [@] :- } \
${ newremoved [@] :- } ' -- $cur ) )
2002-04-01 14:45:45 +00:00
else
2008-12-14 14:05:40 +01:00
COMPREPLY = ( $( compgen $default -- " $cur " ) )
2002-04-01 14:45:45 +00:00
fi
2002-02-28 22:23:14 +00:00
else
COMPREPLY = ( $( compgen -W '-n -R -l -f -F -m -r' -- \
$cur ) )
fi
; ;
2003-02-08 06:33:51 +00:00
cvsroot)
if [ -r ~/.cvspass ] ; then
# Ugly escaping because of bash treating ':' specially
cvsroots = $( sed 's/^[^ ]* //; s/:/\\:/g' ~/.cvspass )
COMPREPLY = ( $( compgen -W '$cvsroots' -- $cur ) )
fi
; ;
2003-01-17 09:09:59 +00:00
export )
if [ [ " $cur " != -* ] ] ; then
[ -z " $cvsroot " ] && cvsroot = $CVSROOT
COMPREPLY = ( $( cvs -d " $cvsroot " co -c | awk '{print $1}' ) )
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
else
COMPREPLY = ( $( compgen -W ' -N -f -l -R -n \
-r -D -d -k' -- $cur ) )
fi
; ;
2002-04-30 19:55:20 +00:00
diff)
if [ [ " $cur " = = -* ] ] ; then
_longopt diff
else
get_entries
2005-02-08 20:50:01 +00:00
COMPREPLY = ( $( compgen -W '${entries[@]:-}' -- $cur ) )
2002-04-30 19:55:20 +00:00
fi
; ;
2002-02-28 22:23:14 +00:00
remove)
2002-03-01 06:58:23 +00:00
if [ [ " $cur " != -* ] ] ; then
2002-02-28 22:23:14 +00:00
set_prefix
2003-02-06 18:06:29 +00:00
if [ $COMP_CWORD -gt 1 -a -r ${ prefix :- } CVS/Entries ] ; then
2002-02-28 22:23:14 +00:00
get_entries
# find out what files are missing
2008-06-21 22:19:37 +02:00
for i in " ${ entries [@] } " ; do
2008-06-23 11:18:05 +02:00
[ ! -r " $i " ] && miss = ( " ${ miss [@] } " $i )
2002-02-28 22:23:14 +00:00
done
2003-02-06 18:06:29 +00:00
COMPREPLY = ( $( compgen -W '${miss[@]:-}' -- $cur ) )
2002-02-28 22:23:14 +00:00
fi
else
COMPREPLY = ( $( compgen -W '-f -l -R' -- $cur ) )
fi
; ;
import)
2002-03-01 06:58:23 +00:00
if [ [ " $cur " != -* ] ] ; then
2002-02-28 22:23:14 +00:00
# starts with same algorithm as checkout
[ -z " $cvsroot " ] && cvsroot = $CVSROOT
2002-03-01 18:29:34 +00:00
prefix = ${ cur %/* }
if [ -r ${ cvsroot } /${ prefix } ] ; then
get_modules
2002-03-01 06:58:23 +00:00
COMPREPLY = ( ${ COMPREPLY [@]# $cvsroot } )
COMPREPLY = ( ${ COMPREPLY [@]# \/ } )
fi
2002-02-28 22:23:14 +00:00
pwd = $( pwd )
pwd = ${ pwd ##*/ }
2002-03-01 06:58:23 +00:00
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]} $pwd' -- \
$cur ) )
2002-02-28 22:23:14 +00:00
else
COMPREPLY = ( $( compgen -W '-d -k -I -b -m -W' -- $cur ) )
fi
; ;
2006-02-25 10:55:56 +00:00
update)
if [ [ " $cur " = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A -P -C -d -f -l -R -p \
-k -r -D -j -I -W' -- \
$cur ) )
fi
; ;
2002-03-01 06:58:23 +00:00
"" )
2002-04-18 13:55:50 +00:00
COMPREPLY = ( $( compgen -W ' add admin annotate checkout ci co \
2002-06-21 07:11:32 +00:00
commit diff delete edit export \
freeze get history import log new \
patch rcs rdiff release remove \
2006-02-23 19:27:59 +00:00
rfreeze rlog rm rtag stat status \
tag unedit up update -H -Q -q -b \
-d -e -f -l -n -t -r -v -w -x -z \
--help --version' -- $cur ) )
2002-02-28 22:23:14 +00:00
; ;
2002-03-01 06:58:23 +00:00
*)
; ;
2002-02-28 22:23:14 +00:00
esac
2008-05-06 20:20:14 +01:00
2000-08-11 21:20:41 +00:00
return 0
}
2002-06-01 18:58:06 +00:00
complete -F _cvs $default cvs
2002-05-02 22:43:50 +00:00
}
2000-08-11 21:20:41 +00:00
2002-04-29 18:58:39 +00:00
have rpm && {
2002-04-07 17:17:13 +00:00
# helper functions for rpm completion
#
2002-09-09 16:26:14 +00:00
_rpm_installed_packages( )
2000-08-11 21:20:41 +00:00
{
2009-01-11 16:13:32 +02:00
local ver nodig = " $1 " nosig = " $2 "
2002-12-18 18:15:46 +00:00
2002-04-07 17:17:13 +00:00
if [ -r /var/log/rpmpkgs -a \
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ] ; then
2003-04-29 05:28:10 +00:00
# using RHL 7.2 or later - this is quicker than querying the DB
2002-04-07 17:17:13 +00:00
COMPREPLY = ( $( sed -ne \
2009-01-11 15:42:12 +02:00
's|^\(' $cur '[^[:space:]]*\)-[^[:space:]-]\+-[^[:space:]-]\+\.rpm$|\1|p' \
2002-04-07 17:17:13 +00:00
/var/log/rpmpkgs ) )
else
2009-01-11 16:13:32 +02:00
_rpm_nodigsig
COMPREPLY = ( $( rpm -qa $nodig $nosig --qf= '%{NAME} ' " $cur * " ) )
2002-04-07 17:17:13 +00:00
fi
}
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
2002-09-09 16:26:14 +00:00
_rpm_groups( )
2002-04-17 06:44:12 +00:00
{
local IFS = $'\t'
# remove trailing backslash, or grep will complain
2002-10-01 06:07:33 +00:00
cur = ${ cur % "\\" }
2004-07-19 06:43:10 +00:00
COMPREPLY = ( $( rpm -qa $nodig $nosig --queryformat '%{group}\n' | \
2003-04-29 05:28:10 +00:00
grep " ^ $cur " ) )
2002-04-17 06:44:12 +00:00
# backslash escape spaces and translate newlines to tabs
2008-06-21 22:19:37 +02:00
COMPREPLY = ( $( echo " ${ COMPREPLY [@] } " | sed 's/ /\\ /g' | tr '\n' '\t' ) )
2002-04-17 06:44:12 +00:00
}
2009-01-11 16:13:32 +02:00
_rpm_nodigsig( )
{
if [ -z " $nodig " -a -z " $nosig " ] ; then
local rpmver
rpmver = $( rpm --version)
rpmver = ${ rpmver ##* }
if [ [ " $rpmver " > "4.0.4" ] ] ; then
nodig = "--nodigest"
fi
if [ [ " $rpmver " > "4.0.99" ] ] ; then
nosig = "--nosignature"
fi
fi
}
2002-04-07 17:17:13 +00:00
# rpm(8) completion
2008-05-06 20:20:14 +01:00
#
2002-04-07 17:17:13 +00:00
_rpm( )
{
2009-01-11 16:13:32 +02:00
local cur prev nodig nosig
2000-08-11 21:20:41 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2001-12-18 03:43:25 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2004-07-19 06:43:10 +00:00
nodig = ""
nosig = ""
2009-01-11 16:13:32 +02:00
_rpm_nodigsig
2000-08-11 21:20:41 +00:00
2002-02-26 22:59:47 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
2000-08-11 21:20:41 +00:00
# first parameter on line
case " $cur " in
-b*)
2002-02-27 00:14:52 +00:00
COMPREPLY = ( $( compgen -W '-ba -bb -bc -bi -bl -bp -bs' \
-- $cur ) )
2000-08-11 21:20:41 +00:00
; ;
-t*)
2002-02-27 00:14:52 +00:00
COMPREPLY = ( $( compgen -W '-ta -tb -tc -ti -tl -tp -ts' \
-- $cur ) )
2000-08-11 21:20:41 +00:00
; ;
--*)
2002-02-27 00:14:52 +00:00
COMPREPLY = ( $( compgen -W ' --help --version --initdb \
--checksig --recompile --rebuild --resign --addsign \
--rebuilddb --showrc --setperms --setugids --tarbuild \
--eval --install --upgrade --query --freshen --erase \
2002-05-05 18:20:02 +00:00
--verify --querytags --rmsource --rmspec --clean \
--import' -- $cur ) )
2000-08-11 21:20:41 +00:00
; ;
*)
2009-01-11 15:22:31 +02:00
COMPREPLY = ( $( compgen -W '-b -e -E -F -i -q -t -U -V' \
2002-02-27 00:14:52 +00:00
-- $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
; ;
2009-01-11 15:22:31 +02:00
--eval| -E)
2002-01-03 00:16:41 +00:00
# get a list of macros
2009-01-11 15:09:54 +02:00
COMPREPLY = ( $( rpm --showrc | sed -ne \
's/^-\?[0-9]\+[:=][[:space:]]\+\(' ${ cur #% } '[^[:space:](]*\).*/\1/p' ) )
COMPREPLY = ( " ${ COMPREPLY [@]/#/% } " )
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
; ;
--pipe)
2002-02-27 00:14:52 +00:00
COMPREPLY = ( $( compgen -c -- $cur ) )
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
return 0
; ;
--rcfile)
2002-02-27 15:48:20 +00:00
_filedir
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
return 0
; ;
2001-03-05 19:12:48 +00:00
--specfile)
# complete on .spec files
2002-05-18 17:05:08 +00:00
_filedir spec
2001-03-05 19:12:48 +00:00
return 0
; ;
--whatprovides)
2002-03-04 03:46:42 +00:00
if [ [ " $cur " = = */* ] ] ; then
_filedir
else
2001-03-05 19:12:48 +00:00
# complete on capabilities
2004-07-19 06:43:10 +00:00
COMPREPLY = ( $( rpm -qa $nodig $nosig --queryformat \
2002-04-03 21:17:10 +00:00
'%{providename}\n' | grep " ^ $cur " ) )
2002-03-04 03:46:42 +00:00
fi
2001-03-05 19:12:48 +00:00
return 0
; ;
--whatrequires)
# complete on capabilities
2004-07-19 06:43:10 +00:00
COMPREPLY = ( $( rpm -qa $nodig $nosig --queryformat \
2003-04-29 05:28:10 +00:00
'%{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 \
2002-05-05 18:20:02 +00:00
--eval --pipe --queryformat --repackage --nosuggests \
--nodigest --nosignature' -- $cur ) )
2002-03-29 07:30:47 +00:00
else
2002-05-19 14:56:19 +00:00
_filedir 'rpm'
2002-03-29 07:30:47 +00:00
fi
2000-08-11 21:20:41 +00:00
; ;
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
-@( e| -erase) )
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --allmatches --noscripts \
--notriggers --nodeps --test --repackage' -- $cur ) )
else
2009-01-11 16:13:32 +02:00
_rpm_installed_packages " $nodig " " $nosig "
2002-03-29 07:30:47 +00:00
fi
2000-08-11 21:20:41 +00:00
; ;
2002-03-29 07:30:47 +00:00
-@( q*| -query) )
2002-04-17 06:44:12 +00:00
# check whether we're doing file completion
if [ " ${ COMP_LINE #* -*([^ -])f } " != " $COMP_LINE " ] ; then
2003-11-03 22:28:55 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --scripts --root \
--rcfile --requires --ftpport --ftpproxy \
--httpproxy --httpport --provides --triggers \
--dump --changelog --dbpath \
--last --filesbypkg \
--info --list --state \
--docfiles --configfiles --queryformat \
--conflicts --obsoletes \
--nodigest --nosignature \
2009-02-02 22:24:38 +01:00
--suggests --enhances \
2003-11-03 22:28:55 +00:00
--triggerscripts' -- $cur ) )
else
2002-04-17 06:44:12 +00:00
_filedir
2003-11-03 22:28:55 +00:00
fi
2002-04-17 06:44:12 +00:00
elif [ " ${ COMP_LINE #* -*([^ -])g } " != " $COMP_LINE " ] ; then
2002-09-09 16:26:14 +00:00
_rpm_groups
2002-04-05 17:45:05 +00:00
elif [ " ${ COMP_LINE #* -*([^ -])p } " != " $COMP_LINE " ] ; then
2002-04-03 21:10:35 +00:00
# uninstalled package completion
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --scripts --root \
--rcfile --whatprovides --whatrequires \
--requires --triggeredby --ftpport --ftpproxy \
--httpproxy --httpport --provides --triggers \
--dump --changelog --dbpath --filesbypkg \
--define --eval --pipe --showrc --info --list \
2003-04-29 00:24:20 +00:00
--state --docfiles --configfiles --queryformat\
2002-05-05 18:20:02 +00:00
--conflicts --obsoletes --nodigest \
--nosignature' -- $cur ) )
2002-03-29 07:30:47 +00:00
else
2002-05-19 14:56:19 +00:00
_filedir 'rpm'
2002-03-29 07:30:47 +00:00
fi
2002-03-07 16:16:43 +00:00
else
2002-04-03 21:10:35 +00:00
# installed package completion
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --scripts --root \
--rcfile --whatprovides --whatrequires \
--requires --triggeredby --ftpport --ftpproxy \
--httpproxy --httpport --provides --triggers \
--dump --changelog --dbpath --specfile \
--querybynumber --last --filesbypkg --define \
--eval --pipe --showrc --info --list --state \
--docfiles --configfiles --queryformat \
--conflicts --obsoletes --pkgid --hdrid \
2003-07-21 08:05:34 +00:00
--fileid --tid --nodigest --nosignature \
--triggerscripts' -- $cur ) )
2002-04-05 17:45:05 +00:00
elif [ " ${ COMP_LINE #* -*([^ -])a } " = = " $COMP_LINE " ] ; then
2009-01-11 16:13:32 +02:00
_rpm_installed_packages " $nodig " " $nosig "
2002-03-29 07:30:47 +00:00
fi
2002-03-07 16:16:43 +00:00
fi
2001-08-22 15:20:27 +00:00
; ;
2002-12-04 04:32:06 +00:00
-@( K*| -checksig) )
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
2002-05-05 18:20:02 +00:00
COMPREPLY = ( $( compgen -W ' --nopgp --nogpg --nomd5 \
--nodigest --nosignature' -- $cur ) )
2002-03-29 07:30:47 +00:00
else
2002-05-19 14:56:19 +00:00
_filedir 'rpm'
2002-03-29 07:30:47 +00:00
fi
2000-08-11 21:20:41 +00:00
; ;
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
-@( [ Vy] *| -verify) )
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --root --rcfile --dbpath \
2003-07-11 06:48:07 +00:00
--nodeps --nogroup --nolinkto --nomode --nomtime \
--nordev --nouser --nofiles --noscripts --nomd5 \
--querytags --specfile --whatrequires --whatprovides \
--nodigest --nosignature' -- $cur ) )
2002-04-17 06:44:12 +00:00
# check whether we're doing file completion
elif [ " ${ COMP_LINE #* -*([^ -])f } " != " $COMP_LINE " ] ; then
_filedir
elif [ " ${ COMP_LINE #* -*([^ -])g } " != " $COMP_LINE " ] ; then
2002-09-09 16:26:14 +00:00
_rpm_groups
2002-04-05 17:45:05 +00:00
elif [ " ${ COMP_LINE #* -*([^ -])p } " != " $COMP_LINE " ] ; then
2002-05-19 14:56:19 +00:00
_filedir 'rpm'
2002-03-22 15:45:42 +00:00
else
2009-01-11 16:13:32 +02:00
_rpm_installed_packages " $nodig " " $nosig "
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 \
2003-08-03 01:07:38 +00:00
--target -- buildarch --buildos --nobuild --nodeps \
2002-03-29 07:30:47 +00:00
--nodirtokens' -- $cur ) )
elif [ [ ${ COMP_WORDS [1] } = = -b* ] ] ; then
2002-05-19 14:56:19 +00:00
_filedir 'spec'
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
else
2009-01-13 20:45:07 +02:00
_filedir '@(tgz|tar.@(gz|bz2|lzma))'
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 \
2003-08-03 01:07:38 +00:00
--rmspec --sign --nodirtokens --target' -- $cur ) )
2002-03-29 07:30:47 +00:00
else
2003-08-18 07:33:29 +00:00
_filedir '?(no)src.rpm'
2002-03-29 07:30:47 +00:00
fi
2000-08-11 21:20:41 +00:00
; ;
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
--tarbuild)
2009-01-13 20:45:07 +02:00
_filedir '@(tgz|tar.@(gz|bz2|lzma))'
rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.)
some minor bug fixes to rpm completion; code tidied in places
added some outstanding long options to rpm completion (--install, --freshen,
--upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.)
added -g group completion
2000-11-20 20:41:43 +00:00
; ;
--@( re| add) sign)
2002-05-19 14:56:19 +00:00
_filedir 'rpm'
2000-08-11 21:20:41 +00:00
; ;
--set@( perms| gids) )
2009-01-11 16:13:32 +02:00
_rpm_installed_packages " $nodig " " $nosig "
2000-08-11 21:20:41 +00:00
; ;
2002-01-30 04:04:28 +00:00
--@( clean| rms@( ource| pec) ) )
2002-03-29 07:30:47 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --clean --rmsource \
--rmspec' -- $cur ) )
else
2002-05-19 14:56:19 +00:00
_filedir 'spec'
2002-03-29 07:30:47 +00:00
fi
2000-12-20 02:04:54 +00:00
; ;
2002-05-05 18:20:02 +00:00
--@( import| dbpath| root) )
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '--import --dbpath --root' \
-- $cur ) )
else
_filedir
fi
; ;
2000-08-11 21:20:41 +00:00
esac
2000-08-29 00:41:27 +00:00
return 0
2000-08-11 21:20:41 +00:00
}
2002-04-29 18:58:39 +00:00
complete -F _rpm $filenames rpm rpmbuild
}
2000-08-11 21:20:41 +00:00
2002-05-09 16:20:53 +00:00
# Debian apt-get(8) completion.
2000-10-09 18:07:50 +00:00
#
2001-07-08 23:14:13 +00:00
have apt-get &&
2002-02-27 00:24:04 +00:00
_apt_get( )
2000-10-09 18:07:50 +00:00
{
2001-11-20 04:15:48 +00:00
local cur prev special i
2000-10-09 18:07:50 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2001-12-18 03:43:25 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-10-09 18:07:50 +00:00
2003-05-17 07:55:11 +00:00
for ( ( i = 0; i < ${# COMP_WORDS [@] } -1; i++ ) ) ; do
2008-05-10 18:04:06 +02:00
if [ [ ${ COMP_WORDS [i] } = = @( install| remove| autoremove| purge| source| build-dep) ] ] ; then
2000-10-09 18:07:50 +00:00
special = ${ COMP_WORDS [i] }
fi
done
2002-10-02 01:32:40 +00:00
2000-10-09 18:07:50 +00:00
if [ -n " $special " ] ; then
case $special in
2008-05-10 18:04:06 +02:00
remove| autoremove| purge)
2002-04-07 17:17:13 +00:00
if [ -f /etc/debian_version ] ; then
# Debian system
2004-10-15 04:47:39 +00:00
COMPREPLY = ( $( _comp_dpkg_installed_packages \
2002-04-07 17:17:13 +00:00
$cur ) )
else
# assume RPM based
2002-09-09 16:26:14 +00:00
_rpm_installed_packages
2002-04-07 17:17:13 +00:00
fi
return 0
; ;
2002-10-13 01:46:49 +00:00
*)
COMPREPLY = ( $( apt-cache pkgnames $cur 2> /dev/null ) )
return 0
; ;
2000-10-09 18:07:50 +00:00
esac
fi
2002-10-02 01:32:40 +00:00
case " $prev " in
-@( c| -config-file) )
_filedir
return 0
; ;
-@( t| -target-release| -default-release) )
COMPREPLY = ( $( apt-cache policy | \
grep " release.o=Debian,a= $cur " | \
2008-05-01 22:22:11 +02:00
sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) )
2002-10-02 01:32:40 +00:00
return 0
; ;
2008-05-06 20:20:14 +01:00
2002-10-13 01:46:49 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -d -f -h -v -m -q -s -y \
2002-10-02 01:32:40 +00:00
-u -t -b -c -o --download-only --fix-broken \
--help --version --ignore-missing \
--fix-missing --no-download --quiet --simulate \
--just-print --dry-run --recon --no-act --yes \
--assume-yes --show-upgraded --only-source \
--compile --build --ignore-hold \
--target-release --no-upgrade --force-yes \
--print-uris --purge --reinstall \
--list-cleanup --default-release \
--trivial-only --no-remove --diff-only \
2008-05-10 18:04:06 +02:00
--no-install-recommends \
2008-05-01 22:22:11 +02:00
--tar-only --config-file --option --auto-remove' -- $cur ) )
2002-10-13 01:46:49 +00:00
else
COMPREPLY = ( $( compgen -W ' update upgrade dselect-upgrade \
2008-05-01 22:22:11 +02:00
dist-upgrade install remove purge source build-dep \
check clean autoclean autoremove' -- $cur ) )
2002-10-13 01:46:49 +00:00
fi
2000-10-09 18:07:50 +00:00
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _apt_get $filenames apt-get
2000-10-09 18:07:50 +00:00
2002-05-09 16:20:53 +00:00
# Debian apt-cache(8) completion.
2000-10-09 18:07:50 +00:00
#
2001-07-08 23:14:13 +00:00
have apt-cache &&
2002-02-27 00:24:04 +00:00
_apt_cache( )
2000-10-09 18:07:50 +00:00
{
2001-11-20 04:15:48 +00:00
local cur prev special i
2000-10-09 18:07:50 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2001-12-18 03:43:25 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-10-09 18:07:50 +00:00
2008-05-06 20:20:14 +01:00
2002-10-13 01:46:49 +00:00
if [ " $cur " != show ] ; then
2003-05-17 07:55:11 +00:00
for ( ( i = 0; i < ${# COMP_WORDS [@] } -1; i++ ) ) ; do
2008-05-01 22:22:11 +02:00
if [ [ ${ COMP_WORDS [i] } = = @( add| depends| dotty| madison| policy| rdepends| show?( pkg| src| ) ) ] ] ; then
2002-10-13 01:46:49 +00:00
special = ${ COMP_WORDS [i] }
2000-10-09 18:07:50 +00:00
fi
2002-10-13 01:46:49 +00:00
done
fi
2002-10-02 01:32:40 +00:00
2000-10-09 18:07:50 +00:00
if [ -n " $special " ] ; then
2002-10-13 01:46:49 +00:00
case $special in
2000-10-09 18:07:50 +00:00
add)
2002-10-13 01:46:49 +00:00
_filedir
return 0
; ;
2008-05-06 20:20:14 +01:00
2008-09-06 19:28:52 +02:00
showsrc)
COMPREPLY = ( $( apt-cache dumpavail | \
grep " ^Source: $cur " | sort | \
uniq | cut -f2 -d" " ) )
return 0
; ;
2002-10-13 01:46:49 +00:00
*)
COMPREPLY = ( $( apt-cache pkgnames $cur 2> /dev/null ) )
return 0
; ;
2008-05-06 20:20:14 +01:00
2002-10-13 01:46:49 +00:00
esac
2000-10-09 18:07:50 +00:00
fi
2002-10-02 01:32:40 +00:00
case " $prev " in
-@( c| p| s| -config-file| -@( pkg| src) -cache) )
_filedir
return 0
; ;
2002-10-13 01:46:49 +00:00
search)
2003-05-26 16:22:44 +00:00
if [ [ " $cur " != -* ] ] ; then
return 0
fi
2002-10-13 01:46:49 +00:00
; ;
esac
2002-10-02 01:32:40 +00:00
2002-10-13 01:46:49 +00:00
if [ [ " $cur " = = -* ] ] ; then
2002-10-02 01:32:40 +00:00
2002-10-13 01:46:49 +00:00
COMPREPLY = ( $( compgen -W ' -h -v -p -s -q -i -f -a -g -c \
2000-10-09 18:07:50 +00:00
-o --help --version --pkg-cache --src-cache \
--quiet --important --full --all-versions \
2003-12-12 10:10:49 +00:00
--no-all-versions --generate --no-generate \
--names-only --all-names --recurse \
2008-06-23 13:35:19 +02:00
--config-file --option --installed' -- $cur ) )
2002-10-13 01:46:49 +00:00
else
2004-10-14 14:57:41 +00:00
COMPREPLY = ( $( compgen -W ' add gencaches show showpkg showsrc \
2003-12-12 10:10:49 +00:00
stats dump dumpavail unmet search search \
depends rdepends pkgnames dotty xvcg \
2008-05-01 22:22:11 +02:00
policy madison' -- $cur ) )
2002-10-13 01:46:49 +00:00
fi
2000-10-09 18:07:50 +00:00
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _apt_cache $filenames apt-cache
2002-10-13 01:46:49 +00:00
2000-10-09 18:07:50 +00:00
2002-09-28 16:12:24 +00:00
# Debian aptitude(1) completion
2002-05-05 17:24:31 +00:00
#
2002-05-11 07:28:58 +00:00
have aptitude && {
2006-02-23 21:55:44 +00:00
have grep-status && {
_comp_dpkg_hold_packages( )
{
grep-status -P -e " ^ $1 " -a -FStatus 'hold' -n -s Package
}
} || {
2004-02-25 03:03:28 +00:00
_comp_dpkg_hold_packages( )
2002-05-11 07:28:58 +00:00
{
2002-05-30 18:17:29 +00:00
grep -B 2 'hold' /var/lib/dpkg/status | grep " Package: $1 " \
2002-05-19 07:16:30 +00:00
| cut -d\ -f2
2002-05-11 07:28:58 +00:00
}
2006-02-23 21:55:44 +00:00
}
2002-05-11 07:28:58 +00:00
2002-05-05 17:24:31 +00:00
_aptitude( )
{
local cur dashoptions prev special i
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-05-05 17:24:31 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-09-28 16:12:24 +00:00
dashoptions = ' -S -u -i -h --help --version -s --simulate -d \
2002-05-05 17:24:31 +00:00
--download-only -P --prompt -y --assume-yes -F \
2004-06-01 06:02:57 +00:00
--display-format -O --sort -w --width -f -r -g \
2005-01-13 01:22:45 +00:00
--with-recommends --with-suggests -R -G \
--without-recommends --without-suggests -t \
--target-release -V --show-versions -D --show-deps\
2008-10-24 22:12:09 +02:00
-Z -v --verbose --purge-unused --schedule-only'
2002-05-05 17:24:31 +00:00
2003-05-17 07:55:11 +00:00
for ( ( i = 0; i < ${# COMP_WORDS [@] } -1; i++ ) ) ; do
2008-11-22 18:10:38 +01:00
if [ [ ${ COMP_WORDS [i] } = = @( install| reinstall| hold| unhold| markauto| unmarkauto| dist-upgrade| full-upgrade| download| show| forbid-version| purge| remove| changelog| why| why-not| keep| keep-all| build-dep) ] ] ; then
2002-05-05 17:24:31 +00:00
special = ${ COMP_WORDS [i] }
fi
2002-05-08 15:38:56 +00:00
#exclude some mutually exclusive options
2002-05-05 17:24:31 +00:00
[ [ ${ COMP_WORDS [i] } = = '-u' ] ] && dashoptions = ${ dashoptions /-i }
[ [ ${ COMP_WORDS [i] } = = '-i' ] ] && dashoptions = ${ dashoptions /-u }
done
if [ [ -n " $special " ] ] ; then
case $special in
2008-11-22 18:10:38 +01:00
@( install| hold| markauto| unmarkauto| dist-upgrade| full-upgrade| download| show| changelog| why| why-not| build-dep) )
2002-10-05 06:08:53 +00:00
COMPREPLY = ( $( apt-cache pkgnames $cur 2> /dev/null ) )
2002-09-28 16:12:24 +00:00
return 0
2002-05-05 17:24:31 +00:00
; ;
2004-06-01 06:02:57 +00:00
@( purge| remove| reinstall| forbid-version) )
2004-10-15 04:47:39 +00:00
COMPREPLY = ( $( _comp_dpkg_installed_packages $cur ) )
2002-09-28 16:12:24 +00:00
return 0
2002-05-05 17:24:31 +00:00
; ;
unhold)
2005-02-08 20:50:01 +00:00
COMPREPLY = ( $( _comp_dpkg_hold_packages $cur ) )
2002-09-28 16:12:24 +00:00
return 0
2002-05-05 17:24:31 +00:00
; ;
esac
fi
case $prev in
2002-05-19 07:16:30 +00:00
# don't complete anything if these options are found
2008-05-01 22:22:11 +02:00
@( autoclean| clean| forget-new| search| upgrade| safe-upgrade| update| keep-all) )
2002-09-28 16:12:24 +00:00
return 0
2002-05-05 17:24:31 +00:00
; ;
2004-06-01 06:02:57 +00:00
2002-05-05 17:24:31 +00:00
-S)
2002-09-28 16:12:24 +00:00
_filedir
2002-05-05 17:24:31 +00:00
return 0
; ;
2004-06-01 06:02:57 +00:00
-@( t| -target-release| -default-release) )
COMPREPLY = ( $( apt-cache policy | \
grep " release.o=Debian,a= $cur " | \
2008-05-01 22:59:32 +02:00
sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ) )
2004-06-01 06:02:57 +00:00
return 0
; ;
2002-05-05 17:24:31 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W " $dashoptions " -- $cur ) )
else
2008-05-01 22:22:11 +02:00
COMPREPLY = ( $( compgen -W ' update upgrade safe-upgrade forget-new clean \
2004-06-01 06:02:57 +00:00
autoclean install reinstall remove \
2008-05-01 22:22:11 +02:00
hold unhold purge markauto unmarkauto why why-not \
dist-upgrade full-upgrade download search show \
forbid-version changelog keep-all' -- $cur ) )
2002-05-05 17:24:31 +00:00
fi
2002-10-13 01:46:49 +00:00
return 0
2002-05-05 17:24:31 +00:00
}
2005-07-07 23:36:51 +00:00
complete -F _aptitude $default aptitude
2002-05-11 07:28:58 +00:00
}
2002-05-05 17:24:31 +00:00
2002-07-31 23:11:14 +00:00
# Debian apt-build(1) completion.
#
2002-09-28 16:48:02 +00:00
have apt-build &&
2002-10-02 01:32:40 +00:00
_apt_build( )
2002-07-31 23:11:14 +00:00
{
local cur prev special i
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-07-31 23:11:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2003-05-17 07:55:11 +00:00
for ( ( i = 0; i < ${# COMP_WORDS [@] } -1; i++ ) ) ; do
2002-09-28 16:33:12 +00:00
if [ [ ${ COMP_WORDS [i] } = = @( install| remove| source| info| clean) ] ] ; then
2002-07-31 23:11:14 +00:00
special = ${ COMP_WORDS [i] }
fi
done
2002-09-28 16:33:12 +00:00
2002-07-31 23:11:14 +00:00
if [ -n " $special " ] ; then
case $special in
2002-09-28 16:33:12 +00:00
@( install| source| info) )
2002-10-05 06:08:53 +00:00
COMPREPLY = ( $( apt-cache pkgnames $cur 2> /dev/null ) )
2002-07-31 23:11:14 +00:00
return 0
; ;
remove)
2004-10-15 04:47:39 +00:00
COMPREPLY = ( $( _comp_dpkg_installed_packages \
2002-09-28 16:33:12 +00:00
$cur ) )
return 0
; ;
*)
2002-07-31 23:11:14 +00:00
return 0
; ;
esac
fi
2002-10-02 01:32:40 +00:00
case " $prev " in
--@( patch| build-dir| repository-dir) )
_filedir
return 0
; ;
2008-05-06 20:20:14 +01:00
2002-10-02 01:32:40 +00:00
-@( h| -help) )
return 0
; ;
2002-07-31 23:11:14 +00:00
2002-10-13 01:46:49 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --help --show-upgraded -u --build-dir \
2002-10-02 01:32:40 +00:00
--repository-dir --build-only \
--build-command --reinstall --rebuild \
--remove-builddep --no-wrapper --purge \
--patch --patch-strip -p --yes -y \
2002-10-13 01:46:49 +00:00
--version -v --no-source' -- $cur ) )
else
COMPREPLY = ( $( compgen -W ' update upgrade install remove \
source dist-upgrade world clean info \
2002-10-17 00:53:37 +00:00
clean-build update-repository ' -- $cur ) )
2002-10-13 01:46:49 +00:00
fi
2002-07-31 23:11:14 +00:00
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _apt_build $filenames apt-build
2002-07-31 23:11:14 +00:00
2000-08-29 00:41:27 +00:00
# chsh(1) completion
#
2000-08-11 21:20:41 +00:00
_chsh( )
{
local cur prev
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2001-12-18 03:43:25 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-08-11 21:20:41 +00:00
if [ " $prev " = "-s" ] ; then
2004-02-13 07:47:38 +00:00
if [ -f /etc/debian_version ] ; then
COMPREPLY = ( $( </etc/shells ) )
else
COMPREPLY = ( $( chsh -l | grep " ^ $cur " ) )
fi
2000-08-11 21:20:41 +00:00
else
2004-02-13 07:47:38 +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 = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2001-12-18 03:43:25 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-08-11 21:20:41 +00:00
case " $prev " in
@( [ 1-6] | --@( list| add| del) ) )
2004-05-24 07:50:30 +00:00
_services
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
2004-05-24 07:50:30 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '--list --add --del --level' -- $cur ) )
else
if [ $COMP_CWORD -eq 2 -o $COMP_CWORD -eq 4 ] ; then
COMPREPLY = ( $( compgen -W 'on off reset' -- $cur ) )
else
_services
fi
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _chkconfig chkconfig
2000-08-11 21:20:41 +00:00
2002-10-05 05:52:37 +00:00
# This function provides simple user@host completion
2002-07-22 16:57:28 +00:00
#
_user_at_host( ) {
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-07-22 16:57:28 +00:00
if [ [ $cur = = *@* ] ] ; then
_known_hosts
else
2004-10-15 04:42:27 +00:00
COMPREPLY = ( $( compgen -u -- " $cur " ) )
2002-07-22 16:57:28 +00:00
fi
return 0
}
2002-12-10 00:30:08 +00:00
shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
2002-07-22 16:57:28 +00:00
2002-01-08 04:49:06 +00:00
# This function performs host completion based on ssh's known_hosts files,
# defaulting to standard host completion if they don't exist.
2000-08-29 00:41:27 +00:00
#
2008-11-01 12:25:38 +01:00
# Arguments: -a Use aliases
# -c Use `:' suffix
# -F configfile Use `configfile' for configuration settings
2000-09-25 21:38:11 +00:00
_known_hosts( )
2000-08-29 00:41:27 +00:00
{
2008-11-01 12:25:38 +01:00
local configfile
local cur curd ocur user suffix aliases global_kh user_kh hosts i host
local -a kh khd config
2000-08-29 00:41:27 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-05-17 22:35:26 +00:00
ocur = $cur
2008-11-01 12:25:38 +01:00
local OPTIND = 1
while getopts "acF:" flag " $@ " ; do
case $flag in
a) aliases = 'yes' ; ;
c) suffix = ':' ; ;
F) configfile = " $OPTARG " ; ;
esac
done
2002-01-16 07:14:14 +00:00
[ [ $cur = = *@* ] ] && user = ${ cur %@* } @ && cur = ${ cur #*@ }
2001-03-05 19:12:48 +00:00
kh = ( )
2000-09-11 18:46:39 +00:00
2002-05-05 23:31:28 +00:00
# ssh config files
2008-11-01 12:25:38 +01:00
if [ -n " $configfile " ] ; then
[ -r " $configfile " ] &&
config = ( " ${ config [@] } " " $configfile " )
else
[ -r /etc/ssh/ssh_config ] &&
config = ( " ${ config [@] } " "/etc/ssh/ssh_config" )
[ -r " ${ HOME } /.ssh/config " ] &&
config = ( " ${ config [@] } " " ${ HOME } /.ssh/config " )
[ -r " ${ HOME } /.ssh2/config " ] &&
config = ( " ${ config [@] } " " ${ HOME } /.ssh2/config " )
fi
2002-05-05 23:31:28 +00:00
if [ ${# config [@] } -gt 0 ] ; then
# expand path (if present) to global known hosts file
2008-11-08 09:48:11 +01:00
global_kh = $( eval echo " $( sed -ne 's/^[ \t]*[Gg][Ll][Oo][Bb][Aa][Ll][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][' " $'\t ' " ']*\(.*\)$/\1/p' " ${ config [@] } " ) " )
2002-05-05 23:31:28 +00:00
# expand path (if present) to user known hosts file
2008-11-08 09:48:11 +01:00
user_kh = $( eval echo " $( sed -ne 's/^[ \t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][' " $'\t ' " ']*\(.*\)$/\1/p' " ${ config [@] } " ) " )
2002-05-05 23:31:28 +00:00
fi
2008-06-23 11:28:11 +02:00
# Global known_hosts files
[ -r " $global_kh " ] &&
kh = ( " ${ kh [@] } " " $global_kh " )
2008-11-01 12:25:38 +01:00
if [ -z " $configfile " ] ; then
[ -r /etc/ssh/ssh_known_hosts ] &&
kh = ( " ${ kh [@] } " /etc/ssh/ssh_known_hosts )
[ -r /etc/ssh/ssh_known_hosts2 ] &&
kh = ( " ${ kh [@] } " /etc/ssh/ssh_known_hosts2 )
[ -r /etc/known_hosts ] &&
kh = ( " ${ kh [@] } " /etc/known_hosts )
[ -r /etc/known_hosts2 ] &&
kh = ( " ${ kh [@] } " /etc/known_hosts2 )
[ -d /etc/ssh2/knownhosts ] &&
khd = ( " ${ khd [@] } " /etc/ssh2/knownhosts/*pub )
fi
2008-06-23 11:28:11 +02:00
# User known_hosts files
[ -r " $user_kh " ] &&
kh = ( " ${ kh [@] } " " $user_kh " )
2008-11-01 12:25:38 +01:00
if [ -z " $configfile " ] ; then
[ -r ~/.ssh/known_hosts ] &&
kh = ( " ${ kh [@] } " ~/.ssh/known_hosts )
[ -r ~/.ssh/known_hosts2 ] &&
kh = ( " ${ kh [@] } " ~/.ssh/known_hosts2 )
[ -d ~/.ssh2/hostkeys ] &&
khd = ( " ${ khd [@] } " ~/.ssh2/hostkeys/*pub )
fi
2000-08-29 00:41:27 +00:00
# If we have known_hosts files to use
2008-11-01 12:25:38 +01:00
if [ ${# kh [@] } -gt 0 -o ${# khd [@] } -gt 0 -o -n " $configfile " ] ; then
2002-01-16 07:14:14 +00:00
# Escape slashes and dots in paths for awk
cur = ${ cur // \/ / \\ \/ }
cur = ${ cur // \. / \\ \. }
2005-01-19 03:41:36 +00:00
curd = $cur
2002-05-17 22:35:26 +00:00
2001-12-05 16:32:24 +00:00
if [ [ " $cur " = = [ 0-9] *.* ] ] ; then
2000-09-11 18:46:39 +00:00
# Digits followed by a dot - just search for that
cur = " ^ $cur .* "
2001-12-05 16:32:24 +00:00
elif [ [ " $cur " = = [ 0-9] * ] ] ; then
2000-09-11 18:46:39 +00:00
# Digits followed by no dot - search for digits followed
# by a dot
cur = " ^ $cur .*\. "
2001-12-05 16:32:24 +00:00
elif [ -z " $cur " ] ; then
2000-09-11 18:46:39 +00:00
# A blank - search for a dot or an alpha character
cur = "[a-z.]"
else
cur = " ^ $cur "
fi
2002-05-17 22:35:26 +00:00
2005-01-19 03:41:36 +00:00
if [ ${# kh [@] } -gt 0 ] ; then
# FS needs to look for a comma separated list
COMPREPLY = ( $( awk ' BEGIN { FS = "," }
2009-01-16 23:05:07 +01:00
/^\s *[ ^| \# ] / { for ( i = 1; i<= 2; ++i) { \
2001-11-20 04:15:48 +00:00
gsub( " .* $" , "" , $i ) ; \
2000-09-11 18:46:39 +00:00
if ( $i ~ /'$cur' /) { print $i } \
2008-06-21 22:19:37 +02:00
} } ' " ${ kh [@] } " 2>/dev/null ) )
2005-01-19 03:41:36 +00:00
fi
if [ ${# khd [@] } -gt 0 ] ; then
# Needs to look for files called
# .../.ssh2/key_22_<hostname>.pub
2008-05-06 20:20:14 +01:00
# dont fork any processes, because in a cluster environment,
2005-01-19 03:41:36 +00:00
# there can be hundreds of hostkeys
2008-06-21 22:19:37 +02:00
for i in " ${ khd [@] } " ; do
2005-01-19 03:41:36 +00:00
if [ [ " $i " = = *key_22_$curd *.pub ] ] && [ -r " $i " ] ; then
host = ${ i /#*key_22_/ }
host = ${ host /%.pub/ }
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $host )
2005-01-19 03:41:36 +00:00
fi
done
fi
2002-05-17 22:35:26 +00:00
# append any available aliases from config files
if [ ${# config [@] } -gt 0 ] && [ -n " $aliases " ] ; then
2008-11-01 12:32:22 +01:00
local host_aliases = $( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?[' " $'\t ' " ']\+\([^#*?]*\)\(#.*\)\?$/\2/p' " ${ config [@] } " )
2008-05-01 22:22:11 +02:00
hosts = $( compgen -W " $host_aliases " -- $ocur )
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $hosts )
2002-05-17 22:35:26 +00:00
fi
2008-05-06 20:20:14 +01:00
2008-05-01 22:59:32 +02:00
# Now add results of normal hostname completion
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $( compgen -A hostname -- $ocur ) )
2002-05-17 22:35:26 +00:00
# apply suffix
2002-01-16 07:14:14 +00:00
for ( ( i = 0; i < ${# COMPREPLY [@] } ; i++ ) ) ; do
2002-02-11 02:14:08 +00:00
COMPREPLY[ i] = $user ${ COMPREPLY [i] } $suffix
2002-01-16 07:14:14 +00:00
done
2008-11-01 12:25:38 +01:00
elif [ -z " $configfile " ] ; then
2000-08-29 00:41:27 +00:00
# Just do normal hostname completion
2002-02-27 00:41:56 +00:00
COMPREPLY = ( $( compgen -A hostname -S " $suffix " -- $cur ) )
2000-08-29 00:41:27 +00:00
fi
return 0
}
2002-12-10 00:30:08 +00:00
complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \
2008-05-01 22:22:11 +02:00
ping ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr
2000-09-25 21:38:11 +00:00
2003-01-30 07:56:28 +00:00
# rsync(1) completion
#
have rsync &&
_rsync( )
{
local cur prev shell i userhost path
2008-05-06 20:20:14 +01:00
2003-01-30 07:56:28 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-01-30 07:56:28 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
_expand || return 0
case " $prev " in
--@( config| password-file| include-from| exclude-from) )
_filedir
return 0
; ;
-@( T| -temp-dir| -compare-dest) )
_filedir -d
return 0
; ;
-@( e| -rsh) )
COMPREPLY = ( $( compgen -W 'rsh ssh' -- $cur ) )
return 0
; ;
esac
2008-05-06 20:20:14 +01:00
2003-01-30 07:56:28 +00:00
case " $cur " in
-*)
COMPREPLY = ( $( compgen -W ' -v -q -c -a -r -R -b -u -l -L -H \
-p -o -g -D -t -S -n -W -x -B -e -C -I -T -P \
-z -h -4 -6 --verbose --quiet --checksum \
--archive --recursive --relative --backup \
--backup-dir --suffix= --update --links \
--copy-links --copy-unsafe-links --safe-links \
--hard-links --perms --owner --group --devices\
--times --sparse --dry-run --whole-file \
--no-whole-file --one-file-system \
--block-size= --rsh= --rsync-path= \
--cvs-exclude --existing --ignore-existing \
--delete --delete-excluded --delete-after \
--ignore-errors --max-delete= --partial \
--force --numeric-ids --timeout= \
--ignore-times --size-only --modify-window= \
--temp-dir= --compare-dest= --compress \
--exclude= --exclude-from= --include= \
--include-from= --version --daemon --no-detach\
--address= --config= --port= --blocking-io \
--no-blocking-io --stats --progress \
--log-format= --password-file= --bwlimit= \
--write-batch= --read-batch= --help' -- $cur ) )
; ;
*:*)
# find which remote shell is used
2008-09-06 16:39:42 +02:00
shell = ssh
2003-01-30 07:56:28 +00:00
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = -@( e| -rsh) ] ] ; then
shell = ${ COMP_WORDS [i+1] }
break
fi
done
if [ [ " $shell " = = ssh ] ] ; then
# remove backslash escape from :
cur = ${ cur / \\ : / : }
userhost = ${ cur %%?( \\ ) : * }
path = ${ cur #* : }
# unescape spaces
path = ${ path // \\ \\ \\ \\ / }
if [ -z " $path " ] ; then
# default to home dir of specified
# user on remote host
path = $( ssh -o 'Batchmode yes' \
$userhost pwd 2>/dev/null)
fi
# escape spaces; remove executables, aliases, pipes
# and sockets; add space at end of file names
COMPREPLY = ( $( ssh -o 'Batchmode yes' $userhost \
command ls -aF1d " $path * " 2>/dev/null | \
sed -e 's/ /\\\\\\\ /g' -e 's/[*@|=]$//g' \
-e 's/[^\/]$/& /g' ) )
fi
; ;
*)
_known_hosts -c -a
_filedir
; ;
esac
2008-05-06 20:20:14 +01:00
2003-01-30 07:56:28 +00:00
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _rsync $nospace $filenames rsync
2003-01-30 07:56:28 +00:00
2002-03-15 16:39:18 +00:00
# Linux route(8) completion
2000-09-11 18:46:39 +00:00
#
2002-04-22 05:59:08 +00:00
[ $UNAME = Linux ] &&
2000-09-11 18:46:39 +00:00
_route( )
{
local cur prev
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2001-12-18 03:43:25 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-09-11 18:46:39 +00:00
if [ " $prev " = dev ] ; then
2002-03-01 00:42:13 +00:00
COMPREPLY = ( $( ifconfig -a | sed -ne 's|^\(' $cur '[^ ]*\).*$|\1|p' ) )
2000-09-11 18:46:39 +00:00
return 0
fi
COMPREPLY = ( $( compgen -W ' add del -host -net netmask metric mss \
2002-04-03 19:10:49 +00:00
window irtt reject mod dyn reinstate dev \
default gw' -- $cur ) )
2000-09-11 18:46:39 +00:00
COMPREPLY = ( $( echo " ${ COMP_WORDS [@] } " | \
( while read -d ' ' i; do
[ " $i " = = "" ] && continue
# flatten array with spaces on either side,
# otherwise we cannot grep on word
# boundaries of first and last word
COMPREPLY = " ${ COMPREPLY [@] } "
# remove word from list of completions
COMPREPLY = ( ${ COMPREPLY / $i / } )
done
2008-06-21 22:19:37 +02:00
echo " ${ COMPREPLY [@] } " )
2000-09-11 18:46:39 +00:00
) )
return 0
}
2002-04-22 05:59:08 +00:00
[ $UNAME = Linux ] && complete -F _route route
2000-09-11 18:46:39 +00:00
2004-10-14 07:24:15 +00:00
# GNU make(1) completion
2000-09-25 21:38:11 +00:00
#
2005-07-07 21:35:09 +00:00
have make || have gmake || have gnumake || have pmake &&
2000-09-25 21:38:11 +00:00
_make( )
{
2005-01-03 02:11:55 +00:00
local file makef makef_dir = "." makef_inc cur prev i
2000-09-25 21:38:11 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2001-12-18 03:43:25 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2000-09-25 21:38:11 +00:00
2003-08-05 15:41:40 +00:00
# --name value style option
2003-08-03 01:19:30 +00:00
case $prev in
-@( f| o| W) )
_filedir
return 0
; ;
-@( I| C) )
_filedir -d
return 0
; ;
esac
2002-02-27 01:18:08 +00:00
2003-08-05 15:41:40 +00:00
# --name=value style option
if [ [ " $cur " = = *= * ] ] ; then
prev = ${ cur /=*/ }
cur = ${ cur /*=/ }
case " $prev " in
--@( file| makefile) )
_filedir
return 0
; ;
--@( directory| include-dir) )
_filedir -d
return 0
; ;
esac
fi
2000-09-25 21:38:11 +00:00
2002-02-27 00:41:56 +00:00
if [ [ " $cur " = = -* ] ] ; then
2003-08-03 01:19:30 +00:00
COMPREPLY = ( $( compgen -W ' -b -m -B -C -d -e -f -h -i -I\
-j -l -k -n -o -p -q -r -R - s -S -t -v -w -W \
--always-make --directory= --debug \
--environment-overrides --file= --makefile= --help \
--ignore-errors --include-dir= --jobs --load-average \
--max-load --keep-going --just-print --dry-run \
--recon --old-file= --assume-old= --print-data-base \
--question --no-builtin-rules --no-builtin-variables \
--silent --quiet --no-keep-goind --stop --touch \
--version --print-directory --no-print-directory \
--what-if= --new-file= --assume-new= \
--warn-undefined-variables' -- $cur ) )
2003-08-03 02:02:32 +00:00
else
2005-01-03 02:11:55 +00:00
# before we check for makefiles, see if a path was specified
# with -C
for ( ( i = 0; i < ${# COMP_WORDS [@] } ; i++ ) ) ; do
if [ [ ${ COMP_WORDS [i] } = = -C ] ] ; then
# eval for tilde expansion
eval makef_dir = ${ COMP_WORDS [i+1] }
break
fi
done
# before we scan for targets, see if a Makefile name was
# specified with -f
2003-08-03 01:19:30 +00:00
for ( ( i = 0; i < ${# COMP_WORDS [@] } ; i++ ) ) ; do
if [ [ ${ COMP_WORDS [i] } = = -f ] ] ; then
# eval for tilde expansion
eval makef = ${ COMP_WORDS [i+1] }
break
fi
done
2001-12-18 03:43:25 +00:00
2008-12-11 20:13:16 +01:00
[ -n " $makef " ] && makef = " -f ${ makef } "
[ -n " $makef_dir " ] && makef_dir = " -C ${ makef_dir } "
COMPREPLY = ( $( make -qp $makef $makef_dir 2>/dev/null | \
awk -F':' ' /^[ a-zA-Z0-9] [ ^$# \/ \t = ] *:( [ ^= ] | $) / \
{ split( $1 ,A,/ /) ; for ( i in A) print A[ i] } ' | \
command grep " ^ $cur " ) )
2004-10-14 07:24:15 +00:00
2003-08-03 01:19:30 +00:00
fi
2005-07-07 23:36:51 +00:00
} &&
2006-02-24 22:55:13 +00:00
complete -f -F _make $filenames make gmake gnumake pmake
2001-01-10 23:09:48 +00:00
2002-03-19 15:19:58 +00:00
# GNU tar(1) completion
2001-07-08 23:14:13 +00:00
#
_tar( )
{
2002-06-02 20:19:38 +00:00
local cur ext regex tar untar
2001-07-08 23:14:13 +00:00
2001-12-18 03:43:25 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2001-07-08 23:14:13 +00:00
2002-06-01 16:46:19 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
2002-03-07 17:47:12 +00:00
COMPREPLY = ( $( compgen -W 'c t x u r d A' -- $cur ) )
return 0
fi
2002-02-21 19:26:36 +00:00
2002-02-18 18:21:14 +00:00
case " ${ COMP_WORDS [1] } " in
2008-05-01 22:59:32 +02:00
?( -) [ cr] *f)
2002-02-18 18:21:14 +00:00
_filedir
2002-06-02 20:19:38 +00:00
return 0
2002-02-18 18:21:14 +00:00
; ;
2009-01-13 20:45:07 +02:00
+( [ ^IZzJjy] ) f)
ext = 't@(ar?(.@(Z|gz|bz?(2)|lz?(ma)))|gz|bz?(2)|lz?(ma))'
2009-03-16 05:49:06 -04:00
regex = 't\(ar\(\.\(Z\|gz\|bz2\?\|lzma\|xz\)\)\?\|gz\|bz2\?\|lzma\|xz\)'
2002-02-18 18:21:14 +00:00
; ;
2004-06-18 05:40:28 +00:00
*[ Zz] *f)
2002-12-16 19:48:58 +00:00
ext = 't?(ar.)@(gz|Z)'
2005-07-19 04:32:31 +00:00
regex = 't\(ar\.\)\?\(gz\|Z\)'
2002-02-18 18:21:14 +00:00
; ;
2002-03-26 15:27:02 +00:00
*[ Ijy] *f)
2002-06-17 14:40:59 +00:00
ext = 't?(ar.)bz?(2)'
2005-07-19 04:32:31 +00:00
regex = 't\(ar\.\)\?bz2\?'
2002-02-18 18:21:14 +00:00
; ;
2009-01-13 20:45:07 +02:00
*[ J] *f)
2009-03-16 05:49:06 -04:00
ext = 't?(ar.)@(lz?(ma)|xz)'
regex = 't\(ar\.\)\?\(lzma\|xz\)\?'
2009-01-13 20:45:07 +02:00
; ;
2002-02-18 18:21:14 +00:00
*)
_filedir
2002-06-02 20:19:38 +00:00
return 0
2002-02-18 18:21:14 +00:00
; ;
2008-05-06 20:20:14 +01:00
2002-02-18 18:21:14 +00:00
esac
2001-07-08 23:14:13 +00:00
2002-06-11 16:49:57 +00:00
if [ [ " $COMP_LINE " = = *$ext ' ' ] ] ; then
2002-06-02 20:19:38 +00:00
# complete on files in tar file
#
# get name of tar file from command line
tar = $( echo " $COMP_LINE " | \
2005-07-19 04:32:31 +00:00
sed -e 's/^.* \([^ ]*' $regex '\) .*$/\1/' )
2002-06-02 20:19:38 +00:00
# devise how to untar and list it
2002-06-04 03:27:03 +00:00
untar = t${ COMP_WORDS [1]//[^Izjyf]/ }
2002-06-02 20:19:38 +00:00
2002-06-10 13:36:50 +00:00
COMPREPLY = ( $( compgen -W " $( echo $( tar $untar $tar \
2>/dev/null ) ) " -- " $cur " ) )
2002-10-14 16:56:46 +00:00
return 0
2002-06-02 20:19:38 +00:00
fi
# file completion on relevant files
2008-06-21 22:19:37 +02:00
_filedir " $ext "
2002-06-02 20:19:38 +00:00
2001-07-08 23:14:13 +00:00
return 0
}
2002-12-18 18:15:46 +00:00
[ -n " ${ COMP_TAR_INTERNAL_PATHS :- } " ] && complete -F _tar $dirnames tar ||
2002-06-25 13:48:33 +00:00
complete -F _tar $filenames tar
2001-07-08 23:14:13 +00:00
2002-03-07 17:35:32 +00:00
# jar(1) completion
#
have jar &&
_jar( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-03-07 17:35:32 +00:00
if [ $COMP_CWORD = 1 ] ; then
COMPREPLY = ( $( compgen -W 'c t x u' -- $cur ) )
return 0
fi
case " ${ COMP_WORDS [1] } " in
2002-10-05 07:34:57 +00:00
*c*f)
2002-03-07 17:35:32 +00:00
_filedir
; ;
*f)
2003-02-06 18:08:16 +00:00
_filedir '?(e|j|w)ar'
2002-03-07 17:35:32 +00:00
; ;
*)
_filedir
; ;
esac
2005-07-07 23:36:51 +00:00
} &&
complete -F _jar $filenames jar
2002-03-07 17:35:32 +00:00
2001-07-08 23:14:13 +00:00
# Linux iptables(8) completion
#
have iptables &&
_iptables( )
{
2002-01-08 00:26:49 +00:00
local cur prev table chain
2001-07-08 23:14:13 +00:00
COMPREPLY = ( )
2008-05-06 20:20:14 +01:00
cur = ` _get_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
2003-10-07 04:47:55 +00:00
-*[ AIDRPFXLZ] )
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
; ;
*)
2003-10-07 04:47:55 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -i -o -s -d -p -f -m --append \
--delete --insert --replace --list --flush --zero --new \
--delete-chain --policy --rename-chain --proto --source \
--destination --in-interface --jump --match --numeric \
--out-interface --table --verbose --line-numbers --exact \
--fragment --modprobe= --set-counters --version' -- " $cur " ) )
fi
2002-01-08 00:26:49 +00:00
; ;
esac
2005-07-07 23:36:51 +00:00
} &&
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 = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-08-03 00:57:49 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( r| w| F) )
_filedir
return 0
; ;
-i)
2005-07-20 22:54:36 +00:00
_available_interfaces -a
2003-08-03 00:57:49 +00:00
return 0
; ;
esac
2001-07-08 23:14:13 +00:00
2003-08-03 00:57:49 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -a -d -e -f -l -n -N -O -p \
-q -R -S -t -u -v -x -C -F -i -m -r -s -T -w \
-E' -- $cur ) )
fi
2001-07-08 23:14:13 +00:00
2005-07-07 23:36:51 +00:00
} &&
complete -F _tcpdump tcpdump
2001-03-05 19:12:48 +00:00
2002-04-03 19:10:49 +00:00
# autorpm(8) completion
#
have autorpm &&
_autorpm( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-04-03 19:10:49 +00:00
COMPREPLY = ( $( compgen -W ' --notty --debug --help --version \
auto add fullinfo info help install list \
remove set' -- $cur ) )
2005-07-07 23:36:51 +00:00
} &&
complete -F _autorpm autorpm
2002-04-03 19:10:49 +00:00
2001-03-05 19:12:48 +00:00
# This meta-cd function observes the CDPATH variable, so that cd additionally
# completes on directories under those specified in CDPATH.
#
_cd( )
{
2008-05-01 22:22:11 +02:00
local IFS = $'\t\n' cur = ` _get_cword` i j k
2001-03-05 19:12:48 +00:00
2003-05-06 06:39:49 +00:00
# try to allow variable completion
if [ [ " $cur " = = ?( \\ ) \$ * ] ] ; then
COMPREPLY = ( $( compgen -v -P '$' -- " ${ cur #?( \\ ) $} " ) )
return 0
fi
2009-01-09 12:19:15 +01:00
# Enable -o filenames option, see Debian bug #272660
compgen -f /non-existing-dir/ >/dev/null
2002-03-29 02:43:09 +00:00
# Use standard dir completion if no CDPATH or parameter starts with /,
# ./ or ../
2002-12-18 18:15:46 +00:00
if [ -z " ${ CDPATH :- } " ] || [ [ " $cur " = = ?( .) ?( .) /* ] ] ; then
2002-02-27 15:48:20 +00:00
_filedir -d
2002-01-05 19:48:59 +00:00
return 0
fi
2002-05-13 21:40:40 +00:00
2004-07-03 23:15:29 +00:00
local -r mark_dirs = $( _rl_enabled mark-directories && echo y)
local -r mark_symdirs = $( _rl_enabled mark-symlinked-directories && echo y)
2002-03-29 02:43:09 +00:00
# we have a CDPATH, so loop on its contents
for i in ${ CDPATH // : / $'\t' } ; do
# create an array of matched subdirs
2008-06-21 22:19:37 +02:00
k = " ${# COMPREPLY [@] } "
2002-06-24 14:34:50 +00:00
for j in $( compgen -d $i /$cur ) ; do
2004-07-03 23:15:29 +00:00
if [ [ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${ j # $i / } ] ] ; then
j = " ${ j } / "
fi
COMPREPLY[ k++] = ${ j # $i / }
2002-05-16 07:05:04 +00:00
done
2002-03-29 02:43:09 +00:00
done
2002-05-13 21:40:40 +00:00
2002-02-27 15:48:20 +00:00
_filedir -d
2001-03-05 19:12:48 +00:00
2004-07-03 23:15:29 +00:00
if [ [ ${# COMPREPLY [@] } -eq 1 ] ] ; then
i = ${ COMPREPLY [0] }
if [ " $i " = = " $cur " ] && [ [ $i != "*/" ] ] ; then
COMPREPLY[ 0] = " ${ i } / "
fi
fi
2008-05-06 20:20:14 +01:00
2001-03-05 19:12:48 +00:00
return 0
}
2003-01-13 02:30:37 +00:00
if shopt -q cdable_vars; then
2009-01-09 12:19:15 +01:00
complete -v -F _cd $nospace cd
2003-01-13 02:30:37 +00:00
else
2009-01-09 12:19:15 +01:00
complete -F _cd $nospace cd
2003-01-13 02:30:37 +00:00
fi
2001-07-09 00:55:01 +00:00
2009-02-12 22:12:20 +01:00
# a wrapper method for the next one, when the offset is unknown
_command( )
{
local offset i
# find actual offset, as position of the first non-option
offset = 1
for ( ( i = 1; i <= COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " != -* ] ] ; then
offset = $i
break
fi
done
_command_offset $offset
2008-06-23 11:33:52 +02: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
2005-01-19 03:19:45 +00:00
# don't work properly), but still quite useful.
2002-01-18 15:54:22 +00:00
#
2009-02-12 22:12:20 +01:00
_command_offset( )
2002-01-18 15:54:22 +00:00
{
2009-02-12 22:12:20 +01:00
local cur func cline cspec noglob cmd i char_offset word_offset \
2003-06-07 21:23:49 +00:00
_COMMAND_FUNC _COMMAND_FUNC_ARGS
2002-01-18 15:54:22 +00:00
2009-02-12 22:12:20 +01:00
word_offset = $1
# rewrite current completion context before invoking
# actual command completion
# find new first word position, then
# rewrite COMP_LINE and adjust COMP_POINT
local first_word = ${ COMP_WORDS [ $word_offset ] }
for ( ( i = 0; i <= ${# COMP_LINE } ; i++ ) ) ; do
if [ [ " ${ COMP_LINE : $i : ${# first_word } } " = = " $first_word " ] ] ; then
char_offset = $i
break
fi
done
COMP_LINE = ${ COMP_LINE : $char_offset }
COMP_POINT = $(( COMP_POINT - $char_offset ))
# shift COMP_WORDS elements and adjust COMP_CWORD
for ( ( i = 0; i <= COMP_CWORD - $word_offset ; i++ ) ) ; do
COMP_WORDS[ i] = ${ COMP_WORDS [i+ $word_offset ] }
done
for ( ( i; i <= COMP_CWORD; i++ ) ) ; do
unset COMP_WORDS[ i] ;
done
COMP_CWORD = $(( $COMP_CWORD - $word_offset ))
2002-01-18 15:54:22 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-01-18 15:54:22 +00:00
2008-06-23 15:05:28 +02:00
if [ [ $COMP_CWORD -eq 0 ] ] ; then
2002-02-27 01:02:43 +00:00
COMPREPLY = ( $( compgen -c -- $cur ) )
2009-02-12 22:12:20 +01:00
else
cmd = ${ COMP_WORDS [0] }
if complete -p $cmd & >/dev/null; then
2003-06-07 21:09:34 +00:00
cspec = $( complete -p $cmd )
if [ " ${ cspec #* -F } " != " $cspec " ] ; then
2002-01-18 15:54:22 +00:00
# complete -F <function>
# get function name
func = ${ cspec #*-F }
func = ${ func %% * }
2008-06-23 11:44:42 +02:00
if [ [ ${# COMP_WORDS [@] } -ge 2 ] ] ; then
2008-06-23 15:05:28 +02:00
$func $cmd " ${ COMP_WORDS [ ${# COMP_WORDS [@] } -1] } " " ${ COMP_WORDS [ ${# COMP_WORDS [@] } -2] } "
2008-06-23 11:44:42 +02:00
else
2008-06-23 13:34:05 +02:00
$func $cmd " ${ COMP_WORDS [ ${# COMP_WORDS [@] } -1] } "
2008-06-23 11:44:42 +02:00
fi
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)
2008-06-23 11:44:42 +02:00
# FIXME: I'm pretty sure this does not work!
2002-03-30 18:20:51 +00:00
if [ " ${ cspec #*-o } " != " $cspec " ] ; then
cspec = ${ cspec #*-o }
cspec = ${ cspec %% * }
if [ [ " $cspec " != @( dir| file) names ] ] ; then
2004-02-09 20:40:41 +00:00
COMPREPLY = ( " ${ COMPREPLY [@]// \\ \\ : / : } " )
2002-03-30 18:20:51 +00:00
fi
fi
2003-06-07 21:09:34 +00:00
elif [ -n " $cspec " ] ; then
cspec = ${ cspec #complete } ;
cspec = ${ cspec %% $cmd } ;
COMPREPLY = ( $( eval compgen " $cspec " -- " $cur " ) ) ;
2002-01-18 15:54:22 +00:00
fi
2009-02-12 22:12:20 +01:00
fi
2002-01-18 15:54:22 +00:00
fi
2002-02-27 15:28:26 +00:00
[ ${# COMPREPLY [@] } -eq 0 ] && _filedir
2002-01-18 15:54:22 +00:00
}
2009-02-12 22:12:20 +01:00
complete -F _command $filenames nohup exec nice eval time ltrace then \
2008-05-06 20:34:22 +01:00
else do vsound command xargs tsocks
2002-01-18 15:54:22 +00:00
2002-02-26 22:21:39 +00:00
_root_command( )
{
2003-06-07 21:09:34 +00:00
PATH = $PATH :/sbin:/usr/sbin:/usr/local/sbin _command $1 $2 $3
2002-02-26 22:21:39 +00:00
}
2008-09-07 16:27:02 +02:00
complete -F _root_command $filenames sudo fakeroot really gksudo gksu kdesudo
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
#
2006-02-25 12:36:12 +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 = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-03-07 17:32:03 +00:00
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
2003-08-22 05:12:51 +00:00
-buildfile| -f)
2002-05-18 21:00:14 +00:00
_filedir 'xml'
2002-03-07 17:32:03 +00:00
return 0
; ;
-logfile)
_filedir
return 0
; ;
esac
2001-12-11 20:25:53 +00:00
2002-03-07 17:32:03 +00:00
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
2002-03-29 15:33:08 +00:00
COMPREPLY = ( $( compgen -W ' -help -projecthelp -version -quiet \
-verbose -debug -emacs -logfile -logger \
2003-08-22 05:12:51 +00:00
-listener -buildfile -f -D -find' -- $cur ) )
2002-03-07 17:32:03 +00:00
else
# available targets completion
2002-06-19 06:18:28 +00:00
# find which buildfile to use
2002-03-07 17:32:03 +00:00
buildfile = build.xml
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = -buildfile ] ] ; then
buildfile = ${ COMP_WORDS [i+1] }
break
fi
done
[ ! -f $buildfile ] && return 0
2001-12-11 20:25:53 +00:00
2002-03-07 17:32:03 +00:00
# parse buildfile for targets
2002-03-29 15:33:08 +00:00
COMPREPLY = ( $( awk -F'"' '/<target name="/ {print $2}' \
2003-01-25 21:11:18 +00:00
$buildfile | grep " ^ $cur " )
$( awk -F"'" "/<target name='/ " '{print $2}' \
2004-02-13 07:27:24 +00:00
$buildfile | grep " ^ $cur " )
$( awk -F'"' '/<target [^n]/ {if ($1 ~ /name=/) { print $2 } else if ($3 ~ /name=/) {print $4} else if ($5 ~ /name=/) {print $6}}' \
2002-04-03 21:17:10 +00:00
$buildfile | grep " ^ $cur " ) )
2002-03-07 17:32:03 +00:00
fi
2006-02-25 12:36:12 +00:00
}
have complete-ant-cmd.pl && \
complete -C complete-ant-cmd.pl -F _ant $filenames ant || \
complete -F _ant $filenames ant
}
2001-12-11 20:25:53 +00:00
2001-12-18 03:25:04 +00:00
have nslookup &&
_nslookup( )
{
local cur
COMPREPLY = ( )
cur = ${ COMP_WORDS [COMP_CWORD]#- }
COMPREPLY = ( $( compgen -P '-' -W ' all class = debug d2 domain = \
srchlist = defname search port = querytype = \
type = recurse retry root timeout vc \
2002-02-27 01:02:43 +00:00
ignoretc' -- $cur ) )
2005-07-07 23:36:51 +00:00
} &&
complete -F _nslookup nslookup
2001-12-18 03:25:04 +00:00
2002-01-14 20:38:22 +00:00
# mysqladmin(1) completion
#
have mysqladmin &&
_mysqladmin( )
{
local cur prev
COMPREPLY = ( )
2008-05-06 20:20:14 +01:00
cur = ` _get_cword`
2002-01-14 20:38:22 +00:00
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
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " \
2002-01-14 20:38:22 +00:00
$( 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 ) )
2005-07-07 23:36:51 +00:00
} &&
complete -F _mysqladmin mysqladmin
2002-01-14 20:38:22 +00:00
2003-09-11 21:13:40 +00:00
# gzip(1) completion
2002-01-23 23:13:21 +00:00
#
have gzip &&
2003-09-11 21:13:40 +00:00
_gzip( )
2002-01-23 23:13:21 +00:00
{
2009-01-17 00:31:39 +01:00
local cur prev xspec helpopts
2002-01-23 23:13:21 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-01-23 23:13:21 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2009-01-17 00:31:39 +01:00
helpopts = ` _parse_help gzip`
2002-01-23 23:13:21 +00:00
2003-09-11 21:13:40 +00:00
if [ [ " $cur " = = -* ] ] ; then
2009-01-17 00:31:39 +01:00
COMPREPLY = ( $( compgen -W " $helpopts -2 -3 -4 -5 -6 -7 -8 " \
-- " $cur " ) )
2003-09-11 21:13:40 +00:00
return 0
fi
2009-01-12 21:16:51 +02:00
local IFS = $'\t\n'
2003-09-11 21:13:40 +00:00
xspec = "*.?(t)gz"
if [ [ " $prev " = = --* ] ] ; then
[ [ " $prev " = = --decompress || \
" $prev " = = --list || \
" $prev " = = --test ] ] && xspec = "!" $xspec
[ [ " $prev " = = --force ] ] && xspec =
elif [ [ " $prev " = = -* ] ] ; then
[ [ " $prev " = = -*[ dlt] * ] ] && xspec = "!" $xspec
[ [ " $prev " = = -*f* ] ] && xspec =
2003-11-02 20:19:46 +00:00
elif [ " $prev " = '>' ] ; then
xspec =
2008-05-01 22:59:32 +02:00
elif [ " $prev " = '<' ] ; then
xspec =
2003-09-11 21:13:40 +00:00
fi
_expand || return 0
COMPREPLY = ( $( compgen -f -X " $xspec " -- $cur ) \
$( compgen -d -- $cur ) )
2005-07-07 23:36:51 +00:00
} &&
complete -F _gzip $filenames gzip
2003-09-11 21:13:40 +00:00
# bzip2(1) completion
#
have bzip2 &&
_bzip2( )
{
2009-01-12 21:16:51 +02:00
local cur prev xspec
2003-09-11 21:13:40 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-09-11 21:13:40 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -c -d -f -h -k -L -q -s \
-t -v -V -z -1 -2 -3 -4 -5 -6 -7 -8 -9 \
--help --decompress --compress --keep --force \
--test --stdout --quiet --verbose --license \
--version --small --fast --best' -- $cur ) )
return 0
fi
2009-01-12 21:16:51 +02:00
local IFS = $'\t\n'
2003-09-11 21:13:40 +00:00
xspec = "*.bz2"
if [ [ " $prev " = = --* ] ] ; then
[ [ " $prev " = = --decompress || \
" $prev " = = --list || \
" $prev " = = --test ] ] && xspec = "!" $xspec
[ [ " $prev " = = --compress ] ] && xspec =
elif [ [ " $prev " = = -* ] ] ; then
[ [ " $prev " = = -*[ dt] * ] ] && xspec = "!" $xspec
[ [ " $prev " = = -*z* ] ] && xspec =
fi
2002-01-23 23:13:21 +00:00
_expand || return 0
2002-02-27 01:02:43 +00:00
COMPREPLY = ( $( compgen -f -X " $xspec " -- $cur ) \
$( compgen -d -- $cur ) )
2005-07-07 23:36:51 +00:00
} &&
complete -F _bzip2 $filenames bzip2
2002-01-23 23:13:21 +00:00
2002-02-04 02:12:10 +00:00
# openssl(1) completion
#
2005-01-03 04:38:41 +00:00
have openssl && {
_openssl_sections( )
{
local config
config = /etc/ssl/openssl.cnf
2005-01-04 22:35:41 +00:00
[ ! -f $config ] && config = /usr/share/ssl/openssl.cnf
2005-01-03 04:38:41 +00:00
for ( ( i = 2; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = -config ] ] ; then
config = ${ COMP_WORDS [i+1] }
break
fi
done
[ ! -f $config ] && return 0
COMPREPLY = ( $( awk '/\[.*\]/ {print $2} ' $config | grep " ^ $cur " ) )
}
2002-02-04 02:12:10 +00:00
_openssl( )
{
2005-01-03 04:38:41 +00:00
local cur prev
2002-02-04 02:12:10 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-02-04 02:12:10 +00:00
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 ) )
2005-01-03 04:38:41 +00:00
else
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case ${ COMP_WORDS [1] } in
asn1parse)
case $prev in
-inform)
COMPREPLY = ( $( compgen -W 'DER PEM' -- $cur ) )
return 0
; ;
-@( in| out| oid) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -inform -in -out -noout -offset \
-length -i -oid -strparse' -- $cur ) )
fi
; ;
ca)
case $prev in
-@( config| revoke| cert| in| out| spkac| ss_cert) )
_filedir
return 0
; ;
-outdir)
_filedir -d
return 0
; ;
-@( name| crlexts| extensions) )
_openssl_sections
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -verbose -config -name \
-gencrl -revoke -crldays -crlhours -crlexts \
-startdate -enddate -days -md -policy -keyfile \
-key -passin -cert -in -out -notext -outdir \
-infiles -spkac -ss_cert -preserveDN -batch \
-msie_hack -extensions' -- $cur ) )
fi
; ;
ciphers)
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '-v -ssl2 -ssl3 -tls1' -- $cur ) )
fi
; ;
crl)
case $prev in
-@( in| out) form)
COMPREPLY = ( $( compgen -W 'DER PEM' -- $cur ) )
return 0
; ;
-@( in| out| CAfile) )
_filedir
return 0
; ;
-CAPath)
_filedir -d
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -inform -outform -text -in -out -noout \
-hash -issuer -lastupdate -nextupdate -CAfile -CApath' -- $cur ) )
fi
; ;
crl2pkcs7)
case $prev in
-@( in| out) form)
COMPREPLY = ( $( compgen -W 'DER PEM' -- $cur ) )
return 0
; ;
-@( in| out) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '-inform -outform -in -out -print_certs' -- $cur ) )
fi
; ;
dgst)
case $prev in
-@( out| sign| verify| prvrify| signature) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -md5 -md4 -md2 -sha1 -sha -mdc2 -ripemd160 -dss1 \
-c -d -hex -binary -out -sign -verify -prverify -signature' -- $cur ) )
else
_filedir
fi
; ;
dsa)
case $prev in
-@( in| out) form)
COMPREPLY = ( $( compgen -W 'DER PEM' -- $cur ) )
return 0
; ;
-@( in| out) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -inform -outform -in -passin -out -passout -des -des3 -idea -text -noout \
-modulus -pubin -pubout' -- $cur ) )
fi
; ;
dsaparam)
case $prev in
-@( in| out) form)
COMPREPLY = ( $( compgen -W 'DER PEM' -- $cur ) )
return 0
; ;
-@( in| out| rand) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -inform -outform -in -out -noout \
-text -C -rand -genkey' -- $cur ) )
fi
; ;
enc)
case $prev in
-@( in| out| kfile) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -ciphername -in -out -pass \
-e -d -a -A -k -kfile -S -K -iv -p -P -bufsize -debug' -- $cur ) )
fi
; ;
dhparam)
case $prev in
-@( in| out) form)
COMPREPLY = ( $( compgen -W 'DER PEM' -- $cur ) )
return 0
; ;
-@( in| out| rand) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -inform -outform -in -out -dsaparam -noout \
-text -C -2 -5 -rand' -- $cur ) )
fi
; ;
gendsa)
case $prev in
-@( out| rand) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '-out -des -des3 -idea -rand' -- $cur ) )
else
_filedir
fi
; ;
genrsa)
case $prev in
-@( out| rand) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '-out -passout -des -des3 -idea -f4 -3 -rand' -- $cur ) )
fi
; ;
pkcs7)
case $prev in
-@( in| out) form)
COMPREPLY = ( $( compgen -W 'DER PEM' -- $cur ) )
return 0
; ;
-@( in| out) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '-inform -outform -in -out -print_certs -text -noout' -- $cur ) )
fi
; ;
rand)
case $prev in
-@( out| rand) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '-out -rand -base64' -- $cur ) )
fi
; ;
req)
case " $prev " in
-@( in| out| key) form)
COMPREPLY = ( $( compgen -W 'DER PEM' -- $cur ) )
return 0
; ;
-@( in| out| rand| key| keyout| config) )
_filedir
return 0
; ;
-extensions)
_openssl_sections
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -inform -outform -in \
-passin -out -passout -text -noout -verify \
-modulus -new -rand -newkey -newkey -nodes \
-key -keyform -keyout -md5 -sha1 -md2 -mdc2 \
-config -x509 -days -asn1-kludge -newhdr \
-extensions -reqexts section' -- $cur ) )
fi
; ;
rsa)
case $prev in
-@( in| out) form)
COMPREPLY = ( $( compgen -W 'DER NET PEM' -- $cur ) )
return 0
; ;
-@( in| out) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -inform -outform -in -passin -out -passout \
-sgckey -des -des3 -idea -text -noout -modulus -check -pubin \
-pubout -engine' -- $cur ) )
fi
; ;
rsautl)
case $prev in
-@( in| out| inkey) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -in -out -inkey -pubin -certin -sign -verify \
-encrypt -decrypt -pkcs -ssl -raw -hexdump -asn1parse' -- $cur ) )
fi
; ;
s_client)
case $prev in
-connect)
_known_hosts
return 0
; ;
-@( cert| key| CAfile| rand) )
_filedir
return 0
; ;
-CApath)
_filedir -d
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -connect -verify -cert -key -CApath -CAfile \
-reconnect -pause -showcerts -debug -msg -nbio_test -state -nbio \
-crlf -ign_eof -quiet -ssl2 -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 \
-bugs -cipher -starttls -engine -rand' -- $cur ) )
fi
; ;
s_server)
case $prev in
-@( cert| key| dcert| dkey| dhparam| CAfile| rand) )
_filedir
return 0
; ;
-CApath)
_filedir -d
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -accept -context -verify -Verify -cert -key \
-dcert -dkey -dhparam -nbio -nbio_test -crlf -debug -msg -state -CApath \
-CAfile -nocert -cipher -quiet -no_tmp_rsa -ssl2 -ssl3 -tls1 -no_ssl2 \
-no_ssl3 -no_tls1 -no_dhe -bugs -hack -www -WWW -HTTP -engine -id_prefix \
-rand' -- $cur ) )
fi
; ;
s_time)
case $prev in
-connect)
_known_hosts
return 0
; ;
-@( cert| key| CAfile) )
_filedir
return 0
; ;
-CApath)
_filedir -d
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -connect -www -cert -key -CApath -CAfile -reuse \
-new -verify -nbio -time -ssl2 -ssl3 -bugs -cipher' -- $cur ) )
fi
; ;
2008-05-06 20:20:14 +01:00
sess_id)
2005-01-03 04:38:41 +00:00
case $prev in
-@( in| out) form)
COMPREPLY = ( $( compgen -W 'DER PEM' -- $cur ) )
return 0
; ;
-@( in| out) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -inform -outform -in -out -text -noout \
-context ID' -- $cur ) )
fi
; ;
smime)
case $prev in
-@( in| out) form)
COMPREPLY = ( $( compgen -W 'SMIME DER PEM' -- $cur ) )
return 0
; ;
-@( in| out| certfile| signer| recip| inkey| content| rand) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -encrypt -decrypt -sign -verify -pk7out -des -des3 \
-rc2-40 -rc2-64 -rc2-128 -aes128 -aes192 -aes256 -in -certfile -signer \
-recip -inform -passin -inkey -out -outform -content -to -from -subject \
-text -rand' -- $cur ) )
else
_filedir
fi
; ;
speed)
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '-engine' -- $cur ) )
else
COMPREPLY = ( $( compgen -W ' md2 mdc2 md5 hmac sha1 rmd160 idea-cbc \
rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4 rsa512 rsa1024 rsa2048 \
rsa4096 dsa512 dsa1024 dsa2048 idea rc2 des rsa blowfish' -- $cur ) )
fi
; ;
verify)
case $prev in
-@( CAfile| untrusted) )
_filedir
return 0
; ;
-CApath)
_filedir -d
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -CApath -CAfile -purpose -untrusted -help -issuer_checks \
-verbose -certificates' -- $cur ) )
else
_filedir
fi
; ;
x509)
case " $prev " in
-@( in| out| CA| CAkey| CAserial| extfile) )
_filedir
return 0
; ;
-@( in| out) form)
COMPREPLY = ( $( compgen -W 'DER PEM NET' -- $cur ) )
return 0
; ;
-@( key| CA| CAkey) form)
COMPREPLY = ( $( compgen -W 'DER PEM' -- $cur ) )
return 0
; ;
-extensions)
_openssl_sections
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -inform -outform \
-keyform -CAform -CAkeyform -in -out \
-serial -hash -subject -issuer -nameopt \
-email -startdate -enddate -purpose \
-dates -modulus -fingerprint -alias \
-noout -trustout -clrtrust -clrreject \
-addtrust -addreject -setalias -days \
-set_serial -signkey -x509toreq -req \
-CA -CAkey -CAcreateserial -CAserial \
-text -C -md2 -md5 -sha1 -mdc2 -clrext \
-extfile -extensions -engine' -- $cur ) )
fi
; ;
@( md5| md4| md2| sha1| sha| mdc2| ripemd160) )
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W '-c -d' -- $cur ) )
else
_filedir
fi
; ;
esac
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
}
2005-01-03 04:38:41 +00:00
complete -F _openssl $default openssl
}
2002-02-04 02:12:10 +00:00
# screen(1) completion
#
have screen &&
_screen( )
{
2004-10-14 07:08:33 +00:00
local cur prev preprev
2002-02-04 02:12:10 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-02-04 02:12:10 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2004-10-14 07:08:33 +00:00
[ " $COMP_CWORD " -ge 2 ] && preprev = ${ COMP_WORDS [COMP_CWORD-2] }
if [ " $preprev " = "-d" -o " $preprev " = "-D" -a " $prev " = "-r" -o \
" $prev " = "-R" ] ; then
2002-12-05 01:56:19 +00:00
# list all
2002-06-04 03:45:09 +00:00
COMPREPLY = ( $( command screen -ls | \
2004-10-19 03:51:04 +00:00
sed -ne 's|^[' $'\t' ']\+\(' $cur '[0-9]\+\.[^' $'\t' ']\+\).*$|\1|p' ) )
2002-12-05 01:56:19 +00:00
else
case " $prev " in
-[ rR] )
# list detached
COMPREPLY = ( $( command screen -ls | \
2004-10-19 03:51:04 +00:00
sed -ne 's|^[' $'\t' ']\+\(' $cur '[0-9]\+\.[^' $'\t' ']\+\).*Detached.*$|\1|p' ) )
2002-12-05 01:56:19 +00:00
; ;
-[ dDx] )
# list attached
COMPREPLY = ( $( command screen -ls | \
2004-10-19 03:51:04 +00:00
sed -ne 's|^[' $'\t' ']\+\(' $cur '[0-9]\+\.[^' $'\t' ']\+\).*Attached.*$|\1|p' ) )
2002-12-05 01:56:19 +00:00
; ;
-s)
# shells
COMPREPLY = ( $( grep ^${ cur :- [^#] } /etc/shells ) )
; ;
*)
; ;
esac
fi
2002-02-04 02:12:10 +00:00
2002-03-07 18:04:05 +00:00
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _screen $default screen
2002-02-04 02:12:10 +00:00
2002-04-03 19:10:49 +00:00
# lftp(1) bookmark completion
#
have lftp &&
_lftp( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-04-03 19:10:49 +00:00
if [ $COMP_CWORD -eq 1 ] && [ -f ~/.lftp/bookmarks ] ; then
COMPREPLY = ( $( compgen -W '$( sed -ne "s/^\(.*\)' $'\t' ' .*$/\1 /p" \
~/.lftp/bookmarks ) ' -- $cur ) )
fi
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _lftp $default lftp
2002-04-03 19:10:49 +00:00
2002-02-10 20:45:46 +00:00
# ncftp(1) bookmark completion
#
have ncftp &&
_ncftp( )
{
local cur
2002-02-11 22:28:47 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-02-10 20:45:46 +00:00
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
2005-07-07 23:36:51 +00:00
} &&
complete -F _ncftp $default ncftp
2002-02-10 20:45:46 +00:00
2002-02-11 22:28:47 +00:00
# gdb(1) completion
#
have gdb &&
_gdb( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-02-11 22:28:47 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
if [ $COMP_CWORD -eq 1 ] ; then
2008-06-25 21:18:12 +02:00
local IFS
if [ [ " $cur " = = */* ] ] ; then
# compgen -c works as expected if $cur contains any slashes.
IFS = $'\n'
COMPREPLY = ( $( PATH = " $PATH :. " compgen -d -c -- " $cur " ) )
else
# otherwise compgen -c contains Bash's built-in commands,
# functions and aliases. Thus we need to retrieve the program
# names manually.
IFS = ":"
2008-09-07 10:35:59 +02:00
local path_array = ( $( echo " $PATH " | sed 's/::\+/:/g;s/^:\|:$//g' ) )
2008-06-25 21:18:12 +02:00
IFS = $'\n'
COMPREPLY = ( $( compgen -d -W ' $( find " ${ path_array [@] } " . \
2008-09-26 21:39:30 +02:00
-mindepth 1 -maxdepth 1 -not -type d -executable -printf "%f\\n" 2>/dev/null) ' \
2008-06-25 21:18:12 +02:00
-- " $cur " ) )
fi
2002-02-11 22:28:47 +00:00
elif [ $COMP_CWORD -eq 2 ] ; then
2002-06-24 06:22:11 +00:00
prev = ${ prev ##*/ }
2006-02-23 23:57:25 +00:00
COMPREPLY = ( $( compgen -fW " $( command ps axo comm,pid | \
2006-02-24 10:37:04 +00:00
awk '{if ($1 ~ /^' " $prev " '/) print $2}' ) ) " \
2002-06-24 06:22:11 +00:00
-- " $cur " ) )
2002-02-11 22:28:47 +00:00
fi
2005-07-07 23:36:51 +00:00
} &&
2008-06-25 17:58:54 +02:00
complete -F _gdb $default gdb
2002-02-11 22:28:47 +00:00
2002-04-29 18:36:04 +00:00
# Postgresql completion
#
have psql && {
2008-05-06 20:20:14 +01:00
_pg_databases( )
2002-04-29 18:36:04 +00:00
{
2008-06-23 11:46:30 +02:00
return
2002-04-29 18:36:04 +00:00
COMPREPLY = ( $( psql -l 2>/dev/null | \
2003-06-23 13:54:01 +00:00
sed -e '1,/^-/d' -e '/^(/,$d' | \
awk '{print $1}' | grep " ^ $cur " ) )
2002-04-29 18:36:04 +00:00
}
_pg_users( )
{
2008-06-23 11:46:30 +02:00
#COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
# grep "^ $cur" ) )
#[ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- $cur ) )
COMPREPLY = ( $( compgen -u -- $cur ) )
2002-04-29 18:36:04 +00:00
}
2005-07-07 23:36:51 +00:00
# createdb(1) completion
2002-02-13 18:20:59 +00:00
#
2008-05-06 20:20:14 +01:00
_createdb( )
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 = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-02-13 18:20:59 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
2008-05-06 20:20:14 +01:00
-@( h| -host= ) )
2002-02-13 18:20:59 +00:00
_known_hosts
return 0
; ;
2005-07-07 23:36:51 +00:00
-@( U| -username= ) )
2002-04-29 18:36:04 +00:00
_pg_users
2002-02-13 18:20:59 +00:00
return 0
; ;
2002-04-29 18:36:04 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
2005-07-07 23:36:51 +00:00
COMPREPLY = ( $( compgen -W ' -D -T -E -h -p -U -W -e -q \
--location= --template= --encoding= --host= --port= \
--username= --password --echo --quiet --help' -- $cur ) )
2002-04-29 18:36:04 +00:00
else
_pg_databases
fi
}
2005-07-07 23:36:51 +00:00
complete -F _createdb $default createdb
2002-04-29 18:36:04 +00:00
2005-07-07 23:36:51 +00:00
# dropdb(1) completion
2002-04-29 18:36:04 +00:00
#
2008-05-06 20:20:14 +01:00
_dropdb( )
2002-04-29 18:36:04 +00:00
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-04-29 18:36:04 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
2008-05-06 20:20:14 +01:00
-@( h| -host= ) )
2002-04-29 18:36:04 +00:00
_known_hosts
return 0
; ;
-@( U| -username= ) )
_pg_users
2002-02-13 18:20:59 +00:00
return 0
; ;
esac
2002-04-29 18:36:04 +00:00
if [ [ " $cur " = = -* ] ] ; then
2005-07-07 23:36:51 +00:00
COMPREPLY = ( $( compgen -W ' -h -p -U -W -e -q \
--host= --port= --username= --password \
--interactive --echo --quiet --help' -- $cur ) )
2002-04-29 18:36:04 +00:00
else
_pg_databases
fi
}
2005-07-07 23:36:51 +00:00
complete -F _dropdb $default dropdb
2002-04-29 18:36:04 +00:00
2005-07-07 23:36:51 +00:00
# psql(1) completion
2002-04-29 18:36:04 +00:00
#
2008-05-06 20:20:14 +01:00
_psql( )
2002-04-29 18:36:04 +00:00
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-04-29 18:36:04 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
2008-05-06 20:20:14 +01:00
-h| --host)
2002-04-29 18:36:04 +00:00
_known_hosts
return 0
; ;
2005-07-07 23:36:51 +00:00
-U| --username)
2002-04-29 18:36:04 +00:00
_pg_users
return 0
; ;
2005-07-07 23:36:51 +00:00
-d| --dbname)
_pg_databases
return 0
; ;
-@( o| f) | --output| --file)
_filedir
return 0
; ;
2002-04-29 18:36:04 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
2005-07-07 23:36:51 +00:00
# return list of available options
COMPREPLY = ( $( compgen -W ' -a --echo-all -A --no-align \
-c --command -d --dbname -e --echo-queries \
-E --echo-hidden -f --file -F --filed-separator \
-h --host -H --html -l --list -n -o --output \
-p --port -P --pset -q -R --record-separator \
-s --single-step -S --single-line -t --tuples-only \
-T --table-attr -U --username -v --variable \
-V --version -W --password -x --expanded -X --nopsqlrc \
-? --help ' -- $cur ) )
2002-04-29 18:36:04 +00:00
else
2005-07-07 23:36:51 +00:00
# return list of available databases
2002-04-29 18:36:04 +00:00
_pg_databases
fi
}
2005-07-07 23:36:51 +00:00
complete -F _psql $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
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-02-18 08:32:56 +00:00
2002-03-01 22:41:42 +00:00
if [ [ " $cur " = = --*= * ] ] ; then
opt = ${ cur %%=* }
2003-07-29 02:19:03 +00:00
# cut backslash that gets inserted before '=' sign
2002-03-01 22:41:42 +00:00
opt = ${ opt % \\ * }
cur = ${ cur #*= }
_filedir
2008-09-06 19:38:47 +02:00
# FIXME: see #297065... adding "-o nospace" (or $nospace),
# should do the trick, but seems not working... ideas?
2002-03-01 22:41:42 +00:00
COMPREPLY = ( $( compgen -P " $opt = " -W '${COMPREPLY[@]}' -- $cur ) )
return 0
fi
2002-02-18 10:09:59 +00:00
if [ [ " $cur " = = -* ] ] ; then
2002-09-09 13:46:17 +00:00
COMPREPLY = ( $( $1 --help 2>& 1 | sed -e '/--/!d' \
2002-02-20 05:26:08 +00:00
-e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | \
2004-11-22 20:20:43 +00:00
command grep " ^ $cur " | sort -u ) )
2008-05-11 15:32:49 +02:00
elif [ [ " $1 " = = rmdir ] ] ; 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
}
2005-01-16 17:42:01 +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 \
2009-01-24 21:20:58 +02:00
bison diff patch enscript cp df dir du ln ls mkfifo mknod mv rm \
2005-01-19 03:22:03 +00:00
touch vdir awk gperf grep grub indent less m4 sed shar date \
2005-01-16 17:42:01 +00:00
tee who texindex cat csplit cut expand fmt fold head \
2002-02-18 17:26:54 +00:00
md5sum nl od paste pr ptx sha1sum sort split tac tail tr unexpand \
2005-01-16 17:42:01 +00:00
uniq wc ldd bash id irb mkdir rmdir; do
have $i && complete -F _longopt $filenames $i
done
# These commands use filenames, so '-o filenames' is not needed.
for i in env netstat seq uname units wget; do
have $i && complete -F _longopt $default $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 = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_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/' | \
2004-11-22 20:20:43 +00:00
command grep " ^ $cur " | sort -u ) )
2002-02-18 10:09:59 +00:00
else
_filedir
fi
2005-07-07 23:36:51 +00:00
} &&
complete $filenames -F _gcc gcc g++ c++ g77 gcj gpc
2004-03-30 19:02:46 +00:00
[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Cygwin ] && \
2005-07-07 23:36:51 +00:00
[ -n " ${ have :- } " ] && complete $filenames -F _gcc cc
2002-02-15 22:53:58 +00:00
2002-02-26 20:48:32 +00:00
# Linux cardctl(8) completion
#
have cardctl &&
2002-02-27 06:47:09 +00:00
_cardctl( )
2002-02-26 20:48:32 +00:00
{
local cur
2002-05-16 07:05:04 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-02-26 20:48:32 +00:00
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
2005-07-07 23:36:51 +00:00
} &&
complete -F _cardctl cardctl
2002-02-26 20:48:32 +00:00
2002-03-24 18:44:55 +00:00
# This function is required by _dpkg() and _dpkg-reconfigure()
2002-04-02 05:27:50 +00:00
#
2008-05-01 22:59:32 +02:00
# TODO: Ubuntu (and Debian) folks removed the "have grep-status" part. In my Debian I got it,
2008-05-01 22:22:11 +02:00
# and I believe it's ok if we leave it like it is now. Was that removed because
2008-05-01 22:59:32 +02:00
# of Ubuntu's (and Debian's? :() inner weirdness? :) -- David (hanska-guest)
2002-05-05 15:42:42 +00:00
have dpkg && {
2008-05-01 22:59:32 +02:00
#have grep-status && {
#_comp_dpkg_installed_packages()
#{
# grep-status -P -e "^$1" -a -FStatus 'install ok installed' -n -s Package
#}
#} || {
2004-10-15 04:47:39 +00:00
_comp_dpkg_installed_packages( )
2002-03-24 18:44:55 +00:00
{
2008-05-01 22:22:11 +02:00
grep -A 1 " Package: $1 " /var/lib/dpkg/status | \
2009-01-16 21:22:26 +01:00
grep -B 1 -Ee " ok installed|half-installed|unpacked| \
half-configured| config-files" \
-Ee "^Essential: yes" | \
2008-05-01 22:22:11 +02:00
grep " Package: $1 " | cut -d\ -f2
2002-03-24 18:44:55 +00:00
}
2008-06-21 23:55:32 +02:00
#}
2002-03-24 18:44:55 +00:00
2002-05-09 16:20:53 +00:00
# Debian dpkg(8) completion
2002-02-27 06:47:09 +00:00
#
_dpkg( )
{
2004-07-05 21:45:00 +00:00
local cur prev i
2002-02-27 06:47:09 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-02-27 06:47:09 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2004-07-05 21:45:00 +00:00
i = $COMP_CWORD
2002-02-27 06:47:09 +00:00
2002-05-11 07:28:58 +00:00
_expand || return 0
2002-03-27 18:33:34 +00:00
# find the last option flag
if [ [ $cur != -* ] ] ; then
2004-07-05 21:45:00 +00:00
while [ [ $prev != -* && $i != 1 ] ] ; do
i = $(( i-1))
prev = ${ COMP_WORDS [i-1] }
2002-03-27 18:33:34 +00:00
done
fi
2008-05-06 20:20:14 +01:00
case " $prev " in
2008-06-21 22:19:37 +02:00
-@( c| i| A| I| f| e| x| X| -@( install| unpack| record-avail| contents| info| fsys-tarfile| field| control| extract) ) )
2002-12-04 06:25:47 +00:00
_filedir '?(u)deb'
2002-02-27 06:47:09 +00:00
return 0
; ;
2002-10-02 01:32:40 +00:00
-@( b| -build) )
2002-05-18 21:00:14 +00:00
_filedir -d
2002-03-11 01:10:17 +00:00
return 0
; ;
2002-10-02 01:32:40 +00:00
-@( s| p| l| -@( status| print-avail| list) ) )
2002-10-05 06:08:53 +00:00
COMPREPLY = ( $( apt-cache pkgnames $cur 2>/dev/null ) )
2002-03-16 19:49:44 +00:00
return 0
; ;
2002-10-02 01:32:40 +00:00
-@( S| -search) )
2002-03-16 19:49:44 +00:00
_filedir
2002-02-27 06:47:09 +00:00
return 0
; ;
2004-05-20 04:40:59 +00:00
-@( r| L| P| -@( remove| purge| listfiles) ) )
2004-10-15 04:47:39 +00:00
COMPREPLY = ( $( _comp_dpkg_installed_packages $cur ) )
2002-03-24 18:44:55 +00:00
return 0
; ;
2002-02-27 06:47:09 +00:00
*)
COMPREPLY = ( $( compgen -W ' -i --install --unpack -A --record-avail \
2004-05-20 04:40:59 +00:00
--configure -r --remove -P --purge --get-selections \
2002-02-27 06:47:09 +00:00
--set-selections --update-avail --merge-avail \
--clear-avail --command-fd --forget-old-unavail -s \
--status -p --print-avail -L --listfiles -l --list \
-S --search -C --audit --print-architecture \
--print-gnu-build-architecture \
--print-installation-architecture \
2002-03-27 18:33:34 +00:00
--compare-versions --help --version --force-help \
--force-all --force-auto-select --force-downgrade \
--force-configure-any --force-hold --force-bad-path \
--force-not-root --force-overwrite \
--force-overwrite-diverted --force-bad-verify \
2002-09-28 16:12:24 +00:00
--force-depends-version --force-depends \
2002-03-27 18:33:34 +00:00
--force-confnew --force-confold --force-confdef \
2002-10-09 05:29:14 +00:00
--force-confmiss --force-conflicts --force-architecture\
2002-03-27 18:33:34 +00:00
--force-overwrite-dir --force-remove-reinstreq \
--force-remove-essential -Dh \
2002-02-27 06:47:09 +00:00
--debug= help --licence --admindir= --root= --instdir= \
-O --selected-only -E --skip-same-version \
-G --refuse-downgrade -B --auto-deconfigure \
--no-debsig --no-act -D --debug= --status-fd \
2002-03-11 01:10:17 +00:00
-b --build -I --info -f --field -c --contents \
-x --extract -X --vextract --fsys-tarfile -e --control \
2002-02-27 06:47:09 +00:00
--ignore-depends= --abort-after' -- $cur ) )
2002-10-02 01:32:40 +00:00
; ;
esac
2002-02-27 06:47:09 +00:00
}
2002-06-01 18:58:06 +00:00
complete -F _dpkg $filenames dpkg dpkg-deb
2002-05-05 15:42:42 +00:00
}
2002-02-27 06:47:09 +00:00
2002-05-09 16:20:53 +00:00
# Debian GNU dpkg-reconfigure(8) completion
2002-03-24 18:44:55 +00:00
#
have dpkg-reconfigure &&
2002-10-13 01:46:49 +00:00
_dpkg_reconfigure( )
2002-03-24 18:44:55 +00:00
{
2002-04-02 05:27:50 +00:00
local cur prev opt
2002-03-24 18:44:55 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-03-24 18:44:55 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-04-02 05:27:50 +00:00
case " $prev " in
-@( f| -frontend) )
opt = ( $( echo /usr/share/perl5/Debconf/FrontEnd/* ) )
opt = ( ${ opt [@]##*/ } )
opt = ( ${ opt [@]%.pm } )
2002-09-28 16:12:24 +00:00
COMPREPLY = ( $( compgen -W '${opt[@]}' -- $cur ) )
return 0
2002-04-02 05:27:50 +00:00
; ;
-@( p| -priority) )
2002-09-28 16:12:24 +00:00
COMPREPLY = ( $( compgen -W 'low medium high critical' -- $cur ) )
return 0
2002-04-02 05:27:50 +00:00
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -f --frontend -p --priority -a --all \
-u --unseen-only -h --help -s --showold \
--force --terse' -- $cur ) )
else
2004-10-15 04:47:39 +00:00
COMPREPLY = ( $( _comp_dpkg_installed_packages $cur ) )
2002-04-02 05:27:50 +00:00
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _dpkg_reconfigure $default dpkg-reconfigure
2002-03-24 18:44:55 +00:00
2006-02-24 11:00:38 +00:00
# Debian dpkg-source completion
#
have dpkg-source &&
_dpkg_source( )
{
local cur prev options work i action packopts unpackopts
packopts = "-c -l -F -V -T -D -U -W -E -sa -i -I -sk -sp -su -sr -ss -sn -sA -sK -sP -sU -sR"
unpackopts = "-sp -sn -su"
options = ` echo " -x -b $packopts $unpackopts " | xargs echo | sort -u | xargs echo `
COMPREPLY = ( )
if [ " $1 " != "dpkg-source" ] ; then
2008-10-24 19:39:16 +02:00
return 1
2006-02-24 11:00:38 +00:00
fi
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2006-02-24 11:00:38 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
action = "options"
for ( ( i = 0; i < ${# COMP_WORDS [@] } -1; i++ ) ) ; do
if [ [ ${ COMP_WORDS [ $i ] } = = "-x" ] ] ; then
action = unpack
elif [ [ ${ COMP_WORDS [ $i ] } = = "-b" ] ] ; then
action = pack
elif [ [ ${ COMP_WORDS [ $i ] } = = "-h" ] ] ; then
action = help
fi
done
# if currently seeing a complete option, return just itself.
for i in $options ; do
if [ " $cur " = " $i " ] ; then
COMPREPLY = ( " $cur " )
return 0
fi
done
case " $action " in
"unpack" )
if [ " $cur " = "-" -o " $cur " = "-s" ] ; then
2008-05-17 18:51:31 +02:00
COMPREPLY = ( $unpackopts )
2006-02-24 11:00:38 +00:00
return 0
fi
case " $prev " in
"-x" )
COMPREPLY = ( $( compgen -d -- " $cur " ) \
$( compgen -f -X '!*.dsc' -- " $cur " ) )
return 0
; ;
*)
COMPREPLY = ( $unpackopts $( compgen -d -f -- " $cur " ) )
return 0
; ;
esac
return 0
; ;
"pack" )
if [ " $cur " = "-" ] ; then
COMPREPLY = ( $packopts )
return 0
fi
if [ " $cur " = "-s" ] ; then
COMPREPLY = ( "-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" \
"-sA" "-sK" "-sP" "-sU" "-sR" )
return 0
fi
case " $prev " in
"-b" )
COMPREPLY = ( $( compgen -d -- " $cur " ) )
return 0
; ;
"-c" | "-l" | "-T" | "-i" | "-I" )
# -c: get controlfile
# -l: get per-version info from this file
# -T: read variables here, not debian/substvars
# -i: <regexp> filter out files to ignore diffs of.
# -I: filter out files when building tarballs.
# return directory names and file names
COMPREPLY = ( $( compgen -d -f ) )
return 0
; ;
"-F" )
# -F: force change log format
COMPREPLY = ( $( ( cd /usr/lib/dpkg/parsechangelog; compgen -f " $cur " ) ) )
return 0
; ;
"-V" | "-D" )
# -V: set a substitution variable
# we don't know anything about possible variables or values
# so we don't try to suggest any completion.
COMPREPLY = ( )
return 0
; ;
"-D" )
# -D: override or add a .dsc field and value
# if $cur doesn't contain a = yet, suggest variable names
if echo -- " $cur " | grep -q "=" ; then
# $cur contains a "="
COMPREPLY = ( )
return 0
else
COMPREPLY = ( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files )
return 0
fi
; ;
"-U" )
# -U: remove a field
# Suggest possible fieldnames
COMPREPLY = ( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files )
return 0
; ;
*)
COMPREPLY = ( $packopts )
return 0
; ;
esac
return 0
; ;
*)
# if seeing a partial option, return possible completions.
if [ " $cur " = "-s" ] ; then
COMPREPLY = ( "-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" \
"-sA" "-sK" "-sP" "-sU" "-sR" )
return 0
fi
# else return all possible options.
COMPREPLY = ( $options )
return 0
; ;
esac
} &&
complete -F _dpkg_source dpkg-source
2002-04-22 06:39:07 +00:00
# Debian Linux dselect(8) completion.
#
have dselect &&
_dselect( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-04-22 06:39:07 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-10-02 01:32:40 +00:00
case " $prev " in
--admindir)
_filedir -d
2003-07-20 06:46:37 +00:00
return 0
2002-10-02 01:32:40 +00:00
; ;
-@( D| debug) )
_filedir
2003-07-20 06:46:37 +00:00
return 0
2002-10-02 01:32:40 +00:00
; ;
esac
2002-10-13 01:46:49 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --admindir --help --version --licence \
--license --expert --debug' -- $cur ) )
else
COMPREPLY = ( $( compgen -W ' access update select install config \
remove quit' -- $cur ) )
fi
2002-04-22 06:39:07 +00:00
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _dselect $filenames dselect
2002-04-22 06:39:07 +00:00
2002-06-01 18:58:06 +00:00
# Java completion
#
# available path elements completion
have java && {
_java_path( )
{
cur = ${ cur ##* : }
_filedir '@(jar|zip)'
}
# exact classpath determination
_java_find_classpath( )
{
local i
# search first in current options
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = -@( cp| classpath) ] ] ; then
classpath = ${ COMP_WORDS [i+1] }
break
fi
done
# default to environment
[ -z " $classpath " ] && classpath = $CLASSPATH
# default to current directory
[ -z " $classpath " ] && classpath = .
}
# exact sourcepath determination
_java_find_sourcepath( )
{
local i
# search first in current options
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = -sourcepath ] ] ; then
sourcepath = ${ COMP_WORDS [i+1] }
break
fi
done
# default to classpath
2009-02-07 00:05:12 +02:00
if [ -z " $sourcepath " ] ; then
_java_find_classpath
sourcepath = $classpath
fi
2002-06-01 18:58:06 +00:00
}
# available classes completion
_java_classes( )
{
local classpath i
2003-09-17 05:41:37 +00:00
# find which classpath to use
2002-06-01 18:58:06 +00:00
_java_find_classpath
# convert package syntax to path syntax
cur = ${ cur //.// }
# parse each classpath element for classes
for i in ${ classpath // : / } ; do
if [ -r $i ] && [ [ " $i " = = *.@( jar| zip) ] ] ; then
2003-01-09 10:44:29 +00:00
if type zipinfo & > /dev/null; then
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $( zipinfo -1 \
2003-09-17 05:41:37 +00:00
" $i " | grep " ^ $cur " | grep '\.class$' | \
grep -v " \\ $" ) )
2003-01-09 10:44:29 +00:00
else
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $( jar tf " $i " \
2003-09-17 05:41:37 +00:00
" $cur " | grep " \.class $" | grep -v " \\ $" ) )
2003-01-09 10:44:29 +00:00
fi
2002-06-01 18:58:06 +00:00
elif [ -d $i ] ; then
2003-09-17 05:41:37 +00:00
i = ${ i %/ }
2008-09-06 15:57:15 +02:00
# See bug #496828
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $( find " $i " -type f \
2008-09-06 15:57:15 +02:00
-maxdepth 1 -path " $i / $cur *.class " 2>/dev/null | \
2003-09-17 05:41:37 +00:00
grep -v " \\ $" | sed -e " s|^ $i /|| " ) )
2008-09-06 15:57:15 +02:00
# FIXME: if we have foo.class and foo/, the completion
# returns "foo/"... how to give precedence to files
# over directories?
2002-06-01 18:58:06 +00:00
fi
done
2003-09-17 05:41:37 +00:00
2002-06-01 18:58:06 +00:00
# remove class extension
COMPREPLY = ( ${ COMPREPLY [@]%.class } )
# convert path syntax to package syntax
COMPREPLY = ( ${ COMPREPLY [@]// \/ /. } )
}
# available packages completion
_java_packages( )
{
local sourcepath i
2008-05-06 20:26:08 +01:00
# find which sourcepath to use
2002-06-01 18:58:06 +00:00
_java_find_sourcepath
# convert package syntax to path syntax
cur = ${ cur //.// }
# parse each sourcepath element for packages
for i in ${ sourcepath // : / } ; do
if [ -d $i ] ; then
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $( command ls -F -d \
2002-06-04 03:45:09 +00:00
$i /$cur * 2>/dev/null | sed -e 's|^' $i '/||' ) )
2002-06-01 18:58:06 +00:00
fi
done
# keep only packages
2008-06-23 11:48:08 +02:00
COMPREPLY = ( $( echo " ${ COMPREPLY [@] } " | tr " " "\n" | grep " / $" ) )
2002-06-01 18:58:06 +00:00
# remove packages extension
COMPREPLY = ( ${ COMPREPLY [@]%/ } )
# convert path syntax to package syntax
cur = ${ COMPREPLY [@]// \/ /. }
}
2002-10-05 07:31:43 +00:00
# java completion
#
2002-03-07 17:44:48 +00:00
_java( )
{
2002-10-05 07:31:43 +00:00
local cur prev i
2002-03-07 17:44:48 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-03-07 17:44:48 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-10-05 07:31:43 +00:00
for ( ( i = 1; i < $COMP_CWORD ; i++) ) ; do
case ${ COMP_WORDS [ $i ] } in
-cp| -classpath)
2003-09-11 21:04:10 +00:00
( ( i++) ) # skip the classpath string.
2002-10-05 07:31:43 +00:00
; ;
-*)
# this is an option, not a class/jarfile name.
; ;
*)
# once we've seen a class, just do filename completion
_filedir
return 0
; ;
esac
done
2002-06-01 18:58:06 +00:00
case $prev in
2002-03-07 17:44:48 +00:00
-@( cp| classpath) )
2002-06-01 18:58:06 +00:00
_java_path
2002-05-28 18:34:11 +00:00
return 0
; ;
2002-03-07 17:44:48 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
2002-03-29 15:33:08 +00:00
COMPREPLY = ( $( compgen -W ' -client -hotspot -server -classic \
2002-10-05 07:31:43 +00:00
-cp -classpath -D -verbose -verbose:class \
2002-10-13 01:46:49 +00:00
-verbose:gc -version:jni -version \
2002-10-05 07:31:43 +00:00
-showversion -? -help -X -jar \
2002-10-13 01:46:49 +00:00
-ea -enableassertions -da -disableassertions \
-esa -enablesystemassertions \
-dsa -disablesystemassertions ' -- $cur ) )
2002-03-07 17:44:48 +00:00
else
2002-06-01 18:58:06 +00:00
if [ [ " $prev " = = -jar ] ] ; then
# jar file completion
_filedir jar
2002-03-07 17:44:48 +00:00
else
2002-06-01 18:58:06 +00:00
# classes completion
_java_classes
2002-03-07 17:44:48 +00:00
fi
fi
}
2002-06-01 18:58:06 +00:00
complete -F _java $filenames java
}
# javadoc completion
#
have javadoc &&
_javadoc( )
{
COMPREPLY = ( )
local cur prev
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-06-01 18:58:06 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
-@( overview| helpfile| stylesheetfile) )
_filedir
return 0
; ;
-d)
_filedir -d
return 0
; ;
-@( classpath| bootclasspath| docletpath| sourcepath| extdirs) )
_java_path
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
COMPREPLY = ( $( compgen -W ' -overview -public -protected \
-package -private -help -doclet -docletpath \
-sourcepath -classpath -exclude -subpackages \
-breakiterator -bootclasspath -source -extdirs \
-verbose -locale -encoding -J -d -use -version \
-author -docfilessubdirs -splitindex \
-windowtitle -doctitle -header -footer -bottom \
-link -linkoffline -excludedocfilessubdir \
-group -nocomment -nodeprecated -noqualifier \
-nosince -nodeprecatedlist -notree -noindex \
-nohelp -nonavbar -quiet -serialwarn -tag \
-taglet -tagletpath -charset -helpfile \
-linksource -stylesheetfile -docencoding' -- \
$cur ) )
else
# source files completion
_filedir java
# packages completion
_java_packages
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _javadoc $filenames javadoc
2002-06-01 18:58:06 +00:00
# javac completion
#
have javac &&
_javac( )
{
COMPREPLY = ( )
local cur prev
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-06-01 18:58:06 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
-d)
_filedir -d
return 0
; ;
-@( classpath| bootclasspath| sourcepath| extdirs) )
_java_path
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
COMPREPLY = ( $( compgen -W ' -g -g:none -g:lines -g:vars\
-g:source -O -nowarn -verbose -deprecation -classpath\
-sourcepath -bootclasspath -extdirs -d -encoding -source\
-target -help' -- $cur ) )
else
# source files completion
_filedir java
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _javac $filenames javac
2002-03-07 17:44:48 +00:00
2002-04-29 18:21:41 +00:00
# PINE address-book completion
#
have pine &&
_pineaddr( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-04-29 18:21:41 +00:00
2002-07-08 03:09:22 +00:00
COMPREPLY = ( $( compgen -W '$( awk "{print \$1}" ~/.addressbook 2>/dev/null)' \
2002-04-29 18:21:41 +00:00
-- $cur ) )
2005-07-07 23:36:51 +00:00
} &&
complete -F _pineaddr $default pine
2002-04-29 18:21:41 +00:00
2003-11-25 17:37:37 +00:00
# mutt completion
#
# Mutt doesn't have an "addressbook" like Pine, but it has aliases and
# a "query" function to retrieve addresses, so that's what we use here.
2005-07-07 23:36:51 +00:00
have mutt || have muttng && {
2003-11-25 17:37:37 +00:00
_muttaddr( )
{
2003-12-15 08:30:23 +00:00
_muttaliases
_muttquery
2008-05-10 18:04:06 +02:00
cur = ` _get_cword`
2008-06-21 23:55:32 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $( compgen -u -- $cur ) )
2008-05-10 18:04:06 +02:00
2003-12-15 08:30:23 +00:00
return 0
2003-11-25 17:37:37 +00:00
}
2003-12-15 18:02:22 +00:00
_muttconffiles( )
{
local file sofar
local -a newconffiles
2006-02-24 21:07:47 +00:00
2003-12-15 18:02:22 +00:00
sofar = " $1 "
shift
while [ [ " $1 " ] ] ; do
2004-05-15 21:58:30 +00:00
newconffiles = ( $( sed -rn 's|^source[[:space:]]+([^[:space:]]+).*$|\1|p' $( eval echo $1 ) ) )
2008-06-21 22:19:37 +02:00
for file in " ${ newconffiles [@] } " ; do
2003-12-15 18:02:22 +00:00
[ [ ! " $file " ] ] || [ [ " ${ sofar / ${ file } / } " != " $sofar " ] ] &&
continue
sofar = " $sofar $file "
sofar = " $( eval _muttconffiles \" $sofar \" $file ) "
done
shift
done
echo $sofar
}
2003-11-25 17:37:37 +00:00
_muttaliases( )
{
2003-12-15 08:30:23 +00:00
local cur muttrc
2003-12-15 18:02:22 +00:00
local -a conffiles aliases
2008-06-24 22:43:57 +02:00
cur = ` _get_cword = `
2003-11-25 17:37:37 +00:00
2005-07-12 05:28:08 +00:00
[ -f ~/.${ muttcmd } /${ muttcmd } rc ] && muttrc = " ~/. ${ muttcmd } / ${ muttcmd } rc "
[ -f ~/.${ muttcmd } rc ] && muttrc = " ~/. ${ muttcmd } rc "
2003-12-15 08:30:23 +00:00
[ -z " $muttrc " ] && return 0
2005-07-12 05:28:08 +00:00
2003-12-15 18:02:22 +00:00
conffiles = ( $( eval _muttconffiles $muttrc $muttrc ) )
2004-05-15 21:58:30 +00:00
aliases = ( $( sed -rn 's|^alias[[:space:]]+([^[:space:]]+).*$|\1|p' \
2008-06-21 22:19:37 +02:00
$( eval echo " ${ conffiles [@] } " ) ) )
COMPREPLY = ( " ${ COMPREPLY [@] } " $( compgen -W " ${ aliases [*] } " -- $cur ) )
2003-11-25 17:37:37 +00:00
2003-12-15 08:30:23 +00:00
return 0
2003-11-25 17:37:37 +00:00
}
_muttquery( )
{
2003-12-15 08:30:23 +00:00
local cur querycmd
2003-11-25 17:37:37 +00:00
local -a queryresults
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-11-25 17:37:37 +00:00
2005-07-12 05:28:08 +00:00
querycmd = " $( $muttcmd -Q query_command | sed -r 's|^query_command=\"(.*)\"$|\1|; s|%s|' $cur '|' ) "
2003-12-15 08:30:23 +00:00
if [ -z " $cur " -o -z " $querycmd " ] ; then
queryresults = ( )
2008-05-06 20:20:14 +01:00
else
2003-12-15 18:02:22 +00:00
queryresults = ( $( $querycmd | \
2004-05-15 21:58:30 +00:00
sed -nr '2,$s|^([^[:space:]]+).*|\1|p' ) )
2003-12-15 08:30:23 +00:00
fi
2003-11-25 17:37:37 +00:00
2008-06-23 11:49:56 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $( compgen -W " ${ queryresults [*] } " \
2003-12-15 18:02:22 +00:00
-- $cur ) )
2003-11-25 17:37:37 +00:00
2003-12-15 08:30:23 +00:00
return 0
2003-11-25 17:37:37 +00:00
}
_muttfiledir( )
{
2003-12-15 08:30:23 +00:00
local cur folder spoolfile
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-11-25 17:37:37 +00:00
2003-12-15 08:30:23 +00:00
# This is currently not working so well. Perhaps this function should
# just call _filedir() for the moment.
if [ [ $cur = = [ = +] * ] ] ; then
2005-07-12 05:28:08 +00:00
folder = " $( $muttcmd -Q folder | sed -r 's|^folder=\"(.*)\"$|\1|' ) "
2004-07-03 22:11:09 +00:00
: folder:= ~/Mail
# Match any file in $folder beginning with $cur
# (minus the leading '=' sign).
COMPREPLY = ( $( compgen -f -- " $folder / ${ cur : 1 } " ) )
COMPREPLY = ( ${ COMPREPLY [@]# $folder / } )
return 0
2003-12-15 08:30:23 +00:00
elif [ " $cur " = = !* ] ; then
2005-07-12 05:28:08 +00:00
spoolfile = " $( $muttcmd -Q spoolfile | sed -r 's|^spoolfile=\"(.*)\"$|\1|' ) "
2003-12-15 08:30:23 +00:00
[ ! -z " $spoolfile " ] && eval cur = " ${ cur /^!/ $spoolfile } " ;
fi
_filedir
2003-11-25 17:37:37 +00:00
2003-12-15 08:30:23 +00:00
return 0
2003-11-25 17:37:37 +00:00
}
_mutt( )
{
2003-12-15 18:02:22 +00:00
local cur prev
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-11-25 17:37:37 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
COMPREPLY = ( )
2008-05-06 20:20:14 +01:00
2005-07-12 05:28:08 +00:00
[ ${ COMP_WORDS [0] } = = muttng ] && muttcmd = "muttng" || muttcmd = "mutt"
2003-11-25 17:37:37 +00:00
2003-12-15 18:02:22 +00:00
case " $cur " in
-*)
COMPREPLY = ( $( compgen -W ' -A -a -b -c -e -f -F -H -i -m -n \
-p -Q -R -s -v -x -y -z -Z -h' \
-- $cur ) )
2003-12-15 08:30:23 +00:00
return 0
; ;
2003-11-25 17:37:37 +00:00
*)
2003-12-15 18:02:22 +00:00
case " $prev " in
-@( a| f| F| H| i) )
_muttfiledir
return 0
; ;
-A)
_muttaliases
return 0
; ;
-@( e| m| Q| s| h| p| R| v| y| z| Z) )
return 0
; ;
*)
_muttaddr
return 0
; ;
esac
; ;
2003-12-15 08:30:23 +00:00
esac
2008-05-06 20:20:14 +01:00
2003-11-25 17:37:37 +00:00
}
2005-07-07 23:36:51 +00:00
complete -F _mutt $default $filenames mutt muttng
2003-11-25 17:37:37 +00:00
}
2002-02-18 08:39:02 +00:00
_configure_func( )
2001-03-05 19:12:48 +00:00
{
2002-04-02 17:22:40 +00:00
local cur
2001-03-05 19:12:48 +00:00
2002-02-18 08:39:02 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-02-18 08:39:02 +00:00
2002-04-02 17:22:40 +00:00
# if $COMP_CONFIGURE_HINTS is not null, then completions of the form
# --option=SETTING will include 'SETTING' as a contextual hint
2002-02-18 08:39:02 +00:00
[ [ " $cur " != -* ] ] && return 0
2002-07-15 21:07:02 +00:00
2002-04-02 17:22:40 +00:00
if [ -n " $COMP_CONFIGURE_HINTS " ] ; then
2009-01-08 16:35:03 +01:00
COMPREPLY = ( $( $1 --help 2>& 1 | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' | grep ^$cur ) )
2002-04-02 14:56:59 +00:00
else
2009-01-08 16:35:03 +01:00
COMPREPLY = ( $( $1 --help 2>& 1 | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,=].*//g' | grep ^$cur ) )
2002-04-02 14:56:59 +00:00
fi
2001-03-05 19:12:48 +00:00
}
2002-04-03 17:19:30 +00:00
complete -F _configure_func $default configure
2001-07-08 23:14:13 +00:00
2002-05-09 16:20:53 +00:00
# Debian reportbug(1) completion
2002-03-11 01:15:09 +00:00
#
have reportbug &&
_reportbug( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-03-11 01:15:09 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-f| --filename| -i| --include| --mta| -o| --output)
_filedir
return 0
; ;
-B| --bts)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W "debian guug kde mandrake help" -- \
$cur ) )
2002-03-11 01:15:09 +00:00
return 0
; ;
-e| --editor| --mua)
COMP_WORDS = ( COMP_WORDS[ 0] $cur )
COMP_CWORD = 1
_command
return 0
; ;
--mode)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W "novice standard expert" -- $cur ) )
2002-03-11 01:15:09 +00:00
return 0
; ;
-S| --severity)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W " grave serious important normal \
minor wishlist" -- $cur ) )
2002-09-28 16:12:24 +00:00
return 0
2002-03-11 01:15:09 +00:00
; ;
2002-03-26 18:45:45 +00:00
-u| --ui| --interface)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W "newt text gnome" -- $cur ) )
2002-03-11 01:15:09 +00:00
return 0
; ;
-t| --type)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W "gnats debbugs" -- $cur ) )
2002-09-28 16:12:24 +00:00
return 0
2002-03-11 01:15:09 +00:00
; ;
-T| --tags)
2008-05-01 22:22:11 +02:00
COMPREPLY = ( $( compgen -W " none \
woody potato sarge sarge-ignore etch etch-ignore \
lenny lenny-ignore sid experimental confirmed \
d-i fixed fixed-in-experimental fixed-upstream \
help l10n moreinfo patch pending security \
unreproducible upstream wontfix ipv6 lfs" -- $cur ))
2002-09-28 16:12:24 +00:00
return 0
2002-03-11 01:15:09 +00:00
; ;
*)
; ;
esac
2008-05-06 20:20:14 +01:00
2002-03-11 01:15:09 +00:00
COMPREPLY = ( $( compgen -W ' -h --help -v --version -a --af -b \
--no-query-bts --query-bts -B --bts -c --configure \
2002-09-28 16:12:24 +00:00
--no-config-files --check-available -d --debug \
--no-check-available -e --editor --email -f \
--filename -g --gnupg -H --header -i --include -j \
--justification -l --ldap --no-ldap -L --list-cc -m \
--maintonly --mode --mua --mta --mutt -n --mh --nmh \
-o --output -p --print -P --pgp --proxy --http_proxy\
-q --quiet -Q --query-only --realname --report-quiet \
--reply-to --replyto -s --subject -S --severity \
--smtphost -t --type -T --tags --template -V -x \
--no-cc --package-version -z --no-compress \
--ui --interface -u \
2008-05-01 22:22:11 +02:00
wnpp boot-floppies kernel bugs.debian.org \
cdimage.debian.org general installation-reports \
listarchives lists.debian.org mirrors nm.debian.org \
press project qa.debian.org release-notes \
security.debian.org tech-ctte upgrade-reports \
www.debian.org' -- $cur ) \
$( apt-cache pkgnames -- $cur 2> /dev/null) )
2002-03-11 01:15:09 +00:00
_filedir
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _reportbug $filenames reportbug
2002-03-11 01:15:09 +00:00
2002-05-09 16:20:53 +00:00
# Debian querybts(1) completion
2002-03-11 01:15:09 +00:00
#
have querybts &&
_querybts( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-03-11 01:15:09 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-B| --bts)
2002-03-16 19:49:44 +00:00
COMPREPLY = ( $( compgen -W "debian guug kde mandrake help" -- \
$cur ) )
2002-03-11 01:15:09 +00:00
return 0
; ;
2002-03-26 18:45:45 +00:00
-u| --ui| --interface)
2002-03-11 01:15:09 +00:00
COMPREPLY = ( $( compgen -W "newt text gnome" -- $cur ) )
return 0
; ;
*)
; ;
esac
COMPREPLY = ( $( compgen -W ' -h --help -v --version -A --archive \
-B --bts -l --ldap --no-ldap --proxy= --http_proxy= \
2002-09-28 16:12:24 +00:00
-s --source -w --web -u --ui --interface \
2008-05-01 22:22:11 +02:00
wnpp boot-floppies kernel bugs.debian.org \
cdimage.debian.org general installation-reports \
listarchives lists.debian.org mirrors nm.debian.org \
press project qa.debian.org release-notes \
security.debian.org tech-ctte upgrade-reports \
www.debian.org' -- $cur ) \
$( apt-cache pkgnames -- $cur 2> /dev/null) )
2005-07-07 23:36:51 +00:00
} &&
complete -F _querybts $filenames querybts
2002-03-11 01:15:09 +00:00
2002-04-24 20:26:49 +00:00
# update-alternatives completion
#
2004-05-24 07:00:23 +00:00
have update-alternatives && {
installed_alternatives( )
2002-04-24 20:26:49 +00:00
{
2004-05-24 07:00:23 +00:00
local admindir
# find the admin dir
for i in alternatives dpkg/alternatives rpm/alternatives; do
[ -d /var/lib/$i ] && admindir = /var/lib/$i && break
done
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = --admindir ] ] ; then
admindir = ${ COMP_WORDS [i+1] }
break
2002-04-24 20:26:49 +00:00
fi
2004-05-24 07:00:23 +00:00
done
COMPREPLY = ( $( command ls $admindir | grep " ^ $cur " ) )
}
2002-04-24 20:26:49 +00:00
2004-05-24 07:00:23 +00:00
_update_alternatives( )
{
local cur prev mode args i
2002-04-24 20:26:49 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-04-24 20:26:49 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
--@( altdir| admindir) )
_filedir -d
return 0
; ;
--@( help| version) )
return 0
; ;
esac
2008-05-06 20:26:08 +01:00
# find which mode to use and how many real args used so far
2002-04-24 20:26:49 +00:00
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
2008-05-01 22:59:32 +02:00
if [ [ " ${ COMP_WORDS [i] } " = = --@( install| remove| auto| display| config| remove-all) ] ] ; then
2002-04-24 20:26:49 +00:00
mode = ${ COMP_WORDS [i] }
args = $(( $COMP_CWORD - i))
break
fi
done
case $mode in
--install)
case $args in
1)
_filedir
; ;
2)
installed_alternatives
; ;
3)
_filedir
; ;
esac
; ;
--remove)
case $args in
1)
installed_alternatives
; ;
2)
_filedir
; ;
esac
; ;
--auto)
installed_alternatives
; ;
2008-05-01 22:59:32 +02:00
--remove-all)
installed_alternatives
; ;
2002-04-24 20:26:49 +00:00
--display)
installed_alternatives
; ;
--config)
installed_alternatives
; ;
*)
COMPREPLY = ( $( compgen -W ' --verbose --quiet --help --version \
--altdir --admindir' -- $cur ) \
$( compgen -W ' --install --remove --auto --display \
--config' -- $cur ) )
esac
}
2004-05-24 07:00:23 +00:00
complete -F _update_alternatives update-alternatives
}
2002-04-24 20:26:49 +00:00
2002-05-18 17:05:08 +00:00
# Python completion
#
have python &&
_python( )
{
2002-10-10 06:38:05 +00:00
local prev cur
2002-05-18 17:05:08 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-01-16 18:10:51 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1]##*/ }
2002-05-18 17:05:08 +00:00
2002-10-10 06:38:05 +00:00
case " $prev " in
-Q)
COMPREPLY = ( $( compgen -W "old new warn warnall" -- $cur ) )
return 0
; ;
-W)
COMPREPLY = ( $( compgen -W "ignore default all module once error" -- $cur ) )
return 0
; ;
-c)
2002-05-18 17:05:08 +00:00
_filedir '@(py|pyc|pyo)'
2002-10-10 06:38:05 +00:00
return 0
; ;
!( python| -?) )
2002-10-13 01:46:49 +00:00
[ [ ${ COMP_WORDS [COMP_CWORD-2] } != -@( Q| W) ] ] && _filedir
2002-10-10 06:38:05 +00:00
; ;
esac
# if '-c' is already given, complete all kind of files.
2003-05-17 07:55:11 +00:00
for ( ( i = 0; i < ${# COMP_WORDS [@] } -1; i++ ) ) ; do
2002-10-10 06:38:05 +00:00
if [ [ ${ COMP_WORDS [i] } = = -c ] ] ; then
2002-10-13 01:46:49 +00:00
_filedir
2002-10-10 06:38:05 +00:00
fi
done
if [ [ " $cur " != -* ] ] ; then
_filedir '@(py|pyc|pyo)'
else
2002-10-13 01:46:49 +00:00
COMPREPLY = ( $( compgen -W " - -d -E -h -i -O -Q -S -t -u \
-U -v -V -W -x -c" -- $cur ) )
2002-05-18 17:05:08 +00:00
fi
2002-10-10 06:38:05 +00:00
2002-05-18 17:05:08 +00:00
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _python $filenames python
2002-05-18 17:05:08 +00:00
2002-07-29 16:05:59 +00:00
# Perl completion
#
have perl &&
{
_perlmodules( )
{
2002-10-17 01:05:29 +00:00
COMPREPLY = ( $( compgen -P " $prefix " -W " $( perl -e 'sub mods { my ($base,$dir)=@_; return if $base !~ /^\Q$ENV{cur}/; chdir($dir) or return; for (glob(q[*.pm])) {s/\.pm$//; print qq[$base$_\n]}; mods(/^(?:[.\d]+|$Config{archname}-$Config{osname}|auto)$/ ? undef : qq[${base}${_}\\\\:\\\\:],qq[$dir/$_]) for grep {-d} glob(q[*]); } mods(undef,$_) for @INC;' ) " -- $cur ) )
2002-07-29 16:05:59 +00:00
}
_perl( )
{
local cur prev prefix temp
2008-11-08 09:40:53 +01:00
local optPrefix optSuffix
2002-07-29 16:05:59 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-07-29 16:05:59 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
prefix = ""
2008-11-08 09:40:53 +01:00
# If option not followed by whitespace, reassign prev and cur
2002-07-29 16:05:59 +00:00
if [ [ " $cur " = = -?* ] ] ; then
temp = $cur
prev = ${ temp : 0 : 2 }
cur = ${ temp : 2 }
2008-11-08 09:40:53 +01:00
optPrefix = -P$prev
optSuffix = -S/
2002-07-29 16:05:59 +00:00
prefix = $prev
fi
# only handle module completion for now
case " $prev " in
2008-05-01 22:22:11 +02:00
-I| -x)
2008-11-08 09:40:53 +01:00
local IFS = $'\t\n'
COMPREPLY = ( $( compgen -d $optPrefix $optSuffix -- " $cur " ) )
2008-05-01 22:22:11 +02:00
return 0
; ;
2002-07-29 16:05:59 +00:00
-m| -M)
_perlmodules
return 0
; ;
esac
2009-02-10 23:39:10 +01:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -C -s -T -u -U -W -X -h -v -V -c -w -d \
-D -p -n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) )
else
2003-09-29 07:24:15 +00:00
_filedir
2002-07-29 16:05:59 +00:00
fi
}
2008-11-08 09:40:53 +01:00
complete -F _perl $nospace $filenames perl
2002-07-29 16:05:59 +00:00
_perldoc( )
{
local cur prev prefix temp
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-07-29 16:05:59 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
prefix = ""
# completing an option (may or may not be separated by a space)
if [ [ " $cur " = = -?* ] ] ; then
temp = $cur
prev = ${ temp : 0 : 2 }
cur = ${ temp : 2 }
prefix = $prev
fi
# complete builtin perl functions
case $prev in
-f)
COMPREPLY = ( $( compgen -W ' chomp chop chr crypt hex index lc \
lcfirst length oct ord pack q qq reverse rindex sprintf \
substr tr uc ucfirst y m pos quotemeta s split study qr abs \
atan2 cos exp hex int log oct rand sin sqrt srand pop push \
shift splice unshift grep join map qw reverse sort unpack \
delete each exists keys values binmode close closedir \
dbmclose dbmopen die eof fileno flock format getc print \
printf read readdir rewinddir seek seekdir select syscall \
sysread sysseek syswrite tell telldir truncate warn write \
pack read syscall sysread syswrite unpack vec -X chdir chmod \
chown chroot fcntl glob ioctl link lstat mkdir open opendir \
readlink rename rmdir stat symlink umask unlink utime caller \
2003-07-29 02:19:03 +00:00
continue do dump eval exit goto last next redo return \
2002-07-29 16:05:59 +00:00
sub wantarray caller import local my our package use defined \
2003-07-29 02:19:03 +00:00
formline reset scalar undef \
2002-07-29 16:05:59 +00:00
alarm exec fork getpgrp getppid getpriority kill pipe qx \
2003-07-29 02:19:03 +00:00
setpgrp setpriority sleep system times wait waitpid \
2002-07-29 16:05:59 +00:00
import no package require use bless dbmclose dbmopen package \
ref tie tied untie use accept bind connect getpeername \
getsockname getsockopt listen recv send setsockopt shutdown \
socket socketpair msgctl msgget msgrcv msgsnd semctl semget \
semop shmctl shmget shmread shmwrite endgrent endhostent \
endnetent endpwent getgrent getgrgid getgrnam getlogin \
getpwent getpwnam getpwuid setgrent setpwent endprotoent \
endservent gethostbyaddr gethostbyname gethostent \
getnetbyaddr getnetbyname getnetent getprotobyname \
getprotobynumber getprotoent getservbyname getservbyport \
getservent sethostent setnetent setprotoent setservent \
gmtime localtime time times' -- $cur ) )
return 0
; ;
esac
2009-02-10 23:39:10 +01:00
if [ [ " $cur " = = -* ] ] ; then
2002-07-29 16:05:59 +00:00
COMPREPLY = ( $( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- $cur ) )
2009-02-10 23:39:10 +01:00
else
# return available modules (unless it is clearly a file)
if [ [ " $cur " != */* ] ] ; then
_perlmodules
COMPREPLY = ( " ${ COMPREPLY [@] } " $( compgen -W '$( PAGER=/bin/cat man perl | sed -ne "/perl.*Perl overview/,/perlwin32/p" | awk "\$NF=2 { print \$1}" | grep perl )' -- $cur ) )
fi
fi
2002-07-29 16:05:59 +00:00
}
complete -F _perldoc $default perldoc
}
2002-05-30 17:08:15 +00:00
# rcs(1) completion
#
have rcs &&
_rcs( )
{
2005-01-02 23:48:27 +00:00
local cur prev file dir i
2002-05-30 17:08:15 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-05-30 17:08:15 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
file = ${ cur ##*/ }
dir = ${ cur %/* }
# deal with relative directory
[ " $file " = " $dir " ] && dir = .
COMPREPLY = ( $( compgen -f " $dir /RCS/ $file " ) )
for ( ( i = 0; i < ${# COMPREPLY [@] } ; i++ ) ) ; do
file = ${ COMPREPLY [ $i ]##*/ }
dir = ${ COMPREPLY [ $i ]%RCS/* }
COMPREPLY[ $i ] = $dir $file
done
2008-05-06 20:20:14 +01:00
2005-01-02 23:48:27 +00:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $( compgen -G " $dir / $file *,v " ) )
for ( ( i = 0; i < ${# COMPREPLY [@] } ; i++ ) ) ; do
COMPREPLY[ $i ] = ${ COMPREPLY [ $i ]%,v }
done
2002-05-30 17:08:15 +00:00
# default to files if nothing returned and we're checking in.
# otherwise, default to directories
[ ${# COMPREPLY [@] } -eq 0 -a $1 = ci ] && _filedir || _filedir -d
2005-07-07 23:36:51 +00:00
} &&
complete -F _rcs $filenames ci co rlog rcs rcsdiff
2002-05-30 17:08:15 +00:00
2002-06-01 19:01:05 +00:00
# lilo(8) completion
#
2005-07-20 23:20:36 +00:00
have lilo && {
_lilo_labels( )
{
COMPREPLY = ( $( awk -F'=' '/label/ {print $2}' \
/etc/lilo.conf | sed -e 's/"//g' | grep " ^ $cur " ) )
}
2002-06-01 19:01:05 +00:00
_lilo( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-06-01 19:01:05 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
-@( C| i| m| s| S) )
_filedir
return 0
; ;
-r)
_filedir -d
return 0
; ;
-@( I| D| R) )
# label completion
2005-07-20 23:20:36 +00:00
_lilo_labels
2002-06-01 19:01:05 +00:00
return 0
; ;
-@( A| b| M| u| U) )
# device completion
cur = ${ cur : =/dev/ }
_filedir
return 0
; ;
-T)
# topic completion
COMPREPLY = ( $( compgen -W ' help ChRul EBDA geom geom = \
table = video' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
# relevant options completion
COMPREPLY = ( $( compgen -W ' -A -b -c -C -d -f -g -i -I -l -L -m \
-M -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- \
$cur ) )
fi
2005-07-20 23:20:36 +00:00
}
2005-07-07 23:36:51 +00:00
complete -F _lilo lilo
2005-07-20 23:20:36 +00:00
}
2002-06-01 19:01:05 +00:00
2002-10-01 06:55:38 +00:00
# links completion
#
have links &&
_links( )
{
local cur
2008-05-06 20:20:14 +01:00
2002-10-01 06:55:38 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2008-05-06 20:20:14 +01:00
2002-10-01 06:55:38 +00:00
case " $cur " in
--*)
COMPREPLY = ( $( compgen -W '--help' -- $cur ) )
; ;
-*)
COMPREPLY = ( $( compgen -W ' -async-dns -max-connections \
-max-connections-to-host -retries \
-receive-timeout -unrestartable-receive-timeout\
-format-cache-size -memory-cache-size \
-http-proxy -ftp-proxy -download-dir \
-assume-codepage -anonymous -dump -no-connect \
-source -version -help' -- $cur ) )
; ;
*)
2002-10-01 07:06:01 +00:00
if [ -r ~/.links/links.his ] ; then
2002-10-01 06:55:38 +00:00
COMPREPLY = ( $( compgen -W '$( < ~/.links/links.his )' \
-- $cur ) )
2002-10-01 07:06:01 +00:00
fi
2002-10-01 06:55:38 +00:00
_filedir '@(htm|html)'
return 0
; ;
esac
2008-05-06 20:20:14 +01:00
2002-10-01 06:55:38 +00:00
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _links $filenames links
2002-10-01 06:55:38 +00:00
2002-12-05 01:47:49 +00:00
[ $UNAME = FreeBSD ] && {
2002-12-05 01:52:56 +00:00
# FreeBSD package management tool completion
2002-10-17 01:18:34 +00:00
#
_pkg_delete( )
{
2002-12-05 01:52:56 +00:00
local cur pkgdir prev
2002-10-17 03:01:21 +00:00
2003-04-19 06:52:57 +00:00
pkgdir = ${ PKG_DBDIR :- /var/db/pkg } /
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-12-05 01:52:56 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2004-10-14 07:10:11 +00:00
[ " $prev " = "-o" -o " $prev " = "-p" -o " $prev " = "-W" ] && return 0
2002-10-17 01:18:34 +00:00
2002-10-17 03:01:21 +00:00
COMPREPLY = ( $( compgen -d $pkgdir $cur ) )
2002-10-17 18:51:25 +00:00
COMPREPLY = ( ${ COMPREPLY [@]# $pkgdir } )
2002-10-17 01:18:34 +00:00
return 0
}
2003-05-26 04:50:45 +00:00
complete -F _pkg_delete $dirnames pkg_delete pkg_info
have pkg_deinstall && complete -F _pkg_delete $dirnames pkg_deinstall
2002-12-05 01:47:49 +00:00
2002-12-05 01:52:56 +00:00
# FreeBSD kernel module commands
2002-12-05 01:47:49 +00:00
#
_kldload( )
{
local cur moddir
moddir = /modules/
2003-07-11 06:30:59 +00:00
[ -d $moddir ] || moddir = /boot/kernel/
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-12-05 01:47:49 +00:00
COMPREPLY = ( $( compgen -f $moddir $cur ) )
COMPREPLY = ( ${ COMPREPLY [@]# $moddir } )
COMPREPLY = ( ${ COMPREPLY [@]%.ko } )
return 0
}
complete -F _kldload $filenames kldload
_kldunload( )
{
local cur
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-12-05 01:47:49 +00:00
COMPREPLY = ( $( kldstat | sed -ne " s/^.*[ \t]\+\( $cur [a-z_]\+\).ko $/\1/p " ) )
}
complete -F _kldunload $filenames kldunload
}
2002-10-17 01:18:34 +00:00
2002-12-05 01:52:56 +00:00
# FreeBSD portupgrade completion
#
have portupgrade &&
_portupgrade( )
{
local cur pkgdir prev
2003-04-19 06:52:57 +00:00
pkgdir = ${ PKG_DBDIR :- /var/db/pkg } /
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-12-05 01:52:56 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2004-10-14 07:10:11 +00:00
[ " $prev " = "-l" -o " $prev " = "-L" -o " $prev " = "-o" ] && return 0
2002-12-05 01:52:56 +00:00
COMPREPLY = ( $( compgen -d $pkgdir $cur ) )
COMPREPLY = ( ${ COMPREPLY [@]# $pkgdir } )
COMPREPLY = ( ${ COMPREPLY [@]%-* } )
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _portupgrade $dirnames portupgrade
2002-12-05 01:52:56 +00:00
2003-05-21 07:57:58 +00:00
# FreeBSD portinstall completion
#
have portinstall &&
_portinstall( )
{
2003-07-11 06:30:59 +00:00
local cur portsdir prev indexfile
2003-05-21 07:57:58 +00:00
local -a COMPREPLY2
portsdir = ${ PORTSDIR :- /usr/ports } /
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-05-21 07:57:58 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2003-07-11 06:30:59 +00:00
# First try INDEX-5
indexfile = $portsdir /INDEX-5
2003-12-31 23:48:05 +00:00
# Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x
[ " ${ OSTYPE %.* } " = "freebsd5" -a -f $indexfile ] ||
indexfile = $portsdir /INDEX
2003-05-21 07:57:58 +00:00
[ " $prev " = "-l" -o " $prev " = "-L" -o " $prev " = "-o" ] && return 0
2003-10-17 06:26:39 +00:00
COMPREPLY = ( $( egrep " ^ $cur " < $indexfile | cut -d'|' -f1 ) )
COMPREPLY2 = ( $( egrep " ^[^\|]+\| $portsdir $cur " < $indexfile | \
cut -d'|' -f2 ) )
2003-05-21 07:57:58 +00:00
COMPREPLY2 = ( ${ COMPREPLY2 [@]# $portsdir } )
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " " ${ COMPREPLY2 [@] } " )
2003-05-21 07:57:58 +00:00
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _portinstall $dirnames portinstall
2003-05-21 07:57:58 +00:00
2002-10-17 03:01:21 +00:00
# Slackware Linux removepkg completion
#
have removepkg && [ -f /etc/slackware-version ] &&
_removepkg( )
{
local packages cur
2002-10-17 05:20:05 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-10-17 03:01:21 +00:00
2002-10-17 05:20:05 +00:00
COMPREPLY = ( $( ( cd /var/log/packages; compgen -f -- " $cur " ) ) )
2005-07-07 23:36:51 +00:00
} &&
complete -F _removepkg $filenames removepkg &&
2002-12-19 20:57:36 +00:00
complete $dirnames -f -X '!*.tgz' installpkg upgradepkg explodepkg
2002-10-17 03:01:21 +00:00
2002-10-23 14:05:16 +00:00
# look(1) completion
#
2008-05-06 20:20:14 +01:00
have look &&
2002-10-23 14:05:16 +00:00
_look( )
{
local cur
2008-05-06 20:20:14 +01:00
2002-10-23 14:05:16 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-10-23 14:05:16 +00:00
if [ $COMP_CWORD = 1 ] ; then
2008-09-06 16:10:08 +02:00
COMPREPLY = ( $( compgen -W '$(look $cur 2>/dev/null)' ) )
2002-10-23 14:05:16 +00:00
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _look $default look
2002-10-23 14:05:16 +00:00
2002-12-05 05:31:42 +00:00
# ypcat(1) and ypmatch(1) completion
#
have ypmatch &&
_ypmatch( )
{
2002-12-05 20:43:10 +00:00
local cur map
2002-12-05 05:31:42 +00:00
2002-12-05 20:43:10 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-12-05 05:31:42 +00:00
2002-12-05 16:58:26 +00:00
[ $1 = ypcat ] && [ $COMP_CWORD -gt 1 ] && return 0
[ $1 = ypmatch ] && [ $COMP_CWORD -gt 2 ] && return 0
2002-12-05 20:43:10 +00:00
if [ $1 = ypmatch ] && [ $COMP_CWORD -eq 1 ] && \
[ ${# COMP_WORDS [@] } -eq 3 ] ; then
map = ${ COMP_WORDS [2] }
COMPREPLY = ( $( compgen -W ' $( ypcat $map | \
cut -d':' -f 1 ) ' -- $cur ) )
else
[ $1 = ypmatch ] && [ $COMP_CWORD -ne 2 ] && return 0
2002-12-05 05:31:42 +00:00
COMPREPLY = ( $( compgen -W \
'$( echo $(ypcat -x | cut -d"\"" -f 2))' -- $cur ) )
fi
2002-12-05 20:43:10 +00:00
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _ypmatch ypmatch ypcat
2002-12-05 05:31:42 +00:00
2008-06-24 21:44:51 +02:00
#xrandr(1) completion
#
have xrandr &&
_xrandr( )
{
local cur prev output modes
COMPREPLY = ( )
cur = ` _get_cword`
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
--output)
local outputs = $( xrandr| grep 'connected' | awk '{print $1}' )
COMPREPLY = ( $( compgen -W " $outputs " -- $cur ) )
return 0
; ;
--mode)
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " = = "--output" ] ] ; then
output = ${ COMP_WORDS [i+1] }
break
fi
done
modes = $( xrandr| sed -e " 1,/ $output / d " \
-e " /connected/, $ d " | awk '{print $1}' )
COMPREPLY = ( $( compgen -W " $modes " -- $cur ) )
return 0
; ;
esac
case " $cur " in
*)
COMPREPLY = ( $( compgen -W ' -d -display -help -o \
--orientation -q --query -s --size\
-r --rate -v --version -x -y --screen \
--verbose --dryrun --prop --fb --fbmm --dpi \
--output --auto --mode --preferred --pos \
--reflect --rotate --left-of --right-of \
--above --below --same-as --set --off --crtc \
--newmode --rmmode --addmode --delmode' -- $cur ) )
return 0
; ;
esac
return 0
} &&
complete -F _xrandr xrandr
2002-12-31 02:15:25 +00:00
# mplayer(1) completion
2002-12-19 20:56:47 +00:00
#
2002-12-30 21:23:21 +00:00
have mplayer && {
_mplayer_options_list( )
{
2003-08-03 00:52:43 +00:00
cur = ${ cur % \\ }
2002-12-30 21:23:21 +00:00
COMPREPLY = ( $( $1 $2 help 2> /dev/null | \
sed -e '1,/^Available/d' | awk '{print $1}' | \
2003-08-03 00:52:43 +00:00
sed -e 's/:$//' -e 's/^' ${ 2 #- } '$//' -e 's/<.*//' | \
grep " ^ $cur " ) )
2002-12-30 21:23:21 +00:00
}
2002-12-19 20:56:47 +00:00
_mplayer( )
{
2003-08-03 00:52:43 +00:00
local cmd cur prev skinsdir IFS = $' \t\n' i j k = 0
2002-12-19 20:56:47 +00:00
COMPREPLY = ( )
2002-12-30 21:23:21 +00:00
cmd = ${ COMP_WORDS [0] }
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-12-19 20:56:47 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2002-12-30 21:23:21 +00:00
case " $prev " in
2008-06-24 22:43:57 +02:00
-@( ac| afm| vc| vfm| ao| vo| vop| fstype| demuxer| vf| af) )
2002-12-30 21:23:21 +00:00
_mplayer_options_list mplayer $prev
return 0
; ;
2003-08-03 00:52:43 +00:00
-@( oac| ovc| of) )
2002-12-30 21:23:21 +00:00
_mplayer_options_list mencoder $prev
return 0
; ;
2002-12-19 20:56:47 +00:00
-audiofile)
2009-02-27 16:20:51 +01:00
_filedir '@(mp3|MP3|mpg|MPG|ogg|OGG|w?(a)v|W?(A)V|mid|MID|flac|FLAC|mka|MKA|ape|APE)'
2002-12-30 21:23:21 +00:00
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-font)
_filedir '@(desc|ttf)'
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-sub)
2008-06-21 22:19:37 +02:00
_filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js|ssa|SSA|aas|AAS)'
2003-08-03 00:52:43 +00:00
return 0
; ;
-vobsub)
_filedir '@(idx|IDX|ifo|IFO|sub|SUB)'
2008-05-06 20:20:14 +01:00
IFS = $'\t\n'
2008-06-21 22:19:37 +02:00
COMPREPLY = ( $( for i in " ${ COMPREPLY [@] } " ; do
2003-08-03 00:52:43 +00:00
if [ -f $i -a -r $i ] ; then
echo ${ i %.* }
else
echo $i
fi
done ) )
2008-05-06 20:20:14 +01:00
IFS = $' \t\n'
2003-08-03 00:52:43 +00:00
return 0
; ;
-ifo)
_filedir '@(ifo|IFO)'
return 0
; ;
-cuefile)
_filedir '@(bin|BIN|cue|CUE)'
return 0
; ;
-skin)
2008-10-10 21:01:59 +02:00
# if you don't have installed mplayer in /usr you
2003-08-03 00:52:43 +00:00
# may want to set the MPLAYER_SKINS_DIR global variable
if [ -n " $MPLAYER_SKINS_DIR " ] ; then
skinsdir = $MPLAYER_SKINS_DIR
else
2008-10-10 21:01:59 +02:00
skinsdir = /usr/share/mplayer/Skin
2003-08-03 00:52:43 +00:00
fi
2008-05-06 20:20:14 +01:00
IFS = $'\t\n'
2003-08-03 00:52:43 +00:00
for i in ~/.mplayer/Skin $skinsdir ; do
if [ -d $i -a -r $i ] ; then
for j in $( compgen -d $i /$cur ) ; do
COMPREPLY[ $k ] = ${ j # $i / }
k = $(( + + k))
done
fi
done
2008-05-06 20:20:14 +01:00
IFS = $' \t\n'
2003-08-03 00:52:43 +00:00
return 0
; ;
-@( mixer| @( cdrom| dvd) -device| dvdauth| fb| zrdev) )
cur = ${ cur : =/dev/ }
_filedir
return 0
; ;
-@( edl?( out) | lircconf| menu-cfg| playlist| csslib| dumpfile) | \
-@( subfile| vobsub| aofile| fbmodeconfig| include| o| dvdkey) | \
-passlogfile)
_filedir
return 0
; ;
-@( auto@( q| sync) | loop| menu-root| speed| sstep| aid| alang) | \
-@( ?( @( audio| sub) -) demuxer| bandwidth| cache| chapter) | \
-@( dvd?( angle) | fps| frames| mc| passwd| user| sb| srate| ss| vcd) | \
-@( vi?( d| vo) | ffactor| sid| slang| spu@( align| aa| gauss) ) | \
-@( vobsubid| delay| bpp| brightness| contrast| dfbopts| display) | \
-@( fbmode| geometry| guiwid| hue| icelayer| screen[ wh] | wid) | \
2005-07-20 23:43:47 +00:00
-@( monitor@( aspect| -@( dotclock| [ hv] freq) ) | panscan| saturation) | \
2003-08-03 00:52:43 +00:00
-@( xineramascreen| zr@( crop| norm| quality| [ xy] doff| [ vh] dec) ) | \
-@( aspect| pp| x| y| xy| z| stereo| audio-@( density| delay| preload) ) | \
-@( endpos| osdlevel| ffourcc| sws| channels| skiplimit| format) | \
-@( ofps| aa@( driver| @( osd| sub) color) | vobsubout?( i@( ndex| d) ) ) | \
-sub@( -bg-@( alpha| color) | cp| delay| fps| pos| align| width) | \
-sub@( font-@( blur| outline| autoscale| encoding| @( osd| text) -scale) ) )
return 0
; ;
-lavdopts)
COMPREPLY = ( $( compgen -W 'ec er= bug= idct= gray' \
-- $cur ) )
return 0
; ;
-lavcopts)
COMPREPLY = ( $( compgen -W ' vcodec = vqmin = vqscale = \
vqmax = mbqmin = mbqmax = vqdiff = \
vmax_b_frames = vme = vhq v4mv \
keyint = vb_strategy = vpass = \
aspect = vbitrate = vratetol = \
vrc_maxrate = vrc_minrate = \
vrc_buf_size = vb_qfactor = vi_qfactor = \
vb_qoffset = vi_qoffset = vqblur = \
vqcomp = vrc_eq = vrc_override = \
vrc_init_cplx = vqsquish = vlelim = \
vcelim = vstrict = vdpart vpsize = gray \
vfdct = idct = lumi_mask = dark_mask = \
tcplx_mask = scplx_mask = naq ildct \
format = pred qpel precmp = cmp = \
subcmp = predia = dia = trell last_pred = \
preme = subq = psnr mpeg_quant aic umv' \
-- $cur ) )
return 0
; ;
-ssf)
COMPREPLY = ( $( compgen -W ' lgb = cgb = ls = cs = chs = \
cvs = ' -- $cur ) )
return 0
; ;
-jpeg)
COMPREPLY = ( $( compgen -W ' noprogressive progressive \
nobaseline baseline optimize = \
smooth = quality = outdir = ' -- $cur ) )
return 0
; ;
-xvidopts)
COMPREPLY = ( $( compgen -W 'dr2 nodr2' -- $cur ) )
return 0
; ;
-xvidencopts)
COMPREPLY = ( $( compgen -W ' pass = bitrate = \
fixed_quant = me_quality = 4mv \
rc_reaction_delay_factor = \
rc_averaging_period = rc_buffer = \
quant_range = min_key_interval = \
max_key_interval = mpeg_quant \
mod_quant lumi_mask hintedme \
hintfile debug keyframe_boost = \
kfthreshold = kfreduction = ' -- $cur ) )
return 0
; ;
-divx4opts)
COMPREPLY = ( $( compgen -W ' br = key = deinterlace q = \
min_quant = max_quant = rc_period = \
rc_reaction_period = crispness = \
rc_reaction_ratio = pass = vbrpass = \
help' -- $cur ) )
return 0
; ;
-info)
COMPREPLY = ( $( compgen -W ' name = artist = genre = \
subject = copyright = srcform = \
comment = help' -- $cur ) )
return 0
; ;
-lameopts)
COMPREPLY = ( $( compgen -W ' vbr = abr cbr br = q = aq = \
ratio = vol = mode = padding = fast \
preset = help' -- $cur ) )
return 0
; ;
-rawaudio)
COMPREPLY = ( $( compgen -W ' on channels = rate = \
samplesize = format = ' -- $cur ) )
return 0
; ;
-rawvideo)
COMPREPLY = ( $( compgen -W ' on fps = sqcif qcif cif \
4cif pal ntsc w = h = y420 yv12 yuy2 \
y8 format = size = ' -- $cur ) )
2002-12-30 21:23:21 +00:00
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-aop)
COMPREPLY = ( $( compgen -W ' list = delay = format = fout = \
volume = mul = softclip' -- $cur ) )
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-dxr2)
COMPREPLY = ( $( compgen -W ' ar-mode= iec958-encoded \
iec958-decoded mute ucode = 75ire bw \
color interlaced macrovision = norm = \
square-pixel ccir601-pixel cr-left= \
2003-08-03 00:52:43 +00:00
cr-right= cr-top= cr-bot= ck-rmin= \
ck-gmin= ck-bmin= ck-rmax= ck-gmax= \
ck-bmax= ck-r= ck-g= ck-b= \
ignore-cache= ol-osd= olh-cor= \
olw-cor= olx-cor= oly-cor= overlay \
2003-12-15 08:42:50 +00:00
overlay-ratio= update-cache' -- $cur ) )
2002-12-30 21:23:21 +00:00
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-tv)
COMPREPLY = ( $( compgen -W ' on noaudio driver = device = \
2003-07-20 07:45:06 +00:00
input = freq = outfmt = width = height = \
2002-12-30 21:23:21 +00:00
buffersize = norm = channel = chanlist = \
audiorate = forceaudio alsa amode = \
forcechan = adevice = audioid = volume = \
2003-07-20 07:45:06 +00:00
bass = treble = balance = fps = \
channels = immediatemode = ' -- $cur ) )
2002-12-30 21:23:21 +00:00
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-mf)
2003-12-15 08:42:50 +00:00
COMPREPLY = ( $( compgen -W 'on w= h= fps= type=' \
-- $cur ) )
2002-12-30 21:23:21 +00:00
return 0
2002-12-19 20:56:47 +00:00
; ;
2002-12-30 21:23:21 +00:00
-cdda)
COMPREPLY = ( $( compgen -W ' speed = paranoia = \
generic-dev= sector-size= overlap = \
toc-bias toc-offset= skip noskip' \
-- $cur ) )
return 0
; ;
-input)
COMPREPLY = ( $( compgen -W ' conf = ar-delay ar-rate \
keylist cmdlist js-dev file' -- $cur ) )
return 0
; ;
-af)
2003-07-20 07:45:06 +00:00
COMPREPLY = ( $( compgen -W ' resample resample = \
channels channels = format format = \
volume volume = delay delay = pan \
pan = sub sub = surround surround = ' \
-- $cur ) )
2002-12-30 21:23:21 +00:00
return 0
; ;
-af-adv)
COMPREPLY = ( $( compgen -W 'force= list=' -- $cur ) )
return 0
; ;
2008-06-24 22:43:57 +02:00
-profile)
local profiles = $( sed -ne 's|\[\(.*\)\]|\1|p' ~/.mplayer/config)
COMPREPLY = ( $( compgen -W " $profiles " -- $cur ) )
return 0
; ;
2002-12-30 21:23:21 +00:00
esac
2002-12-19 20:56:47 +00:00
2002-12-30 21:23:21 +00:00
case " $cur " in
-*)
COMPREPLY = ( $( compgen -W ' -aid -alang -audio-demuxer \
-audiofile -cdrom-device -cache -cdda \
-channels -chapter -csslib -demuxer \
-dvd -dvd-device -dvdangle -dvdauth \
-dvdkey -dvdnav -forceidx -fps -frames \
-hr-mp3-seek -idx -mc -mf -ni -nobps \
-passwd -rawaudio -rtsp-stream-over-tcp\
-skipopening -sb -srate -ss -tv -user \
-vcd -vid -vivo -ifo -ffactor -font \
-noautosub -nooverlapsub -sid -slang \
-sub -subcc -subcp -sub-demuxer \
-subdelay -subfont-autoscale \
-subfont-blur -subfont-encoding \
-subfont-osd-scale -subfont-outline \
-subfont-text-scale -subfps -subfile \
-subpos -unicode -utf8 -vobsub \
-vobsubid -ac -afm -aspect -flip \
-lavdopts -noaspect -nosound -pp -ssf \
2003-07-20 07:45:06 +00:00
-stereo -sws -vc -vfm -vop -xvidopts\
-xy -zoom -bandwidth -cuefile \
-noextbased -rawvideo -overlapsub \
-sub-bg-alpha -sub-bg-color -subalign \
-subwidth -sub-no-text-pp -spualign \
-spuaa -spugauss -pphelp -verbose -v \
-noni -noidx -nohr-mp3-seek -extbased \
-bps -oldpp -nozoom -noflip -nounicode \
2008-06-24 22:43:57 +02:00
-noutf8 -profile -vf -af' -- $cur ) )
2002-12-30 21:23:21 +00:00
# add mplayer specific options
2008-06-21 22:19:37 +02:00
[ [ " $cmd " = = @( ?( g) mplayer) ] ] && COMPREPLY = ( " ${ COMPREPLY [@] } " \
2002-12-30 21:23:21 +00:00
$( compgen -W ' -autoq -autosync -benchmark \
-framedrop -h -help -hardframedrop \
-identify -input -lircconf -loop \
-nojoystick -nolirc -nortc -playlist \
-quiet -really-quiet -rnd -sdp -skin \
-slave -softsleep -speed -sstep \
-use-stdin -dumpaudio -dumpfile \
-dumpstream -dumpvideo -dumpmicrodvdsub\
-dumpmpsub -dumpsrtsub -dumpjacosub \
-dumpsami -dumpsub -osdlevel -af \
-af-adv -ao -aofile -aop -delay -mixer \
-nowaveheader -bpp -brightness \
-contrast -display -double -dr -dxr2 \
-fb -fbmode -fbmodeconfig -forcexv -fs \
-geometry -hue -icelayer -jpeg \
2005-07-20 23:43:47 +00:00
-monitor-dotclock -monitor-hfreq \
-monitor-vfreq -monitoraspect \
2002-12-30 21:23:21 +00:00
-nograbpointer -noslices -panscan \
-rootwin -saturation -screenw -screenh \
2005-02-03 08:12:44 +00:00
-stop-xscreensaver -vm -vo -vsync -wid \
2002-12-30 21:23:21 +00:00
-xineramascreen -z -zrbw -zrcrop \
2003-07-20 07:45:06 +00:00
-zrdev -zrfd -zrhelp -zrnorm -zrquality \
-zrvdec -zrhdec -zrxdoff -zrydoff -y \
-edl -edlout -enqueue -fixed-vo \
-menu -menu-root -menu-cfg -shuffle \
2003-08-03 00:52:43 +00:00
-format -aahelp -dfbopts -fstype \
-guiwid -nokeepaspect -x --help \
-aaosdcolor -aasubcolor -aadriver \
-aaextended -aaeight' -- $cur ) )
2002-12-30 21:23:21 +00:00
# add mencoder specific options
2008-06-21 22:19:37 +02:00
[ [ " $cmd " = mencoder ] ] && COMPREPLY = ( " ${ COMPREPLY [@] } " \
2002-12-30 21:23:21 +00:00
$( compgen -W ' -audio-density -audio-delay \
-audio-preload -divx4opts -endpos \
-ffourcc -include -info -lameopts \
-lavcopts -noskip -o -oac -ofps -ovc \
-passlogfile -skiplimit -vobsubout \
-vobsuboutindex -vobsuboutid \
2003-08-03 00:52:43 +00:00
-xvidencopts -of --verbose' -- $cur ) )
2002-12-30 21:23:21 +00:00
; ;
*)
2009-02-27 16:20:51 +01:00
_filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fl[iv]|FL[IV]|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m4[av]|M4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|ts|TS|3g[p2]|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2ts|M2TS|vdr|VDR|xvid|XVID|ape|APE)'
2002-12-30 21:23:21 +00:00
; ;
2002-12-19 20:56:47 +00:00
esac
return 0
}
2005-07-19 04:28:48 +00:00
complete $filenames -F _mplayer mplayer mencoder gmplayer kplayer
2002-12-30 21:23:21 +00:00
}
2002-12-19 20:56:47 +00:00
2003-04-08 05:48:47 +00:00
# KDE dcop completion
#
have dcop &&
_dcop( )
{
local cur compstr
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-04-08 05:48:47 +00:00
if [ -z $cur ] ; then
compstr = ${ COMP_WORDS [*] }
else
compstr = $( command echo ${ COMP_WORDS [*] } | sed " s/ $cur $// " )
fi
COMPREPLY = ( $( compgen -W '$( command $compstr | sed s/\(.*\)// )' -- $cur ) )
2005-07-07 23:36:51 +00:00
} &&
complete -F _dcop dcop
2003-04-08 05:48:47 +00:00
2002-12-31 01:40:22 +00:00
# wvdial(1) completion
#
have wvdial &&
_wvdial( )
{
2003-12-31 23:51:46 +00:00
local cur prev config i IFS = $'\t\n'
2002-12-31 01:40:22 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-12-31 01:40:22 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
--config)
_filedir
return 0
; ;
esac
case $cur in
-*)
COMPREPLY = ( $( compgen -W ' --config --chat \
2003-12-31 23:51:46 +00:00
--remotename --help --version --no-syslog' \
-- $cur ) )
2002-12-31 01:40:22 +00:00
; ;
*)
2003-12-31 23:51:46 +00:00
# start with global and personal config files
config = "/etc/wvdial.conf" $'\t' " $HOME /.wvdialrc "
# replace with command line config file if present
2002-12-31 01:40:22 +00:00
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
2003-12-31 23:51:46 +00:00
if [ [ " ${ COMP_WORDS [i] } " = = "--config" ] ] ; then
config = ${ COMP_WORDS [i+1] }
2002-12-31 01:40:22 +00:00
break
fi
done
2003-12-31 23:51:46 +00:00
# parse config files for sections and
# remove default section
COMPREPLY = ( $( sed -ne \
" s|^\[Dialer \( $cur .*\)\] $|\1|p " \
$config 2>/dev/null | grep -v '^Defaults$' ) )
# escape spaces
COMPREPLY = ${ COMPREPLY // / \\ }
2002-12-31 01:40:22 +00:00
; ;
esac
2005-07-07 23:36:51 +00:00
} &&
complete -F _wvdial wvdial
2002-12-31 01:40:22 +00:00
2002-12-31 01:59:25 +00:00
# gpg(1) completion
#
have gpg &&
2008-05-06 20:20:14 +01:00
_gpg( )
2002-12-31 01:59:25 +00:00
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-12-31 01:59:25 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
2008-05-06 20:20:14 +01:00
-@( s| -sign| -clearsign| -decrypt-files| -load-extension) )
2003-04-18 23:12:37 +00:00
_filedir
return 0
; ;
2008-05-06 20:20:14 +01:00
--@( export| @( ?( l| nr| nrl) sign| edit) -key) )
2003-04-18 23:12:37 +00:00
# return list of public keys
2008-09-27 11:23:40 +02:00
COMPREPLY = ( $( compgen -W " $( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*/\([^ ]*\).*$@\1@p;s@^.*\(<\([^>]*\)>\).*$@\2@p' ) " -- " $cur " ) )
2003-04-18 23:12:37 +00:00
return 0
; ;
-@( r| -recipient) )
2008-09-27 12:05:11 +02:00
COMPREPLY = ( $( compgen -W " $( gpg --list-keys 2>/dev/null | sed -ne 's@^.*<\([^>]*\)>.*$@\1@p' ) " -- " $cur " ) )
2003-04-18 23:12:37 +00:00
if [ -e ~/.gnupg/gpg.conf ] ; then
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $( compgen -W " $( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf ) " -- " $cur " ) )
2003-04-18 23:12:37 +00:00
fi
return 0
; ;
2002-12-31 01:59:25 +00:00
esac
if [ [ " $cur " = = -* ] ] ; then
2004-07-03 22:20:34 +00:00
COMPREPLY = ( $( compgen -W ' -s -b -e -f -c -d -a -r -u -Z -o -v\
-q -n -N $( gpg --dump-options) ' -- $cur ) )
2002-12-31 01:59:25 +00:00
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _gpg $default gpg
2002-12-31 01:59:25 +00:00
2003-04-14 06:35:23 +00:00
# iconv(1) completion
#
have iconv &&
_iconv( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-04-14 06:35:23 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2006-03-01 08:47:38 +00:00
case " $prev " in
-@( f| t| -@( from| to) -code) )
COMPREPLY = ( $( compgen -W \
'$( iconv --list | sed -e "s@//@@;" )' -- " $cur " ) )
return 0
; ;
esac
2003-04-14 06:35:23 +00:00
if [ [ " $cur " = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --from-code -f --to-code -t --list
--output -o --verbose' -- " $cur " ) )
return 0
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _iconv $default iconv
2003-04-14 06:35:23 +00:00
2003-04-15 06:54:50 +00:00
# dict(1) completion
#
2003-08-03 23:36:10 +00:00
{ have dict || have rdict; } && {
2003-04-15 06:54:50 +00:00
_dictdata( )
{
dict $host $port $1 2>/dev/null | sed -ne \
's/^[' $'\t ' '][' $'\t ' ']*\([^' $'\t ' ']*\).*$/\1/p'
}
_dict( )
{
local cur prev host port db dictfile
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-04-15 06:54:50 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
dictfile = /usr/share/dict/words
for ( ( i = 1; i < COMP_CWORD; i++ ) ) ; do
case " ${ COMP_WORDS [i] } " in
-@( h| --host) )
host = ${ COMP_WORDS [i+1] }
[ -n " $host " ] && host = " -h $host "
i = $(( + + i))
; ;
-@( p| -port) )
port = ${ COMP_WORDS [i+1] }
[ -n " $port " ] && port = " -p $port "
i = $(( + + i))
; ;
-@( d| -database) )
db = ${ COMP_WORDS [i+1] }
[ -n " $db " ] && host = " -d $db "
i = $(( + + i))
; ;
*)
; ;
esac
done
if [ [ " $cur " = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -h --host -p --port -d --database \
-m --match -s --strategy -c --config -C \
--nocorrect -D --dbs -S --strats -H \
--serverhelp -i --info -I --serverinfo \
-a --noauth -u --user -k --key -V --version \
-L --license --help -v --verbose -r --raw \
-P --pager --debug --html --pipesize --client' \
-- " $cur " ) )
return 0
fi
case " $prev " in
-@( d| -database| i| info) )
2003-06-07 21:09:34 +00:00
COMPREPLY = ( $( compgen -W '$( _dictdata -D )' -- " $cur " ) )
2003-04-15 06:54:50 +00:00
return 0
; ;
-@( s| -strategy) )
2003-06-07 21:09:34 +00:00
COMPREPLY = ( $( compgen -W '$( _dictdata -S )' -- " $cur " ) )
2003-04-15 06:54:50 +00:00
return 0
; ;
*)
; ;
esac
[ -r $dictfile ] && \
COMPREPLY = ( $( compgen -W '$( cat $dictfile )' -- " $cur " ) )
}
2003-08-03 23:36:10 +00:00
complete -F _dict $default dict rdict
}
2003-04-15 06:54:50 +00:00
2003-08-03 23:36:10 +00:00
# cdrecord(1) completion
2003-08-03 23:40:25 +00:00
#
2009-02-12 22:31:27 +01:00
( have cdrecord || have wodim) &&
2003-08-03 23:36:10 +00:00
_cdrecord( )
{
local cur prev i generic_options track_options track_mode
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-08-03 23:36:10 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
# foo=bar style option
if [ [ " $cur " = = *= * ] ] ; then
prev = ${ cur /=*/ }
cur = ${ cur /*=/ }
case " $prev " in
@( text| cue) file)
_filedir
return 0
; ;
blank)
COMPREPLY = ( $( compgen -W ' help all fast \
track unreserve trtail unclose session' \
-- $cur ) )
return 0
; ;
driveropts)
COMPREPLY = ( $( compgen -W ' burnfree noburnfree\
varirec = audiomaster forcespeed noforcespeed\
speedread nospeedread singlesession \
nosinglesession hidecdr nohidecdr tattooinfo\
tattoofile = ' -- $cur ) )
return 0
; ;
esac
fi
generic_options = ( -version -v -V -d -silent -s -force -immed -dummy \
-dao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc \
-atip -fix -nofix -waiti -load -lock -eject -format \
-setdropts -checkdrive -prcap -inq -scanbus -reset \
-abort -overburn -ignsize -useinfo -packet -noclose \
-text debug = kdebug = kd = minbuf = speed = blank = fs = \
dev = gracetime = timeout = driver = driveropts = \
defpregap = pktsize = mcn = textfile = cuefile = )
track_options = ( -audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi \
-isosize -pad padsize = -nopad -shorttrack -noshorttrack\
pregap = -preemp -nopreemp -copy -nocopy -scms tcsize = \
isrc = index = )
# look if previous was either a file or a track option
track_mode = 0
if [ $COMP_CWORD -gt 1 ] ; then
if [ -f " $prev " ] ; then
track_mode = 1
else
for ( ( i = 0; i < ${# track_options [@] } ; i++ ) ) ; do
if [ [ " ${ track_options [i] } " = = " $prev " ] ] ; then
track_mode = 1
break
fi
done
fi
fi
# files are always eligible completion
_filedir
# track options are always available
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " $( compgen -W '${track_options[@]}' -- $cur ) )
2003-08-03 23:36:10 +00:00
# general options are no more available after file or track option
if [ $track_mode -eq 0 ] ; then
2008-06-21 22:19:37 +02:00
COMPREPLY = ( " ${ COMPREPLY [@] } " \
2003-08-03 23:36:10 +00:00
$( compgen -W '${generic_options[@]}' -- $cur ) )
fi
2005-07-07 23:36:51 +00:00
} &&
2009-02-12 22:31:27 +01:00
complete -F _cdrecord $filenames cdrecord wodim
2003-08-03 23:36:10 +00:00
2003-08-04 03:15:28 +00:00
# mkisofs(8) completion
#
2009-02-12 22:31:27 +01:00
( have mkisofs || have genisoimage) &&
2003-08-04 03:15:28 +00:00
_mkisofs( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-08-04 03:15:28 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( o| abstract| biblio| check-session| copyright| log-file| root-info| prep-boot| *-list) )
_filedir
return 0
; ;
-*-charset)
COMPREPLY = ( $( mkisofs -input-charset help 2>& 1 | \
tail +3 | grep " ^ $cur " ) )
return 0
; ;
-uid)
_uids
return 0
; ;
-gid)
_gids
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -abstract -A -allow-lowercase \
-allow-multidot -biblio -cache-inodes \
-no-cache-inodes -b -eltorito-alt-boot -B -G \
-hard-disk-boot -no-emul-boot -no-boot \
-boot-load-seg -boot-load-size \
-boot-info-table -C -c -check-oldname \
-check-session -copyright -d -D -dir-mode \
2004-03-30 20:17:15 +00:00
-dvd-video -f -file-mode -gid -gui \
2003-08-04 03:15:28 +00:00
-graft-points -hide -hide-list -hidden \
-hidden-list -hide-joliet -hide-joliet-list \
-hide-joliet-trans-tbl -hide-rr-moved \
-input-charset -output-charset -iso-level -J \
-joliet-long -jcharset -l -L -log-file -m \
-exclude-list -max-iso9660-filenames -M -N \
-new-dir-mode -nobak -no-bak -force-rr -no-rr \
-no-split-symlink-components \
-no-split-symlink-fields -o -pad -no-pad \
-path-list -P -p -print-size -quiet -R -r \
-relaxed-filenames -sort -split-output \
-stream-media-size -stream-file-name -sysid -T\
-table-name -ucs-level -udf -uid \
-use-fileversion -U -no-iso-translate -V \
-volset -volset-size -volset-seqno -v -x -z \
-hfs -apple -map -magic -hfs-creator \
-hfs-type -probe -no-desktop -mac-name \
-boot-hfs-file -part -auto -cluster-size \
-hide-hfs -hide-hfs-list -hfs-volid \
-icon-position -root-info -prep-boot \
-input-hfs-charset -output-hfs-charset \
-hfs-unlock -hfs-bless -hfs-parms --cap \
--netatalk --double --ethershare --ushare \
--exchange --sgi --xinet --macbin --single \
--dave --sfm --osx-double --osx-hfs' -- $cur ) )
else
_filedir
fi
2005-07-07 23:36:51 +00:00
} &&
2009-02-12 22:31:27 +01:00
complete -F _mkisofs $filenames mkisofs genisoimage
2003-08-04 03:15:28 +00:00
2003-08-18 19:59:05 +00:00
# mc(1) completion
#
have mc &&
_mc( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-08-18 19:59:05 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2005-07-20 23:26:01 +00:00
# -name value style option
case " $prev " in
-@( e| v| l| P) )
_filedir
return 0
; ;
esac
# --name=value style option
if [ [ " $cur " = = *= * ] ] ; then
prev = ${ cur /=*/ }
cur = ${ cur /*=/ }
case " $prev " in
--@( edit| view| ftplog| printwd) )
_filedir
return 0
; ;
esac
fi
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -a --stickchars -b --nocolor -c \
--color -C --colors= -d --nomouse -e --edit= -f \
--datadir -k --resetsoft -l --ftplog= -P --printwd= \
-s --slow -t --termcap -u --nosubshell -U --subshell \
-v --view= -V --version -x --xterm -h --help' -- $cur ) )
2003-08-18 19:59:05 +00:00
else
_filedir -d
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _mc $filenames mc
2003-08-18 19:59:05 +00:00
2003-10-07 06:17:33 +00:00
# yum(8) completion
#
2004-02-09 21:06:01 +00:00
have yum && {
2009-01-11 23:41:45 +02:00
_yum_list( )
{
2009-01-12 00:31:40 +02:00
if [ [ " $1 " = = all ] ] ; then
2009-01-11 23:41:45 +02:00
# Try to strip in between headings like "Available Packages"
# This will obviously only work for English :P
COMPREPLY = ( $( yum -d 0 -C list $1 " $cur * " 2>/dev/null | \
grep -iv '^\(Available\|Installed\|Updated\) Packages' | \
sed -e 's/[[:space:]].*//' ) )
else
# Drop first line (e.g. "Updated Packages")
COMPREPLY = ( $( yum -d 0 -C list $1 " $cur * " 2>/dev/null | \
sed -ne 1d -e 's/[[:space:]].*//p' ) )
fi
}
2003-10-07 06:17:33 +00:00
_yum( )
{
2003-11-15 07:59:13 +00:00
local cur prev special
2008-05-06 20:20:14 +01:00
2003-11-15 07:59:13 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-11-15 07:59:13 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2003-10-07 06:17:33 +00:00
2003-11-15 07:59:13 +00:00
for ( ( i = 0; i < ${# COMP_WORDS [@] } -1; i++ ) ) ; do
2009-01-11 23:41:45 +02:00
if [ [ ${ COMP_WORDS [i] } = = @( install| update| upgrade| remove| erase| deplist| info) ] ] ; then
2003-11-15 07:59:13 +00:00
special = ${ COMP_WORDS [i] }
fi
done
2003-10-07 06:17:33 +00:00
2003-11-15 07:59:13 +00:00
if [ -n " $special " ] ; then
case $special in
2009-01-11 23:41:45 +02:00
install)
_yum_list available
2003-11-15 07:59:13 +00:00
return 0
; ;
2009-01-11 23:41:45 +02:00
deplist| info)
_yum_list all
return 0
; ;
upgrade| update)
_yum_list updates
return 0
; ;
remove| erase)
# _rpm_installed_packages is not arch-qualified
_yum_list installed
2003-11-15 07:59:13 +00:00
return 0
; ;
esac
fi
2003-10-07 06:17:33 +00:00
2003-11-15 07:59:13 +00:00
case $cur in
--*)
2006-02-26 18:20:21 +00:00
COMPREPLY = ( $( compgen -W '--installroot --version --help --enablerepo --disablerepo --exclude --obsoletes --noplugins' -- $cur ) )
2003-11-15 07:59:13 +00:00
return 0
; ;
-*)
COMPREPLY = ( $( compgen -W '-c -e -d -y -t -R -C -h' -- $cur ) )
return 0
; ;
esac
2003-10-07 06:17:33 +00:00
2003-11-15 07:59:13 +00:00
case $prev in
list)
2006-02-26 18:20:21 +00:00
COMPREPLY = ( $( compgen -W 'all available updates installed extras obsoletes recent' -- $cur ) )
2003-11-15 07:59:13 +00:00
; ;
clean)
2006-02-26 18:20:21 +00:00
COMPREPLY = ( $( compgen -W 'packages headers metadata cache dbcache all' -- $cur ) )
; ;
2009-01-11 23:41:45 +02:00
localinstall| localupdate)
# TODO: should not match *src.rpm
2006-02-26 18:20:21 +00:00
_filedir rpm
2003-11-15 07:59:13 +00:00
; ;
-c)
_filedir
; ;
--installroot)
_filedir -d
; ;
*)
COMPREPLY = ( $( compgen -W ' install update check-update upgrade remove list \
search info provides clean groupinstall groupupdate \
2006-02-26 18:20:21 +00:00
grouplist deplist erase groupinfo groupremove \
localinstall localupdate makecache resolvedep \
shell whatprovides' -- $cur ) )
2003-11-15 07:59:13 +00:00
; ;
esac
2003-10-07 06:17:33 +00:00
}
2005-07-07 23:36:51 +00:00
complete -F _yum $filenames yum
2003-10-07 06:17:33 +00:00
# yum-arch(8) completion
#
_yum_arch( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-10-07 06:17:33 +00:00
case " $cur " in
2003-12-15 08:30:23 +00:00
-*)
COMPREPLY = ( $( compgen -W '-d -v -vv -n -c -z -s -l -q' -- $cur ) )
; ;
*)
_filedir -d
; ;
2003-10-07 06:17:33 +00:00
esac
return 0
}
2003-10-08 01:12:27 +00:00
complete -F _yum_arch $filenames yum-arch
2004-02-09 21:06:01 +00:00
}
2003-10-07 06:17:33 +00:00
2003-12-15 08:42:50 +00:00
# ImageMagick completion
#
have convert && {
_ImageMagick( )
{
local prev
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-channel)
COMPREPLY = ( $( compgen -W ' Red Green Blue Opacity \
Matte Cyan Magenta Yellow Black' -- $cur ) )
return 0
; ;
-colormap)
COMPREPLY = ( $( compgen -W 'shared private' -- $cur ) )
return 0
; ;
-colorspace)
COMPREPLY = ( $( compgen -W ' GRAY OHTA RGB Transparent \
XYZ YCbCr YIQ YPbPr YUV CMYK' -- $cur ) )
return 0
; ;
-compose)
COMPREPLY = ( $( compgen -W ' Over In Out Atop Xor Plus \
Minus Add Subtract Difference Multiply Bumpmap\
Copy CopyRed CopyGreen CopyBlue CopyOpacity' \
-- $cur ) )
return 0
; ;
-compress)
COMPREPLY = ( $( compgen -W ' None BZip Fax Group4 JPEG \
Lossless LZW RLE Zip' -- $cur ) )
return 0
; ;
-dispose)
COMPREPLY = ( $( compgen -W ' Undefined None Background \
Previous' -- $cur ) )
return 0
; ;
-encoding)
COMPREPLY = ( $( compgen -W ' AdobeCustom AdobeExpert \
AdobeStandard AppleRoman BIG5 GB2312 Latin2 \
None SJIScode Symbol Unicode Wansung' -- $cur ) )
return 0
; ;
-endian)
COMPREPLY = ( $( compgen -W 'MSB LSB' -- $cur ) )
return 0
; ;
-filter)
COMPREPLY = ( $( compgen -W ' Point Box Triangle Hermite \
Hanning Hamming Blackman Gaussian Quadratic \
Cubic Catrom Mitchell Lanczos Bessel Sinc' \
-- $cur ) )
return 0
; ;
-format)
COMPREPLY = ( $( convert -list format | \
awk '/ [r-][w-][+-] / {print $1}' | \
tr -d '*' | tr [ :upper:] [ :lower:] | \
grep " ^ $cur " ) )
return 0
; ;
-gravity)
COMPREPLY = ( $( compgen -W ' Northwest North NorthEast \
West Center East SouthWest South SouthEast' \
-- $cur ) )
return 0
; ;
-intent)
COMPREPLY = ( $( compgen -W ' Absolute Perceptual \
Relative Saturation' -- $cur ) )
return 0
; ;
-interlace)
COMPREPLY = ( $( compgen -W 'None Line Plane Partition' \
-- $cur ) )
return 0
; ;
-limit)
COMPREPLY = ( $( compgen -W 'Disk File Map Memory' \
-- $cur ) )
return 0
; ;
-list)
COMPREPLY = ( $( compgen -W ' Delegate Format Magic \
Module Resource Type' -- $cur ) )
return 0
; ;
-map)
COMPREPLY = ( $( compgen -W ' best default gray red \
green blue' -- $cur ) )
_filedir
return 0
; ;
-noise)
COMPREPLY = ( $( compgen -W ' Uniform Gaussian \
Multiplicative \
Impulse Laplacian Poisson' -- $cur ) )
return 0
; ;
-preview)
COMPREPLY = ( $( compgen -W ' Rotate Shear Roll Hue \
Saturation Brightness Gamma Spiff \
Dull Grayscale Quantize Despeckle \
ReduceNoise AddNoise Sharpen Blur \
Treshold EdgeDetect Spread Shade \
Raise Segment Solarize Swirl Implode \
Wave OilPaint CharcoalDrawing JPEG' \
-- $cur ) )
return 0
; ;
-@( mask| profile| texture| tile| write) )
_filedir
return 0
; ;
-type)
COMPREPLY = ( $( compgen -W ' Bilevel Grayscale Palette \
PaletteMatte TrueColor TrueColorMatte \
ColorSeparation ColorSeparationlMatte \
Optimize' -- $cur ) )
return 0
; ;
-units)
COMPREPLY = ( $( compgen -W ' Undefined PixelsPerInch \
PixelsPerCentimeter' -- $cur ) )
return 0
; ;
-virtual-pixel)
COMPREPLY = ( $( compgen -W 'Constant Edge mirror tile' \
-- $cur ) )
return 0
; ;
-visual)
COMPREPLY = ( $( compgen -W ' StaticGray GrayScale \
StaticColor PseudoColor TrueColor \
DirectColor defaut visualid' -- $cur ) )
return 0
; ;
esac
}
_convert( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-12-15 08:42:50 +00:00
_ImageMagick
if [ [ " $cur " = = -* ] ] ; then
2008-06-24 21:42:45 +02:00
COMPREPLY = ( $( compgen -W ' -adaptive-blur -adaptive-resize \
-adaptive-sharpen -adjoin -affine -alpha -annotate \
-antialias -append -attenuate -authenticate \
-auto-orient -average -background -bench -bias \
-black-point-compensation -black-threshold \
-blue-primary -blur -border -bordercolor -caption \
-channel -charcoal -chop -clip -clip-mask -clip-path \
-clone -clut -coalesce -colorize -colors -colorspace \
-combine -comment -compose -composite -compress \
-contrast -contrast-stretch -convolve -crop -cycle \
-debug -decipher -deconstruct -define -delay -delete \
-density -depth -despeckle -display -dispose -distort \
-dither -draw -edge -emboss -encipher -encoding \
-endian -enhance -equalize -evaluate -extent -extract \
-family -fill -filter -flatten -flip -floodfill -flop \
-font -format -frame -fuzz -fx -gamma -gaussian-blur \
-geometry -gravity -green-primary -help -identify \
-implode -insert -intent -interlace -interpolate \
-label -lat -layers -level -limit -linear-stretch \
-liquid-rescale -list -log -loop -map -mask \
-mattecolor -median -modulate -monitor -monochrome \
-morph -mosaic -motion-blur -negate -noise -normalize \
-opaque -ordered-dither -orient -page -paint -ping \
-pointsize -polaroid -posterize -preview -print \
-process -profile -quality -quantize -quiet \
-radial-blur -raise -random-threshold -recolor \
-red-primary -regard-warnings -region -render -repage \
-resample -resize -respect-parenthesis -reverse -roll \
-rotate -sample -sampling-factor -scale -scene -seed \
-segment -separate -sepia-tone -set -shade -shadow \
-sharpen -shave -shear -sigmoidal-contrast -size \
-sketch -solarize -splice -spread -stretch -strip \
-stroke -strokewidth -style -swap -swirl -taint \
-texture -threshold -thumbnail -tile -tile-offset \
-tint -transform -transparent -transparent-color \
-transpose -transverse -treedepth -trim -type \
-undercolor -unique-colors -units -unsharp -verbose \
-version -view -vignette -virtual-pixel -wave \
-weight -white-point -white-threshold \
2003-12-15 08:42:50 +00:00
-write' -- $cur ) )
elif [ [ " $cur " = = +* ] ] ; then
COMPREPLY = ( $( compgen -W ' +adjoin +append +compress \
+contrast +debug +dither +endian +gamma +label +map \
+mask +matte +negate +noise +page +raise +render \
2008-05-06 20:20:14 +01:00
+write' -- $cur ) )
2003-12-15 08:42:50 +00:00
else
_filedir
fi
}
complete -F _convert $filenames convert
_mogrify( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-12-15 08:42:50 +00:00
_ImageMagick
if [ [ " $cur " = = -* ] ] ; then
2008-06-24 21:42:45 +02:00
COMPREPLY = ( $( compgen -W ' -adaptive-blur -adaptive-resize \
-adaptive-sharpen -adjoin -affine -alpha -annotate \
-antialias -attenuate -authenticate -auto-orient \
-background -bias -black-point-compensation \
-black-threshold -blue-primary -blur -border \
-bordercolor -caption -channel -charcoal -chop -clip \
-clip-mask -clip-path -clut -colorize -colors \
-colorspace -comment -compose -compress -contrast \
-contrast-stretch -convolve -cycle -debug -decipher \
-define -delay -density -depth -despeckle -display \
-dispose -distort -dither -draw -edge -emboss \
-encipher -encoding -endian -enhance -equalize \
-evaluate -extent -extract -family -fill -filter \
-flip -floodfill -flop -font -format -frame -fuzz \
-gamma -gaussian-blur -geometry -gravity \
-green-primary -help -identify -implode -intent \
-interlace -interpolate -label -lat -layers -level \
-limit -linear-stretch -liquid-rescale -list -log \
-loop -mask -mattecolor -median -modulate -monitor \
-monochrome -motion-blur -negate -noise -normalize \
-opaque -ordered-dither -orient -page -paint -path \
-ping -pointsize -polaroid -posterize -preview -print \
-profile -quality -quantize -quiet -radial-blur \
-raise -random-threshold -recolor -red-primary \
-regard-warnings -region -render -repage -resample \
-resize -roll -rotate -sample -sampling-factor -scale \
-scene -seed -segment -sepia-tone -set -shade -shadow \
-sharpen -shave -shear -sigmoidal-contrast -size \
-sketch -solarize -splice -spread -stretch -strip \
-stroke -strokewidth -style -swirl -taint -texture \
-threshold -thumbnail -tile -tile-offset -tint \
-transform -transparent -transparent-color -transpose \
-transverse -treedepth -trim -type -undercolor \
-unique-colors -units -unsharp -verbose -version \
-view -vignette -virtual-pixel -wave -weight \
-white-point -white-threshold' -- $cur ) )
2003-12-15 08:42:50 +00:00
elif [ [ " $cur " = = +* ] ] ; then
COMPREPLY = ( $( compgen -W ' +compress +contrast +debug +dither \
+endian +gamma +label +map +mask +matte +negate +page \
2008-05-06 20:20:14 +01:00
+raise' -- $cur ) )
2003-12-15 08:42:50 +00:00
else
_filedir
fi
}
complete -F _mogrify $filenames mogrify
_display( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-12-15 08:42:50 +00:00
_ImageMagick
if [ [ " $cur " = = -* ] ] ; then
2008-06-24 21:42:45 +02:00
COMPREPLY = ( $( compgen -W ' -alpha -antialias -authenticate \
-auto-orient -backdrop -background -border \
2009-02-01 23:05:33 +01:00
-bordercolor -borderwidth -channel -clip \
2008-06-24 21:42:45 +02:00
-clip-path -coalesce -colormap -colors -colorspace \
-comment -compress -contrast -crop -debug -decipher \
-define -delay -density -depth -despeckle -display \
-dispose -dither -edge -endian -enhance -extract \
-filter -flatten -flip -flop -font -foreground \
-format -frame -gamma -geometry -help -iconGeometry \
-iconic -identify -immutable -interlace -interpolate \
-label -limit -list -log -loop -map -mattecolor \
-monitor -monochrome -name -negate -page -profile \
-quality -quantize -quiet -raise -regard-warnings \
-remote -repage -resample -resize \
-respect-parenthesis -roll -rotate -sample \
-sampling-factor -scenes -seed -segment -set \
-shared-memory -sharpen -size -strip -texture -title \
-transparent-color -treedepth -trim -update \
-usePixmap -verbose -version -virtual-pixel -visual \
-window -window-group -write' -- $cur ) )
2003-12-15 08:42:50 +00:00
elif [ [ " $cur " = = +* ] ] ; then
COMPREPLY = ( $( compgen -W ' +compress +contrast +debug +dither \
+endian +gamma +label +map +matte +negate +page \
2008-05-06 20:20:14 +01:00
+raise +write' -- $cur ) )
2003-12-15 08:42:50 +00:00
else
_filedir
fi
}
complete -F _display $filenames display
_animate( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-12-15 08:42:50 +00:00
_ImageMagick
if [ [ " $cur " = = -* ] ] ; then
2008-06-24 21:42:45 +02:00
COMPREPLY = ( $( compgen -W ' -alpha -authenticate -backdrop \
-background -bordercolor -borderwidth -channel \
-coalesce -colormap -colors -colorspace -crop -debug \
-decipher -define -delay -density -depth -display \
-dispose -dither -extract -filter -flatten -font \
-foreground -format -gamma -geometry -help \
-iconGeometry -iconic -identify -immutable -interlace \
-interpolate -limit -list -log -loop -map -mattecolor \
-mattecolor -monitor -monochrome -name -page -pause \
-quantize -quiet -regard-warnings -remote -repage \
-resample -resize -respect-parenthesis -rotate \
-sampling-factor -scenes -seed -set -shared-memory \
-size -strip -title -transparent-color -treedepth \
-trim -verbose -version -virtual-pixel -visual \
-window' -- $cur ) )
2003-12-15 08:42:50 +00:00
elif [ [ " $cur " = = +* ] ] ; then
2008-05-06 20:20:14 +01:00
COMPREPLY = ( $( compgen -W '+debug +dither +gamma +map +matte' -- $cur ) )
2003-12-15 08:42:50 +00:00
else
_filedir
fi
}
complete -F _animate $filenames animate
_identify( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-12-15 08:42:50 +00:00
_ImageMagick
if [ [ " $cur " = = -* ] ] ; then
2008-06-24 21:42:45 +02:00
COMPREPLY = ( $( compgen -W ' -alpha -antialias -authenticate \
-channel -colorspace -crop -debug -define -density \
-depth -extract -format -fuzz -gamma -help -interlace \
-interpolate -limit -list -log -monitor -ping -quiet \
-regard-warnings -respect-parenthesis \
-sampling-factor -seed -set -size -strip -units \
-verbose -version -virtual-pixel' -- $cur ) )
2003-12-15 08:42:50 +00:00
elif [ [ " $cur " = = +* ] ] ; then
2008-06-24 21:42:45 +02:00
COMPREPLY = ( $( compgen -W '+debug' -- $cur ) )
2003-12-15 08:42:50 +00:00
else
_filedir
fi
}
complete -F _identify $filenames identify
_montage( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-12-15 08:42:50 +00:00
_ImageMagick
if [ [ " $cur " = = -* ] ] ; then
2008-06-24 21:42:45 +02:00
COMPREPLY = ( $( compgen -W ' -adjoin -affine -alpha \
-authenticate -background -blue-primary -blur -border \
-bordercolor -borderwidth -caption -channel -clone \
-coalesce -colors -colorspace -comment -compose \
-compress -crop -debug -define -density -depth \
2003-12-15 08:42:50 +00:00
-display -dispose -dither -draw -encoding -endian \
2008-06-24 21:42:45 +02:00
-extract -fill -filter -flatten -flip -flop -font \
-format -frame -gamma -geometry -gravity \
-green-primary -help -identify -interlace \
-interpolate -label -limit -list -log -mattecolor \
-mode -monitor -monochrome -origin -page -pointsize \
-polaroid -profile -quality -quantize -quiet \
-red-primary -regard-warnings -repage -resize \
-respect-parenthesis -rotate -sampling-factor -scenes \
-seed -set -shadow -size -strip -stroke -texture \
-thumbnail -tile -title -transform -transparent \
-transparent-color -treedepth -trim -type -units \
-verbose -version -virtual-pixel \
-white-point' -- $cur ) )
2003-12-15 08:42:50 +00:00
elif [ [ " $cur " = = +* ] ] ; then
COMPREPLY = ( $( compgen -W ' +adjoin +compress +debug +dither \
2008-05-06 20:20:14 +01:00
+endian +gamma +label +matte +page' -- $cur ) )
2003-12-15 08:42:50 +00:00
else
_filedir
fi
}
complete -F _montage $filenames montage
_composite( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2003-12-15 08:42:50 +00:00
_ImageMagick
if [ [ " $cur " = = -* ] ] ; then
2008-06-24 21:42:45 +02:00
COMPREPLY = ( $( compgen -W ' -affine -alpha -authenticate \
-blend -blue-primary -border -bordercolor -channel \
-colors -colorspace -comment -compose -compress \
-debug -decipher -define -density -depth -displace \
-display -dispose -dissolve -dither -encipher \
-encoding -endian -extract -filter -font -format \
-geometry -gravity -green-primary -help -identify \
-interlace -interpolate -label -limit -list -log \
-monitor -monochrome -negate -page -profile -quality \
-quantize -quiet -red-primary -regard-warnings \
-repage -resize -respect-parenthesis -rotate \
-sampling-factor -scene -seed -sharpen -shave -size \
-stegano -stereo -strip -swap -thumbnail -tile \
-transform -transparent-color -treedepth -type -units \
-unsharp -verbose -version -virtual-pixel -watermark \
-white-point -write' -- $cur ) )
2003-12-15 08:42:50 +00:00
elif [ [ " $cur " = = +* ] ] ; then
COMPREPLY = ( $( compgen -W ' +compress +debug +dither +endian +label \
2008-05-06 20:20:14 +01:00
+matte +negate +page +write' -- $cur ) )
2003-12-15 08:42:50 +00:00
else
_filedir
fi
}
complete -F _composite $filenames composite
2008-06-24 21:42:45 +02:00
_compare( )
{
local cur
COMPREPLY = ( )
cur = ` _get_cword`
_ImageMagick
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -alpha -authenticate -channel \
-colorspace -compress -debug -decipher -define \
-density -depth -encipher -extract -format -fuzz \
-help -highlight-color -identify -interlace -limit \
-list -log -metric -monitor -passphrase -profile \
-quality -quantize -quiet -regard-warnings \
-respect-parenthesis -sampling-factor -seed -set \
-size -transparent-color -type -verbose -version \
-virtual-pixel' -- $cur ) )
elif [ [ " $cur " = = +* ] ] ; then
COMPREPLY = ( $( compgen -W '+debug' -- $cur ) )
else
_filedir
fi
}
complete -F _compare $filenames compare
_conjure( )
{
local cur
COMPREPLY = ( )
cur = ` _get_cword`
_ImageMagick
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -debug -help -list -log -monitor \
-quiet -regard-warnings -seed -verbose \
-version' -- $cur ) )
elif [ [ " $cur " = = +* ] ] ; then
COMPREPLY = ( $( compgen -W '+debug' -- $cur ) )
else
_filedir
fi
}
complete -F _conjure $filenames conjure
_import( )
{
local cur
COMPREPLY = ( )
cur = ` _get_cword`
_ImageMagick
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -adjoin -annotate -border -channel \
-colors -colorspace -comment -compress -crop -debug \
-define -delay -density -depth -descend -display \
-dispose -dither -encipher -encoding -endian -filter \
-format -frame -geometry -gravity -help -identify \
-interlace -interpolate -label -limit -list -log \
-monitor -monochrome -negate -page -pause -pointsize \
-quality -quantize -quiet -regard-warnings -repage \
-resize -respect-parenthesis -rotate -sampling-factor \
-scene -screen -seed -set -silent -snaps -strip \
-thumbnail -transparent -transparent-color -treedepth \
-trim -type -verbose -version -virtual-pixel \
-window' -- $cur ) )
elif [ [ " $cur " = = +* ] ] ; then
COMPREPLY = ( $( compgen -W '+debug' -- $cur ) )
else
_filedir
fi
}
complete -F _import $filenames import
_stream( )
{
local cur
COMPREPLY = ( )
cur = ` _get_cword`
_ImageMagick
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -authenticate -channel -colorspace \
-compress -debug -define -density -depth -extract \
-help -identify -interlace -interpolate -limit -list \
-log -map -monitor -quantize -quiet -regard-warnings \
-respect-parenthesis -sampling-factor -seed -set \
-size -storage-type -transparent-color -verbose \
-version -virtual-pixel' -- $cur ) )
elif [ [ " $cur " = = +* ] ] ; then
COMPREPLY = ( $( compgen -W '+debug' -- $cur ) )
else
_filedir
fi
}
complete -F _stream $filenames stream
2003-12-15 08:42:50 +00:00
}
2004-02-09 21:02:48 +00:00
# dd(1) completion
#
have dd &&
_dd( )
{
2005-01-13 01:22:45 +00:00
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-01-13 01:22:45 +00:00
case " $cur " in
if = *| of = *)
cur = ${ cur #*= }
_filedir
return 0
; ;
conv = *)
cur = ${ cur #*= }
COMPREPLY = ( $( compgen -W ' ascii ebcdic ibm block unblock \
lcase notrunc ucase swab noerror sync' \
-- $cur ) )
return 0
; ;
esac
_expand || return 0
COMPREPLY = ( $( compgen -W '--help --version' -- $cur ) \
2005-01-16 17:27:29 +00:00
$( compgen -W 'bs cbs conv count ibs if obs of seek skip' \
-S '=' -- $cur ) )
2005-07-07 23:36:51 +00:00
} &&
complete -F _dd $nospace $filenames dd
2004-02-09 21:02:48 +00:00
2004-03-30 21:01:33 +00:00
# CUPS cancel(1) completion
#
have cancel &&
_cancel( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-03-30 21:01:33 +00:00
COMPREPLY = ( $( lpstat | cut -d' ' -f1 | grep " ^ $cur " ) )
2005-07-07 23:36:51 +00:00
} &&
complete -F _cancel $filenames cancel
2004-03-30 21:01:33 +00:00
2004-05-24 07:42:32 +00:00
# aspell(1) completion
#
have aspell && {
_aspell_dictionary( )
{
local datadir
datadir = /usr/lib/aspell
COMPREPLY = ( $( command ls $datadir /*.@( multi| alias ) ) )
COMPREPLY = ( ${ COMPREPLY [@]%.@(multi|alias) } )
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]#$datadir/}' -- $cur ) )
}
_aspell( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-05-24 07:42:32 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
# --name value style option
case " $prev " in
@( -c| -p| check) )
_filedir
return 0
; ;
@( dump| create| merge) )
COMPREPLY = ( $( compgen -W 'master personal repl' -- $cur ) )
return 0
; ;
-d)
_aspell_dictionary
return 0
; ;
esac
# --name=value style option
if [ [ " $cur " = = *= * ] ] ; then
prev = ${ cur /=*/ }
cur = ${ cur /*=/ }
case " $prev " in
--@( conf| personal| repl| per-conf) )
_filedir
return 0
; ;
--@( conf-dir| data-dir| dict-dir| home-dir| local-data-dir| prefix) )
_filedir -d
return 0
; ;
--master)
_aspell_dictionary
return 0
; ;
--mode)
COMPREPLY = ( $( compgen -W 'none url email sgml tex' -- $cur ) )
return 0
2008-05-06 20:20:14 +01:00
; ;
2004-05-24 07:42:32 +00:00
--sug-mode)
COMPREPLY = ( $( compgen -W 'ultra fast normal bad-speller' -- $cur ) )
return 0
; ;
--keymapping)
COMPREPLY = ( $( compgen -W 'aspell ispell' -- $cur ) )
return 0
; ;
esac
fi
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --conf= --conf-dir= --data-dir= --dict-dir= \
--encoding= --add-filter= --rem-filter= --mode= -e \
-H -t --add-extra-dicts= --rem-extra-dicts= \
--home-dir= -W --ignore= --ignore-accents \
--dont-ignore-accents --ignore-case --dont-ignore-case \
--ignore-repl --dont-ignore-repl --jargon= --keyboard= \
--lang= --language-tag= --local-data-dir= -d --master= \
--module= --add-module-search-order= \
--rem-module-search-order= --per-conf= -p --personal= \
--prefix= --repl= -C -B --run-together --dont-run-together \
--run-together-limit= --run-together-min= --save-repl \
--dont-save-repl --set-prefix --dont-set-prefix --size= \
--spelling= --strip-accents --dont-strip-accents \
--sug-mode= --add-word-list-path= --rem-word-list-path= \
-b -x --backup -b| -x --dont-backup --reverse --dont-reverse \
--time --dont-time --keymapping= --add-email-quote= \
--rem-email-quote= --email-margin= --add-tex-command= \
--rem-tex-command= --tex-check-comments \
--dont-tex-check-comments --add-tex-extension= \
--rem-tex-extension= --add-sgml-check= --rem-sgml-check= \
--add-sgml-extension= --rem-sgml-extension= ' -- $cur ) )
else
COMPREPLY = ( $( compgen -W ' -? help -c check -a pipe -l list \
config config soundslike filter -v version dump \
create merge' -- $cur ) )
fi
}
2008-06-23 11:55:45 +02:00
complete -F _aspell $filenames aspell
2004-05-24 07:42:32 +00:00
}
2004-05-24 07:44:44 +00:00
# xmms(1) completion
#
have xmms &&
_xmms( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-05-24 07:44:44 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -h --help -r --rew -p --play \
-u --pause -s --stop -t --play-pause -f --fwd -e \
--enqueue -m --show-main-window -i --sm-client-id \
-v --version' -- $cur ) )
else
_filedir '@(mp[23]|MP[23]|ogg|OGG|wav|WAV|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)'
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _xmms $filenames xmms
2004-05-24 07:44:44 +00:00
2004-05-26 05:15:28 +00:00
# info(1) completion
#
2005-07-07 21:41:15 +00:00
have info &&
2004-05-26 05:15:28 +00:00
_info( )
{
2009-01-30 10:20:56 +01:00
local cur infopath
2004-05-26 05:15:28 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-05-26 05:15:28 +00:00
_expand || return 0
# default completion if parameter contains /
if [ [ " $cur " = = */* ] ] ; then
_filedir
return 0
fi
infopath = '/usr/share/info'
if [ " ${ INFOPATH : -1 : 1 } " = = ':' ] ; then
infopath = ${ INFOPATH } ${ infopath }
elif [ ${ INFOPATH : +set } ] ; then
infopath = $INFOPATH
fi
infopath = $infopath :
if [ -n " $cur " ] ; then
infopath = " ${ infopath // : // $cur * } "
else
infopath = " ${ infopath // : // } "
fi
# redirect stderr for when path doesn't exist
COMPREPLY = ( $( eval command ls " $infopath " 2>/dev/null ) )
# weed out directory path names and paths to info pages
COMPREPLY = ( ${ COMPREPLY [@]##*/?( : ) } )
# weed out info dir file
for ( ( i = 0 ; i < ${# COMPREPLY [@] } ; ++i ) ) ; do
if [ " ${ COMPREPLY [ $i ] } " = = 'dir' ] ; then
unset COMPREPLY[ $i ] ;
fi ;
2008-05-06 20:20:14 +01:00
done
2004-05-26 05:15:28 +00:00
# strip suffix from info pages
2009-01-13 20:45:07 +02:00
COMPREPLY = ( ${ COMPREPLY [@]%.@(gz|bz2|lzma) } )
2004-05-26 05:15:28 +00:00
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]%.*}' -- " ${ cur // \\ \\ / } " ) )
return 0
2005-07-07 23:36:51 +00:00
} &&
complete -F _info $filenames info
2004-05-26 05:15:28 +00:00
2004-10-14 06:52:14 +00:00
# dhclient(1) completion
#
2004-10-14 06:54:55 +00:00
have dhclient && _dhclient( )
2004-10-14 06:52:14 +00:00
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( cf| lf| pf| sf) )
_filedir
return 0
; ;
-s)
_known_hosts
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -p -d -q -1 -r -lf -pf \
-cf -sf -s -g -n -nw -w' -- $cur ) )
else
2005-07-20 22:54:36 +00:00
_available_interfaces
2004-10-14 06:52:14 +00:00
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _dhclient dhclient
2004-10-14 06:52:14 +00:00
# lvm(8) completion
#
have lvm && {
_volumegroups( )
{
2005-07-11 21:36:17 +00:00
COMPREPLY = ( $( compgen -W " $( vgscan 2>/dev/null | \
sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' ) " -- $cur ) )
2004-10-14 06:52:14 +00:00
}
_physicalvolumes( )
{
2005-07-11 21:36:17 +00:00
COMPREPLY = ( $( compgen -W " $( pvscan 2>/dev/null | \
sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' ) " -- $cur ) )
2004-10-14 06:52:14 +00:00
}
_logicalvolumes( )
{
2005-07-11 21:36:17 +00:00
COMPREPLY = ( $( compgen -W " $( lvscan 2>/dev/null | \
sed -n -e " s|^.*'\(.*\)'.* $|\1|p " ) " -- $cur ) )
2004-10-14 06:52:14 +00:00
}
_units( )
{
COMPREPLY = ( $( compgen -W 'h s b k m g t H K M G T' -- $cur ) )
}
_sizes( )
{
COMPREPLY = ( $( compgen -W 'k K m M g G t T' -- $cur ) )
}
_args( )
{
args = 0
if [ [ " ${ COMP_WORDS [0] } " = = lvm ] ] ; then
offset = 2
else
offset = 1
fi
for ( ( i = $offset ; i < COMP_CWORD; i++ ) ) ; do
if [ [ " ${ COMP_WORDS [i] } " != -* ] ] ; then
args = $(( $args + 1 ))
fi
done
}
_lvmdiskscan( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -d --debug -h -? --help -l \
--lvmpartition -v --verbose --version' -- $cur ) )
fi
}
complete -F _lvmdiskscan lvmdiskscan
_pvscan( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -d --debug -e \
--exported -n --novolumegroup -h -? \
--help --ignorelockingfailure -P \
--partial -s --short -u --uuid -v \
--verbose --version' -- $cur ) )
fi
}
complete -F _pvscan pvscan
_pvs( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( o| O| -options| -sort) )
COMPREPLY = ( $( compgen -W ' pv_fmt pv_uuid \
pv_size pv_free pv_used pv_name \
pv_attr pv_pe_count \
pv_pe_alloc_count' -- $cur ) )
return 0
; ;
--units)
_units
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --aligned -a --all -d --debug \
-h -? --help --ignorelockingfailure --noheadings \
--nosuffix -o --options -O --sort \
--separator --unbuffered --units \
-v --verbose --version' -- $cur ) )
else
_physicalvolumes
fi
}
complete -F _pvs pvs
_pvdisplay( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
--units)
_units
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -c --colon -C --columns --units \
-v --verbose -d --debug -h --help --version' -- $cur ) )
else
_physicalvolumes
fi
}
complete -F _pvdisplay pvdisplay
_pvchange( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| x| -autobackup| --allocatable) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -a --all -A --autobackup \
-d --debug -h --help -t --test -u --uuid -x \
--allocatable -v --verbose --addtag --deltag \
--version' -- $cur ) )
else
_physicalvolumes
fi
}
complete -F _pvchange pvchange
_pvcreate( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
--restorefile)
_filedir
return 0
; ;
-@( M| -metadatatype) )
COMPREPLY = ( $( compgen -W '1 2' -- $cur ) )
return 0
; ;
--metadatacopies)
COMPREPLY = ( $( compgen -W '0 1 2' -- $cur ) )
return 0
; ;
--@( metadatasize| setphysicalvolumesize) )
_sizes
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --restorefile -d --debug -f \
--force -h -? --help --labelsector -M --metadatatype \
--metadatacopies --metadatasize \
--setphysicalvolumesize -t --test -u --uuid uuid -v \
--verbose -y --yes --version' -- $cur ) )
else
_physicalvolumes
fi
}
complete -F _pvcreate pvcreate
_pvmove( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
-@( n| -name) )
_logicalvolumes
return 0
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --abort -A --autobackup \
-b --background -d --debug -f --force -h -? \
--help -i --interval -t --test -v --verbose \
--version -n --name' -- $cur ) )
else
_physicalvolumes
fi
}
complete -F _pvmove pvmove
_pvremove( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -d --debug -f --force -h -? \
--help -y --yes -t --test -v --verbose \
--version' -- $cur ) )
else
_physicalvolumes
fi
}
complete -F _pvremove pvremove
_vgscan( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -d --debug -h --help \
--ignorelockingfailure --mknodes -P \
--partial -v --verbose --version' -- $cur ) )
fi
}
complete -F _vgscan vgscan
_vgs( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( o| O| -options| -sort) )
COMPREPLY = ( $( compgen -W ' vg_fmt vg_uuid vg_name \
vg_attr vg_size vg_free vg_sysid \
vg_extent_size vg_extent_count vg_free_count \
max_lv max_pv pv_count lv_count snap_count \
vg_seqno' -- $cur ) )
return 0
; ;
--units)
_units
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --aligned -d --debug \
-h --help --ignorelockingfailure --noheadings \
--nosuffix -o --options -O --sort -P --partial \
--separator --unbuffered --units \
-v --verbose --version' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgs vgs
_vgdisplay( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
--units)
_units
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -c --colon -C --columns --units \
-P --partial -A --activevolumegroups -v --verbose \
-d --debug -h --help --version' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgdisplay vgdisplay
_vgchange( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( a| A| x| -available| -autobackup| -resizeable) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup --alloc -P \
--partial -d --debug -h --help --ignorelockingfailure \
-t --test -u --uuid -v --verbose --version -a \
--available -x --resizeable -l --logicalvolume \
--addtag --deltag' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgchange vgchange
_vgcreate( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
-@( M| -metadatatype) )
COMPREPLY = ( $( compgen -W '1 2' -- $cur ) )
return 0
; ;
-@( s| -physicalextentsize) )
_sizes
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup --addtag \
--alloc -d --debug -h --help -l --maxlogicalvolumes \
-M --metadatatype -p --maxphysicalvolumes -s \
--physicalextentsize -t --test -v --verbose \
--version' -- $cur ) )
else
_args
if [ $args -eq 0 ] ; then
_volumegroups
else
_physicalvolumes
fi
fi
}
complete -F _vgcreate vgcreate
_vgremove( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -d --debug -h --help -t --test \
-v --verbose --version' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgremove vgremove
_vgrename( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup -d --debug -h \
-? --help -t --test -v --verbose --version' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgrename vgrename
_vgreduce( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -a --all -A --autobackup -d \
--debug -h --help --removemissing -t --test -v \
--verbose --version' -- $cur ) )
else
_args
if [ $args -eq 0 ] ; then
_volumegroups
else
_physicalvolumes
fi
fi
}
complete -F _vgreduce vgreduce
_vgextend( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
-@( L| -size) )
_sizes
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup -d --debug -h \
-? --help -t --test -v --verbose --version' -- $cur ) )
else
_args
if [ $args -eq 0 ] ; then
_volumegroups
else
_physicalvolumes
fi
fi
}
complete -F _vgextend vgextend
_vgport( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -a --all -d --debug -h \
-? --help -v --verbose --version' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgport vgimport vgexport
_vgck( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -d --debug -h \
-? --help -v --verbose --version' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgck vgck
_vgconvert( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( M| -metadatatype) )
COMPREPLY = ( $( compgen -W '1 2' -- $cur ) )
return 0
; ;
--metadatacopies)
COMPREPLY = ( $( compgen -W '0 1 2' -- $cur ) )
return 0
; ;
--metadatasize)
_sizes
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
2008-05-06 20:20:14 +01:00
COMPREPLY = ( $( compgen -W ' -d --debug -h --help --labelsector \
2004-10-14 06:52:14 +00:00
-M --metadatatype --metadatacopies --metadatasize \
-t --test -v --verbose --version' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgconvert vgconvert
_vgcfgbackup( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( f| -file) )
_filedir
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -d --debug -f --file -h --help \
--ignorelockingfailure -P --partial -v --verbose \
--version' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgcfgbackup vgcfgbackup
_vgcfgrestore( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( f| -file) )
_filedir
return 0
; ;
-@( M| -metadatatype) )
COMPREPLY = ( $( compgen -W '1 2' -- $cur ) )
return 0
; ;
-@( n| -name) )
_volumegroups
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -d --debug -f --file -l --list \
-h --help -M --Metadatatype -n --name -t --test \
-v --verbose --version' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgcfgrestore vgcfgrestore
_vgmerge( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup -d --debug \
-h --help -l --list -t --test -v --verbose \
--version' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgmerge vgmerge
_vgsplit( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
-@( M| -metadatatype) )
COMPREPLY = ( $( compgen -W '1 2' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup -d --debug \
-h --help -l --list -M --metadatatype -t --test \
-v --verbose --version' -- $cur ) )
else
_args
if [ $args -eq 0 -o $args -eq 1 ] ; then
_volumegroups
else
_physicalvolumes
fi
fi
}
complete -F _vgsplit vgsplit
_vgmknodes( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -d --debug -h --help -v --verbose \
--version' -- $cur ) )
else
_volumegroups
fi
}
complete -F _vgmknodes vgmknodes
_lvscan( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -b --blockdevice -d --debug \
-h -? --help --ignorelockingfailure -P \
--partial -v --verbose --version' -- $cur ) )
fi
}
complete -F _lvscan lvscan
_lvs( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( o| O| -options| -sort) )
COMPREPLY = ( $( compgen -W ' lv_uuid lv_name \
lv_attr lv_minor lv_size seg_count \
origin snap_percent segtype stripes \
stripesize chunksize seg_start \
seg_size' -- $cur ) )
return 0
; ;
--units)
_units
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --aligned -d --debug \
-h --help --ignorelockingfailure --noheadings \
--nosuffix -o --options -O --sort -P --partial \
--segments --separator --unbuffered --units \
-v --verbose --version' -- $cur ) )
else
_logicalvolumes
fi
}
complete -F _lvs lvs
_lvdisplay( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
--units)
_units
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -c --colon -C --columns --units \
-P --partial -m --maps -v --verbose -d --debug -h \
--help --version' -- $cur ) )
else
_logicalvolumes
fi
}
complete -F _lvdisplay lvdisplay
_lvchange( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( a| A| C| M| -available| -autobackup| -continguous| -persistent) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
-@( p| -permission) )
COMPREPLY = ( $( compgen -W 'r rw' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup -a --available \
--addtag --alloc -C --contiguous -d --debug --deltag \
-f --force -h --help --ignorelockingfailure -M \
--persistent --major major --minor minor -P --partial \
-p --permission -r --readahead --refresh -t --test \
-v --verbose --version' -- $cur ) )
else
_logicalvolumes
fi
}
complete -F _lvchange lvchange
_lvcreate( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| C| M| Z| -autobackup| -continguous| -persistent| -zero) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
-@( L| -size) )
_sizes
return 0
; ;
-@( p| -permission) )
COMPREPLY = ( $( compgen -W 'r rw' -- $cur ) )
return 0
; ;
-@( n| -name) )
_logicalvolumes
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup --addtag --alloc \
-C --contiguous -d --debug -h -? --help -i --stripes \
-I --stripesize -l --extents -L --size -M --persistent \
--major --minor -n --name -p --permission -r \
--readahead -t --test --type -v --verbose -Z --zero \
--version' -- $cur ) )
else
_args
if [ $args -eq 0 ] ; then
_volumegroups
else
_physicalvolumes
fi
fi
}
complete -F _lvcreate lvcreate
_lvremove( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup -d --debug -f \
--force -h -? --help -t --test -v --verbose \
--version' -- $cur ) )
else
_logicalvolumes
fi
}
complete -F _lvremove lvremove
_lvrename( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup -d --debug -h \
-? --help -t --test -v --verbose --version' -- $cur ) )
else
_logicalvolumes
fi
}
complete -F _lvrename lvrename
_lvreduce( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
-@( L| -size) )
_sizes
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup -d \
--debug -f --force -h --help -l --extents \
-L --size -n --nofsck -r --resizefs -t --test \
-v --verbose --version' -- $cur ) )
else
_logicalvolumes
fi
}
complete -F _lvreduce lvreduce
_lvresize( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
-@( L| -size) )
_sizes
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup --alloc -d \
--debug -h --help -i --stripes -I --stripesize \
-l --extents -L --size -n --nofsck -r --resizefs \
-t --test --type -v --verbose --version' -- $cur ) )
else
_args
if [ $args -eq 0 ] ; then
_logicalvolumes
else
_physicalvolumes
fi
fi
}
complete -F _lvresize lvresize
_lvextend( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2004-10-14 06:52:14 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case " $prev " in
-@( A| -autobackup) )
COMPREPLY = ( $( compgen -W 'y n' -- $cur ) )
return 0
; ;
-@( L| -size) )
_sizes
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -A --autobackup --alloc -d \
--debug -h --help -i --stripes -I --stripesize \
-l --extents -L --size -n --nofsck -r --resizefs \
-t --test --type -v --verbose --version' -- $cur ) )
else
_args
if [ $args -eq 0 ] ; then
_logicalvolumes
else
_physicalvolumes
fi
fi
}
complete -F _lvextend lvextend
2005-07-07 21:43:25 +00:00
_lvm( )
{
local prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-07-07 21:43:25 +00:00
if [ $COMP_CWORD -eq 1 ] ; then
COMPREPLY = ( $( compgen -W ' dumpconfig help lvchange \
lvcreate lvdisplay lvextend lvmchange \
lvmdiskscan lvmsadc lvmsar lvreduce \
lvremove lvrename lvresize lvs lvscan \
pvchange pvcreate pvdata pvdisplay pvmove \
pvremove pvresize pvs pvscan vgcfgbackup \
vgcfgrestore vgchange vgck vgconvert \
vgcreate vgdisplay vgexport vgextend \
vgimport vgmerge vgmknodes vgreduce \
vgremove vgrename vgs vgscan vgsplit \
version' -- $cur ) )
else
case ${ COMP_WORDS [1] } in
pvchange)
_pvchange
; ;
pvcreate)
_pvcreate
; ;
pvdisplay)
_pvdisplay
; ;
pvmove)
_pvmove
; ;
pvremove)
_pvremove
; ;
pvresize)
_pvresize
; ;
pvs)
_pvs
; ;
pvscan)
_pvscan
; ;
vgcfgbackup)
_vgcfgbackup
; ;
vgcfgrestore)
_vgcfgrestore
; ;
vgchange)
_vgchange
; ;
vgck)
_vgck
; ;
vgconvert)
_vgconvert
; ;
vgcreate)
_vgcreate
; ;
vgdisplay)
_vgdisplay
; ;
vgexport)
_vgexport
; ;
vgextend)
_vgextend
; ;
vgimport)
_vgimport
; ;
vgmerge)
_vgmerge
; ;
vgmknodes)
_vgmknodes
; ;
vgreduce)
_vgreduce
; ;
vgremove)
_vgremove
; ;
vgrename)
_vgrename
; ;
vgs)
_vgs
; ;
vgscan)
_vgscan
; ;
vgsplit)
_vgsplit
; ;
lvchange)
_lvchange
; ;
lvcreate)
_lvcreate
; ;
lvdisplay)
_lvdisplay
; ;
lvextend)
_lvextend
; ;
lvreduce)
_lvreduce
; ;
lvremove)
_lvremove
; ;
lvrename)
_lvrename
; ;
lvresize)
_lvresize
; ;
lvs)
_lvs
; ;
lvscan)
_lvscan
; ;
esac
fi
}
complete -F _lvm lvm
2004-10-14 06:52:14 +00:00
}
2005-01-03 01:35:57 +00:00
# mkinitrd(8) completion
#
have mkinitrd &&
_mkinitrd( )
{
local cur args
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-01-03 01:35:57 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
# --name value style option
case " $prev " in
--preload)
_modules
return 0
; ;
esac
# --name=value style option
if [ [ " $cur " = = *= * ] ] ; then
prev = ${ cur /=*/ }
cur = ${ cur /*=/ }
case " $prev " in
--@( with| builtin ) )
_modules
return 0
; ;
--@( fstab| dsdt) )
_filedir
return 0
; ;
--tmpdir)
_filedir -d
return 0
; ;
esac
fi
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' --version -v -f --preload \
--with= --omit-scsi-modules --omit-raid-modules \
--images-version --fstab= --nocompress --builtin= \
--nopivot --noudev --allow-missing --tmpdir= \
--initrdfs= --dsdt= --lvm-version= --froce-usb' \
-- $cur ) )
else
2005-07-11 22:23:30 +00:00
_count_args
2005-01-03 01:35:57 +00:00
case $args in
1)
_filedir
; ;
2)
COMPREPLY = ( $( command ls /lib/modules | grep " ^ $cur " ) )
; ;
esac
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _mkinitrd mkinitrd
2005-01-03 01:35:57 +00:00
2005-01-03 04:31:38 +00:00
# pkgconfig(1) completion
#
have pkg-config &&
_pkg_config( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-01-03 04:31:38 +00:00
if [ [ " $cur " = = -* ] ] ; then
# return list of available options
COMPREPLY = ( $( compgen -W ' -version --modversion \
--atleast-pkgconfig-version= --libs --libs-only-l \
--libs-only-other --libs-only-L --cflags \
2008-05-01 22:22:11 +02:00
--cflags-only-I --cflags-only-other --variable= \
2006-02-28 11:53:20 +00:00
--define-variable= --exists --uninstalled \
2005-01-03 04:31:38 +00:00
--atleast-version= --exact-version= --max-version= \
--list-all --debug --print-errors --silence-errors \
--errors-to-stdout -? --help --usage' -- $cur ) )
else
COMPREPLY = ( $( pkg-config --list-all 2>/dev/null | \
awk '{print $1}' | grep " ^ $cur " ) )
fi
2005-07-07 23:36:51 +00:00
} &&
complete -F _pkg_config pkg-config
2005-01-03 04:31:38 +00:00
2005-07-11 22:18:01 +00:00
# cpio(1) completion
#
have cpio && {
_cpio_format( )
{
COMPREPLY = ( $( compgen -W 'bin odc newc crc tar ustar hpbin hpodc' -- $cur ) )
}
_cpio( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-07-11 22:18:01 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
# --name value style option
case $prev in
-H)
_cpio_format
return 0
; ;
-@( E| F| I) )
_filedir
return 0
; ;
-R)
_usergroup
return 0
; ;
esac
# --name=value style option
if [ [ " $cur " = = *= * ] ] ; then
prev = ${ cur /=*/ }
cur = ${ cur /*=/ }
case $prev in
--format)
_cpio_format
return 0
; ;
--@( file| pattern-file) )
_filedir
return 0
; ;
--owner)
_usergroup
return 0
; ;
--rsh-command)
COMPREPLY = ( $( compgen -c -- $cur ) )
return 0
; ;
esac
fi
if [ $COMP_CWORD -eq 1 ] ; then
2008-05-06 20:20:14 +01:00
COMPREPLY = ( $( compgen -W '-o --create -i --extract -p --pass-through' -- $cur ) )
2005-07-11 22:18:01 +00:00
else
case ${ COMP_WORDS [1] } in
-@( o| -create) )
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -0 -a -c -v -A -B\
-L -V -C -H -M -O -F --file= --format= \
--message= --null --reset-access-time\
--verbose --dot --append --block-size= \
--dereference --io-size= --quiet\
--force-local --rsh-command= --help\
--version' -- $cur ) )
fi
; ;
-@( i| -extract) )
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -b -c -d -f -m -n -r\
-t -s -u -v -B -S -V -C -E -H -M -R -I\
-F --file= --make-directories\
--nonmatching\
--preserve-modification-time\
--numeric-uid-gid --rename -t --list\
--swap-bytes --swap --dot\
--unconditional --verbose --block-size= \
--swap-halfwords --io-size= \
--pattern-file= --format= --owner= \
--no-preserve-owner --message= \
--force-local --no-absolute-filenames\
--sparse --only-verify-crc --quiet\
--rsh-command= --help\
--version' -- $cur ) )
fi
; ;
-@( p| -pass-through) )
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -0 -a -d -l -m -u -v\
-L -V -R --null --reset-access-time\
--make-directories --link --quiet\
--preserve-modification-time\
--unconditional --verbose --dot\
--dereference --owner= \
--no-preserve-owner --sparse --help\
--version' -- $cur ) )
else
_filedir -d
fi
; ;
esac
fi
}
complete -F _cpio cpio
}
2005-07-11 22:19:05 +00:00
# id(1) completion
#
2005-07-12 17:13:02 +00:00
have id &&
2005-07-11 22:19:05 +00:00
_id( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-07-11 22:19:05 +00:00
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -a -g --group -G --groups -n --name\
-r --real -u --user --help --version' -- $cur ) )
else
COMPREPLY = ( $( compgen -u $cur ) )
fi
} &&
complete -F _id id
2005-07-11 22:20:16 +00:00
# getent(1) completion
#
have getent &&
_getent( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-07-11 22:20:16 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
passwd)
COMPREPLY = ( $( compgen -u $cur ) )
return 0
; ;
group)
COMPREPLY = ( $( compgen -g $cur ) )
return 0
; ;
services)
COMPREPLY = ( $( compgen -s $cur ) )
return 0
; ;
hosts)
COMPREPLY = ( $( compgen -A hostname $cur ) )
return 0
; ;
2009-01-12 01:08:01 +02:00
protocols| networks| ahosts| ahostsv4| ahostsv6| rpc)
COMPREPLY = ( $( getent $prev | \
sed -ne 's|^\(' $cur '[^[:space:]]*\).*|\1|p' ) )
2005-07-11 22:20:16 +00:00
return 0
; ;
2009-01-12 01:08:01 +02:00
aliases| shadow)
COMPREPLY = ( $( getent $prev | \
sed -ne 's|^\(' $cur '[^:]*\).*|\1|p' ) )
2005-07-11 22:20:16 +00:00
return 0
; ;
esac
if [ $COMP_CWORD -eq 1 ] ; then
2009-01-12 01:08:01 +02:00
COMPREPLY = ( $( compgen -W ' passwd group hosts services \
protocols networks ahosts ahostsv4 \
ahostsv6 aliases ethers netgroup \
rpc shadow' -- $cur ) )
2005-07-11 22:20:16 +00:00
fi
} &&
complete -F _getent getent
2005-07-11 22:21:13 +00:00
# ntpdate(1) completion
#
have ntpdate &&
_ntpdate( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2005-07-11 22:21:13 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
-k)
_filedir
return 0
; ;
-U)
COMPREPLY = ( $( compgen -u $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -4 -6 -b -B -d -Q -q -s -u -v -a\
-e -k -p -o -r -t' -- $cur ) )
else
_known_hosts
fi
} &&
complete -F _ntpdate ntpdate
2006-02-24 23:24:16 +00:00
# smartctl(8) completion
#
have smartctl && {
_smartctl_quietmode( )
{
COMPREPLY = ( $( compgen -W 'errorsonly silent' -- $cur ) )
}
_smartctl_device( )
{
COMPREPLY = ( $( compgen -W 'ata scsi 3ware' -- $cur ) )
}
_smartctl_tolerance( )
{
COMPREPLY = ( $( compgen -W 'warn exit ignore' -- $cur ) )
}
_smartctl_badsum( )
{
COMPREPLY = ( $( compgen -W 'normal conservative permissive verypermissive' -- $cur ) )
}
_smartctl_report( )
{
COMPREPLY = ( $( compgen -W 'ioctl ataioctl scsiioctl' -- $cur ) )
}
_smartctl_feature( )
{
COMPREPLY = ( $( compgen -W 'on off' -- $cur ) )
}
_smartctl_log( )
{
COMPREPLY = ( $( compgen -W 'error selftest selective directory' -- $cur ) )
}
_smartctl_vendorattribute( )
{
COMPREPLY = ( $( compgen -W ' help 9,minutes 9,seconds 9,halfminutes \
9,temp 192,emergencyretractcyclect 193,loadunload \
194,10xCelsius 194,unknown 198,offlinescanuncsectorct \
200,writeerrorcount 201,detectedtacount 220,temp' -- $cur ) )
}
_smartctl_firmwarebug( )
{
COMPREPLY = ( $( compgen -W 'none samsung samsung2' -- $cur ) )
}
_smartctl_presets( )
{
COMPREPLY = ( $( compgen -W 'use ignore show showall' -- $cur ) )
}
_smartctl_test( )
{
COMPREPLY = ( $( compgen -W 'offline short long conveyance select afterselect,on afterselect,off pending' -- $cur ) )
}
_smartctl( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2006-02-24 23:24:16 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
# --name value style option
case " $prev " in
-q)
_smartctl_quietmode
; ;
-d)
_smartctl_device
return 0
; ;
-t)
_smartctl_tolerance
return 0
; ;
-b)
_smartctl_badsum
return 0
; ;
-r)
_smartctl_report
return 0
; ;
-s)
_smartctl_feature
return 0
; ;
-o)
_smartctl_feature
return 0
; ;
-S)
_smartctl_feature
return 0
; ;
-l)
_smartctl_log
return 0
; ;
-v)
_smartctl_vendorattribute
return 0
; ;
-F)
_smartctl_firmwarebug
return 0
; ;
-P)
_smartctl_presets
return 0
; ;
-t)
_smartctl_test
return 0
; ;
esac
# --name=value style option
if [ [ " $cur " = = *= * ] ] ; then
prev = ${ cur /=*/ }
cur = ${ cur /*=/ }
case " $prev " in
--quietmode)
_smartctl_quietmode
return 0
; ;
--device)
_smartctl_device
return 0
; ;
--tolerance)
_smartctl_tolerance
return 0
; ;
--badsum)
_smartctl_badsum
return 0
; ;
--report)
_smartctl_report
return 0
; ;
--smart)
_smartctl_feature
return 0
; ;
--offlineauto)
_smartctl_feature
return 0
; ;
--saveauto)
_smartctl_feature
return 0
; ;
--log)
_smartctl_log
return 0
; ;
--vendorattribute)
_smartctl_vendorattribute
return 0
; ;
--firmwarebug)
_smartctl_firmwarebug
return 0
; ;
--presets)
_smartctl_presets
return 0
; ;
--test)
_smartctl_test
return 0
; ;
esac
fi
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -h --help --usage -V --version \
--copyright --license-i --info -a --all -q \
--quietmode= -d --device= -T --tolerance= -b --badsum= \
-r --report= -s --smart= -o --offlineauto= -S \
--saveauto= -H --health -c --capabilities -A \
--attributes -l --log= -v --vendorattribute= -F \
--firmwarebug= -P --presets= -t --test= -C \
--captive -X --abort' -- $cur ) )
else
cur = ${ cur : =/dev/ }
_filedir
fi
}
complete -F _smartctl smartctl
}
2006-02-25 10:49:40 +00:00
# vncviewer(1) completion
#
have vncviewer &&
_vncviewer( )
{
local cur prev
local -a config
2008-05-06 20:20:14 +01:00
2006-02-25 10:49:40 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2006-02-25 10:49:40 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2006-02-25 23:12:40 +00:00
case " $prev " in
2006-02-25 10:49:40 +00:00
-via)
_known_hosts -a
; ;
*)
# ssh into the the server, find and ping the broadcast address, then
# sort and show the results.
COMPREPLY = ( $( ssh -o 'Batchmode yes' $prev \
"ping -bnc 4 255.255.255.255" 2>/dev/null | \
awk -F ' ' '{print $4}' | \
sort -n | uniq | egrep '[0-9]+\.[0-9]+\.' 2>/dev/null ) )
esac
2008-05-06 20:20:14 +01:00
2006-02-25 10:49:40 +00:00
return 0
} &&
complete -F _vncviewer vncviewer
2006-02-25 12:02:25 +00:00
# sysctl(8) completion
#
have sysctl &&
_sysctl( )
{
local cur
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2006-02-25 12:02:25 +00:00
COMPREPLY = ( $( compgen -W " $( sysctl -N -a 2>/dev/null) " -- $cur ) )
return 0
} &&
complete -F _sysctl sysctl
2006-03-01 08:40:27 +00:00
# update-rc.d(8) completion
#
# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
#
have update-rc.d &&
_update_rc_d( )
{
local cur prev sysvdir services options valid_options
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2006-03-01 08:40:27 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
[ -d /etc/rc.d/init.d ] && sysvdir = /etc/rc.d/init.d \
|| sysvdir = /etc/init.d
2009-01-11 15:37:05 +02:00
services = ( $( echo $sysvdir /!( README*| *.sh| *.dpkg*| *.rpm@( orig| new| save) ) ) )
2006-03-01 08:40:27 +00:00
services = ( ${ services [@]# $sysvdir / } )
options = ( -f -n )
if [ [ $COMP_CWORD -eq 1 || " $prev " = = -* ] ] ; then
valid_options = ( $( \
echo " ${ COMP_WORDS [@] } ${ options [@] } " \
| tr " " "\n" \
| sed -ne " / $( echo " ${ options [@] } " | sed "s/ /\\|/g" ) /p " \
| sort | uniq -u \
) )
COMPREPLY = ( $( compgen -W '${options[@]} ${services[@]}' \
-X '$( echo ${COMP_WORDS[@]} | tr " " "|" )' -- $cur ) )
elif [ [ " $prev " = = ?( $( echo ${ services [@] } | tr " " "|" ) ) ] ] ; then
COMPREPLY = ( $( compgen -W 'remove defaults start stop' -- $cur ) )
elif [ [ " $prev " = = defaults && " $cur " = = [ 0-9] ] ] ; then
COMPREPLY = ( 0 1 2 3 4 5 6 7 8 9 )
elif [ [ " $prev " = = defaults && " $cur " = = [ sk] ?( [ 0-9] ) ] ] ; then
COMPREPLY = ( 0 1 2 3 4 5 6 7 8 9 )
elif [ [ " $prev " = = defaults && -z " $cur " ] ] ; then
COMPREPLY = ( 0 1 2 3 4 5 6 7 8 9 s k )
elif [ [ " $prev " = = ?( start| stop) ] ] ; then
2008-05-06 20:20:14 +01:00
if [ [ " $cur " = = [ 0-9] || -z " $cur " ] ] ; then
2006-03-01 08:40:27 +00:00
COMPREPLY = ( 0 1 2 3 4 5 6 7 8 9 )
2008-05-06 20:20:14 +01:00
elif [ [ " $cur " = = [ 0-9] [ 0-9] ] ] ; then
2006-03-01 08:40:27 +00:00
COMPREPLY = ( $cur )
else
COMPREPLY = ( )
fi
elif [ [ " $prev " = = ?( [ 0-9] [ 0-9] | [ 0-6S] ) ] ] ; then
if [ [ -z " $cur " ] ] ; then
if [ [ $prev = = [ 0-9] [ 0-9] ] ] ; then
COMPREPLY = ( 0 1 2 3 4 5 6 S )
else
COMPREPLY = ( 0 1 2 3 4 5 6 S . )
fi
2008-05-06 20:20:14 +01:00
elif [ [ " $cur " = = [ 0-6S.] ] ] ; then
2006-03-01 08:40:27 +00:00
COMPREPLY = ( $cur )
else
COMPREPLY = ( )
fi
elif [ [ " $prev " = = "." ] ] ; then
COMPREPLY = ( $( compgen -W "start stop" -- $cur ) )
else
COMPREPLY = ( )
fi
return 0
} &&
complete -F _update_rc_d update-rc.d
2006-02-25 23:12:40 +00:00
# invoke-rc.d(8) completion
#
2006-03-01 08:40:27 +00:00
# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
#
2006-02-25 23:12:40 +00:00
have invoke-rc.d &&
2006-03-01 08:40:27 +00:00
_invoke_rc_d( )
2006-02-25 23:12:40 +00:00
{
2006-03-01 08:40:27 +00:00
local cur prev sysvdir services options valid_options
2006-02-25 23:12:40 +00:00
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2006-02-25 23:12:40 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
2006-03-01 08:40:27 +00:00
[ -d /etc/rc.d/init.d ] && sysvdir = /etc/rc.d/init.d \
|| sysvdir = /etc/init.d
2009-01-11 15:37:05 +02:00
services = ( $( echo $sysvdir /!( README*| *.sh| *.dpkg*| *.rpm@( orig| new| save) ) ) )
2006-03-01 08:40:27 +00:00
services = ( ${ services [@]# $sysvdir / } )
options = ( --help --quiet --force --try-anyway --disclose-deny --query --no-fallback )
if [ [ ( $COMP_CWORD -eq 1) || ( " $prev " = = --* ) ] ] ; then
valid_options = ( $( \
echo ${ COMP_WORDS [@] } ${ options [@] } \
| tr " " "\n" \
| sed -ne " / $( echo ${ options [@] } | sed "s/ /\\\\|/g" ) /p " \
| sort | uniq -u \
) )
COMPREPLY = ( $( compgen -W '${valid_options[@]} ${services[@]}' -- \
$cur ) )
elif [ -x $sysvdir /$prev ] ; then
COMPREPLY = ( $( compgen -W ' ` sed -ne " y/|/ /; \
s/^.*Usage:[ ] *[ ^ ] *[ ] *{ *\( [ ^} \" ] *\) .*$/\1 /p" \
$sysvdir /$prev ` ' -- \
$cur ) )
else
COMPREPLY = ( )
fi
2006-02-25 23:12:40 +00:00
2006-03-01 08:40:27 +00:00
return 0
2006-02-25 23:12:40 +00:00
} &&
2006-03-01 08:40:27 +00:00
complete -F _invoke_rc_d invoke-rc.d
2006-02-25 23:12:40 +00:00
2006-03-01 09:13:27 +00:00
# minicom(1) completion
#
have minicom &&
_minicom( )
{
local cur prev
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2006-03-01 09:13:27 +00:00
prev = ${ COMP_WORDS [COMP_CWORD-1] }
case $prev in
-@( a| c) )
COMPREPLY = ( $( compgen -W 'on off' -- $cur ) )
return 0
; ;
-@( S| C) )
_filedir
return 0
; ;
-P)
COMPREPLY = ( $( command ls /dev/tty* ) )
COMPREPLY = ( $( compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' -- $cur ) )
return 0
; ;
esac
if [ [ " $cur " = = -* ] ] ; then
COMPREPLY = ( $( compgen -W ' -s -o -m -M -z -l -L -w -a -t \
-c -S -d -p -C -T -8' -- $cur ) )
else
2008-05-01 22:22:11 +02:00
COMPREPLY = ( $( command ls /etc/minicom/minirc.* 2>/dev/null | sed -e 's|/etc/minicom/minirc.||' | grep " ^ $cur " ) )
2006-03-01 09:13:27 +00:00
fi
} &&
complete -F _minicom minicom
2008-06-23 13:34:05 +02:00
have rrdtool &&
2008-05-10 18:04:06 +02:00
_rrdtool ( )
{
cur = ` _get_cword`
COMPREPLY = ( $( compgen -W ' create update updatev graph dump \
restore last lastupdate first info \
fetch tune resize xport' -- $cur ) )
2008-06-23 13:34:05 +02:00
} &&
2008-05-10 18:04:06 +02:00
complete -F _rrdtool rrdtool
2006-03-01 09:22:43 +00:00
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
2008-06-22 21:42:22 +02:00
IFS = $'\t\n'
2001-12-20 07:52:12 +00:00
COMPREPLY = ( )
2008-05-01 22:22:11 +02:00
cur = ` _get_cword`
2002-01-23 23:13:21 +00:00
_expand || return 0
2001-12-20 07:52:12 +00:00
# get first exclusion compspec that matches this command
2004-07-11 16:18:24 +00:00
xspec = $( sed -ne $'/^complete .*[ \t]' ${ 1 ##*/ } $'\([ \t]\|$\)/{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 %% * }
2008-10-25 14:33:12 +02:00
local toks = ( ) tmp
2008-11-01 09:49:57 +01:00
toks = ( ${ toks [@]- } $(
2008-10-24 19:17:23 +02:00
compgen -d -- " $( quote_readline " $cur " ) " | {
while read -r tmp; do
2008-10-25 14:33:12 +02:00
# see long TODO comment in _filedir() --David
echo $tmp
2008-10-24 19:17:23 +02:00
done
}
) )
2008-06-23 11:58:40 +02:00
2008-11-01 09:49:57 +01:00
toks = ( ${ toks [@]- } $(
2009-01-08 16:35:03 +01:00
eval compgen -f -X " $xspec " -- "\$(quote_readline " \$ cur")" | {
2008-10-24 19:17:23 +02:00
while read -r tmp; do
2008-10-25 14:33:12 +02:00
[ -n $tmp ] && echo $tmp
2008-10-24 19:17:23 +02:00
done
}
) )
2008-06-23 11:58:40 +02:00
COMPREPLY = ( " ${ toks [@] } " )
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 ##* \' }
2008-06-23 12:00:22 +02:00
list = ( " ${ list [@] } " $line )
2001-12-20 16:12:44 +00:00
done
2008-06-21 22:19:37 +02:00
echo " ${ list [@] } "
2001-12-20 16:12:44 +00:00
)
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
2008-06-21 22:19:37 +02:00
eval complete -F _filedir_xspec $filenames " ${ list [@] } "
2002-01-03 00:16:41 +00:00
fi
2003-02-26 00:17:54 +00:00
unset list
2002-03-08 18:50:24 +00:00
# source completion directory definitions
2009-02-20 22:58:01 +01:00
if [ -d $BASH_COMPLETION_COMPAT_DIR -a -r $BASH_COMPLETION_COMPAT_DIR -a \
-x $BASH_COMPLETION_COMPAT_DIR ] ; then
for i in $BASH_COMPLETION_COMPAT_DIR /*; do
[ [ ${ i ##*/ } != @( *~| *.bak| *.swp| \# *\# | *.dpkg*| *.rpm@( orig| new| save) ) ] ] &&
[ \( -f $i -o -h $i \) -a -r $i ] && . $i
done
fi
2009-01-29 15:10:18 +01:00
if [ -d $BASH_COMPLETION_DIR -a -r $BASH_COMPLETION_DIR -a \
2009-02-20 22:58:01 +01:00
$BASH_COMPLETION_DIR != $BASH_COMPLETION_COMPAT_DIR -a \
2009-01-29 15:10:18 +01:00
-x $BASH_COMPLETION_DIR ] ; then
for i in $BASH_COMPLETION_DIR /*; do
[ [ ${ i ##*/ } != @( *~| *.bak| *.swp| \# *\# | *.dpkg*| *.rpm@( orig| new| save) ) ] ] &&
[ \( -f $i -o -h $i \) -a -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
2004-10-15 16:27:22 +00:00
unset UNAME RELEASE default dirnames filenames have nospace bashdefault \
plusdirs
2002-03-29 02:35:42 +00:00
2008-06-23 12:03:06 +02:00
set $BASH_COMPLETION_ORIGINAL_V_VALUE
unset BASH_COMPLETION_ORIGINAL_V_VALUE