7038N/A# This file contains an example set of shell completions that can be used with
7038N/A# bash(1). These completions allow a user to complete filenames, commands
7038N/A# name, command line options, and command line arguments using the [tab] key.
7038N/A# The completions defined here are specific to the GNU command set, as a result
7038N/A# they will provide the choice of GNU command line options in response to the
7038N/A# [tab] key. For the completed options to match the command implementation,
7038N/A# These completions are not included in the default bash(1) environment. To
7038N/A# include them in the default environment, it is recommended that this file be
7038N/A# bash_completion - programmable completion functions for bash
3.x 7038N/A# (backwards compatible with bash 2.05b)
7038N/A# $Id: bash_completion,v 1.872 2006/03/01 16:20:18 ianmacd Exp $
7038N/A# Copyright (C) Ian Macdonald <ian@caliban.org>
7038N/A# This program is free software; you can redistribute it
and/or modify
7038N/A# it under the terms of the GNU General Public License as published by
7411N/A# the Free Software Foundation; either version 2, or (at your option)
7038N/A# This program is distributed in the hope that it will be useful,
7038N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of
7038N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7038N/A# GNU General Public License for more details.
7038N/A# You should have received a copy of the GNU General Public License
7038N/A# along with this program; if not, write to the Free Software Foundation,
7038N/A# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
7038N/A# The latest version of this software can be obtained here:
7038N/A BASH_COMPLETION_ORIGINAL_V_VALUE="-v"
7038N/A BASH_COMPLETION_ORIGINAL_V_VALUE="+v"
7038N/Aif [[ -n $BASH_COMPLETION_DEBUG ]]; then
7038N/A# Alter the following to reflect the location of this file.
7038N/Areadonly BASH_COMPLETION BASH_COMPLETION_DIR
# Set a couple of useful vars
# strip OS type and version under Cygwin (
e.g. CYGWIN_NT-5.1 => Cygwin)
# features supported by bash 2.05 and higher
if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} > 04 ]] ||
[ ${BASH_VERSINFO[0]} -gt 2 ]; then
declare -r bash205=$BASH_VERSION 2>
/dev/null || :
# features supported by bash 2.05b and higher
if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] ||
[ ${BASH_VERSINFO[0]} -gt 2 ]; then
declare -r bash205b=$BASH_VERSION 2>
/dev/null || :
# features supported by bash 3.0 and higher
if [ ${BASH_VERSINFO[0]} -gt 2 ]; then
declare -r bash3=$BASH_VERSION 2>
/dev/null || :
bashdefault="-o bashdefault"
# Turn on extended globbing and programmable completion
shopt -s extglob progcomp
# A lot of the following one-liners were taken directly from the
# completion examples provided with the bash 2.04 source distribution
# Make directory commands see only directories
# The following section lists completions that are redefined later
# Do NOT break these over multiple lines.
# START exclude -- do NOT remove this line
complete -f -X '!*.?(t)bz?(2)' bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo|xpi|sxw|ott)' unzip zipinfo
complete -f -X '*.Z' compress znew
complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
complete -f -X '!*.Z' uncompress
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 display
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
complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview
complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi
complete -f -X '!*.@(dvi|DVI)?(.@(gz|bz2))' kdvi
complete -f -X '!*.@(dvi|DVI)' dvips dviselect dvitype dvipdf advi dvipdfm dvipdfmx
complete -f -X '!*.@(pdf|PDF)' acroread gpdf xpdf
complete -f -X '!*.@(?(e)ps|?(E)PS|pdf|PDF)' kpdf
complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ)|cb(r|z)|CB(R|Z)|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
complete -f -X '!*.@(?(e)ps|?(E)PS)' ps2pdf
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
complete -f -X '!*.@(mp3|MP3)' mpg123 mpg321 madplay
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|mp3|MP3|m4v|M4V|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV|asx|ASX|mng|MNG|srt)' xine aaxine fbxine kaffeine
complete -f -X '!*.@(avi|asf|wmv)' aviplay
complete -f -X '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay
complete -f -X '!*.@(mpg|mpeg|avi|mov|qt)' xanim
complete -f -X '!*.@(ogg|OGG|m3u|flac|spx)' ogg123
complete -f -X '!*.@(mp3|MP3|ogg|OGG|pls|m3u)' gqmpeg freeamp
complete -f -X '!*.fig' xfig
complete -f -X '!*.@(mid?(i)|MID?(I))' playmidi
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)' timidity
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
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
complete -f -X '!*.@(exe|EXE|com|COM|scr|SCR|
exe.so)' wine
complete -f -X '!*.@(zip|ZIP|z|Z|gz|GZ|tgz|TGZ)' bzme
complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera galeon curl dillo elinks amaya
complete -f -X '!*.@(sxw|stw|sxg|sgl|doc|dot|rtf|txt|htm|html|odt|ott|odm)' oowriter
complete -f -X '!*.@(sxi|sti|pps|ppt|pot|odp|otp)' ooimpress
complete -f -X '!*.@(sxc|stc|xls|xlw|xlt|csv|ods|ots)' oocalc
complete -f -X '!*.@(sxd|std|sda|sdd|odg|otg)' oodraw
complete -f -X '!*.@(sxm|smf|mml|odf)' oomath
complete -f -X '!*.odb' oobase
complete -f -X '!*.rpm' rpm2cpio
# FINISH exclude -- do not remove this line
# start of section containing compspecs that can be handled within bash
# user commands see only users
complete -u su usermod userdel passwd chage write chfn groups slay w sux
# group commands see only groups
[ -n "$bash205" ] && complete -g groupmod groupdel newgrp 2>
/dev/null# bg completes with stopped jobs
complete -A stopped -P '%' bg
complete -j -P '%' fg jobs disown
# readonly and unset complete with shell variables
complete -v readonly unset
# set completes with set options
# shopt completes with shopt options
complete -A helptopic help
# unalias completes with aliases
# bind completes with readline bindings (make this more intelligent)
# type and which complete on commands
complete -c command type which
# builtin completes on builtins
# start of section containing completion functions called by other functions
# This function checks whether we have a given program on the system.
# No need for bulky functions in memory if we don't.
# use GNU sed if we have it, since its extensions are still used in our code
[ $UNAME != Linux ] && have gsed && alias sed=gsed
# This function checks whether a given readline variable
[[ "$( bind -v )" = *$1+([[:space:]])on* ]]
# This function shell-quotes the argument
echo \'${1//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
# This function quotes the argument in a way so that readline dequoting
# results in the original argument
echo \'${t//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
# This function shell-dequotes the argument
# 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.)
if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then
echo "${COMP_WORDS[COMP_CWORD]}"
local index="$COMP_POINT"
for (( i = 0; i <= COMP_CWORD; ++i )); do
while [[ "${#cur}" -ge ${#COMP_WORDS[i]} ]] && [[ "${cur:0:${#COMP_WORDS[i]}}" != "${COMP_WORDS[i]}" ]]; do
if [[ "$i" -lt "$COMP_CWORD" ]]; then
cur="${cur#${COMP_WORDS[i]}}"
index="$(( index - old_size + new_size ))"
if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then
# We messed up! At least return the whole word so things keep working
echo "${COMP_WORDS[COMP_CWORD]}"
# This function performs file and directory completion. It's better than
# simply using 'compgen -f', because it honours spaces in filenames.
# If passed -d, it completes only on directories. If passed anything else,
# it's assumed to be a file glob to complete on.
[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
done < <( compgen -d -- "$(quote_readline "$cur")" )
if [[ "$1" != -d ]]; then
[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
done < <( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" )
COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
# This function completes on signal names
# 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
COMPREPLY=( $( compgen -A signal SIG${cur#-} ))
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=-${COMPREPLY[i]#SIG}
# This function completes on configured network interfaces
COMPREPLY=( $( sed -ne 's|^iface \([^ ]\+\).*$|\1|p' \
COMPREPLY=( $( command ls \
sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
COMPREPLY=( $( command ls -B \
sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
COMPREPLY=( $( command ls \
sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
# This function completes on all available network interfaces
# -a: restrict to active interfaces only
# -w: restrict to wireless interfaces only
if [ "${1:-}" = -w ]; then
elif [ "${1:-}" = -a ]; then
sed -ne 's|^\('$cur'[^[:space:][:punct:]]\{1,\}\).*$|\1|p') )
# This function expands tildes in pathnames
# FIXME: Why was this here?
# [ "$cur" != "${cur%\\}" ] && cur="$cur\\"
# expand ~username type directory specifications
if [[ "$cur" == \~*/* ]]; then
elif [[ "$cur" == \~* ]]; then
COMPREPLY=( $( compgen -P '~' -u $cur ) )
# This function completes on process IDs.
# AIX and Solaris ps prefers
X/Open syntax.
[ $UNAME = SunOS -o $UNAME = AIX ] &&
COMPREPLY=( $( compgen -W '$( command ps -efo pid | sed 1d )' -- $cur ))
COMPREPLY=( $( compgen -W '$( command ps axo pid | sed 1d )' -- $cur ) )
# This function completes on process group IDs.
# AIX and SunOS prefer
X/Open, all else should be BSD.
[ $UNAME = SunOS -o $UNAME = AIX ] &&
COMPREPLY=( $( compgen -W '$( command ps -efo pgid | sed 1d )' -- $cur ))
COMPREPLY=( $( compgen -W '$( command ps axo pgid | sed 1d )' -- $cur ))
# This function completes on user IDs
COMPREPLY=( $( getent passwd | \
awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) )
COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- $cur ) )
COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\
# This function completes on group IDs
COMPREPLY=( $( getent group | \
awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) )
COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- $cur ) )
COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\
# This function completes on services
COMPREPLY=( $( builtin echo $sysvdir/!(*.rpmsave|*.rpmorig|*~|functions)) )
COMPREPLY=( "${COMPREPLY[@]}" $( builtin echo $famdir/!(*.rpmsave|*.rpmorig|*~)) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- $cur ) )
# This function complete on modules
COMPREPLY=( $( command ls -R $modpath | \
sed -ne 's/^\('$cur'.*\)\.k\?o\(\|.gz\)$/\1/p') )
# this function complete on user:group format
if [[ $cur = *@(\\:|.)* ]] && [ -n "$bash205" ]; then
COMPREPLY=( $(compgen -P ${user/\\\\} -g -- ${cur##*[.:]}) )
elif [[ $cur = *:* ]] && [ -n "$bash205" ]; then
COMPREPLY=( $( compgen -g -- ${cur##*[.:]} ) )
COMPREPLY=( $( compgen -S : -u -- $cur ) )
# this function count the number of mandatory args
for (( i=1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" != -* ]]; then
# start of section containing completion functions for bash built-ins
cur=${COMP_WORDS[$COMP_CWORD]}
COMPREPLY=( $( compgen -A alias -S '=' -- $cur ) )
COMPREPLY=( "$( alias ${cur%=} 2>
/dev/null | \
sed -e 's|^alias '$cur'\(.*\)$|\1|' )" )
complete -F _alias $nospace alias
cur=${COMP_WORDS[$COMP_CWORD]}
COMPREPLY=( $( compgen -v -P '$' -- ${cur#*=\$} ) )
COMPREPLY=( $( compgen -v -S '=' -- $cur ) )
COMPREPLY=( "$( eval echo -n \"$`echo ${cur%=}`\" |
sed -e 's/'\''/'\''\\\'\'''\''/g'
complete -F _export $default $nospace export
# bash shell function completion
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' -- \
elif [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -A function -- $cur ) )
COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" )
complete -F _function function declare typeset
# bash complete completion
prev=${COMP_WORDS[COMP_CWORD-1]}
options="default dirnames filenames"
[ -n "$bash205b" ] && options="$options nospace"
[ -n "$bash3" ] && options="$options bashdefault plusdirs"
COMPREPLY=( $( compgen -W "$options" -- $cur ) )
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 ) )
COMPREPLY=( $( compgen -A command -- $cur ) )
COMPREPLY=( $( compgen -A function -- $cur ) )
COMPREPLY=( $( complete -p | sed -e 's|.* ||' | \
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"
[ -n "$bash205" ] && options="$options -o"
COMPREPLY=( $( compgen -W "$options" -- $cur ) )
COMPREPLY=( $( compgen -A command -- $cur ) )
complete -F _complete complete
# start of section containing completion functions for external programs
# 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
# 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
prev=${COMP_WORDS[COMP_CWORD-1]}
# don't complete for things like killall, ssh and mysql if it's
# the standalone command, rather than the init script
[[ ${COMP_WORDS[0]} != @(*
init.d/!(functions|~)|service) ]] && return 0
# don't complete past 2nd token
[ $COMP_CWORD -gt 2 ] && return 0
if [[ $COMP_CWORD -eq 1 ]] && [[ $prev == "service" ]]; then
COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
s/^.*Usage.*{\(.*\)}.*$/\1/p" \
$sysvdir/${prev##*/} 2>
/dev/null`' -- $cur ) )
complete -F _service service
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \
--dereference --no-dereference --from= --silent --quiet \
--reference= --recursive --verbose --help --version' -- $cur ) )
complete -F _chown $filenames chown
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \
--dereference --no-dereference --silent --quiet \
--reference= --recursive --verbose --help --version' -- $cur ) )
# first parameter on line or first since an option?
if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || \
[[ "$prev" == -* ]] && [ -n "$bash205" ]; then
COMPREPLY=( $( compgen -g $cur 2>
/dev/null ) )
complete -F _chgrp $filenames chgrp
# umount(8) completion. This relies on the mount point being the third
# space-delimited field in the output of mount(8)
COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- $cur ) )
complete -F _umount $dirnames umount
# mount(8) completion. This will pull a list of possible mounts out of
# /etc/{,v}fstab, unless the word being completed contains a ':', which
# would indicate the specification of an NFS server. In that case, we
# query the server for a list of all available exports and complete on
[[ "$cur" == \\ ]] && cur="/"
for i in {,/usr}/{,s}
bin/showmount; do [ -x $i ] && sm=$i && break; done
if [ -n "$sm" ] && [[ "$cur" == *:* ]]; then
COMPREPLY=( $( $sm -e ${cur%%:*} | sed 1d | \
grep ^${cur#*:} | awk '{print $1}' ) )
elif [[ "$cur" == //* ]]; then
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" ) )
COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \
COMPREPLY=( $( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \
COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' \
complete -F _mount $default $filenames mount
# Linux rmmod(8) completion. This completes on a list of all currently
# installed kernel modules.
awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' 2>
/dev/null ))
# 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
prev=${COMP_WORDS[COMP_CWORD-1]}
# behave like lsmod for modprobe -r
if [ $1 = "modprobe" ] &&
[ "${COMP_WORDS[1]}" = "-r" ]; then
awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' ) )
# do filename completion if we're giving a path to a module
if [[ "$cur" == */* ]]; then
_filedir '@(?(k)o?(.gz))'
if [ $COMP_CWORD -gt 1 ] &&
[[ "${COMP_WORDS[COMP_CWORD-1]}" != -* ]]; then
# do module parameter completion
awk '{if ($1 ~ /^parm:/ && $2 ~ /^'$cur'/) { print $2 } \
else if ($1 !~ /:/ && $1 ~ /^'$cur'/) { print $1 }}' ) )
complete -F _insmod $filenames insmod modprobe modinfo
[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
-o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
local cur prev sect manpath UNAME
prev=${COMP_WORDS[COMP_CWORD-1]}
# default completion if parameter contains /
if [[ "$cur" == */* ]]; then
# strip OS type and version under Cygwin
if [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = FreeBSD \
-o $UNAME = Cygwin ]; then
manpath=$( manpath 2>
/dev/null || command man --path )
if [ -z "$manpath" ]; then
COMPREPLY=( $( compgen -c -- $cur ) )
# determine manual section to search
[[ "$prev" == [0-9ln] ]] && sect=$prev || sect='*'
manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }"
manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"
# redirect stderr for when path doesn't exist
COMPREPLY=( $( eval command ls "$manpath" 2>
/dev/null ) )
# weed out directory path names and paths to man pages
COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
# strip suffix from man pages
COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2)} )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
[[ "$prev" != [0-9ln] ]] && _filedir '[0-9ln]'
[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
-o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
-o $UNAME = OpenBSD ] && \
complete -F _man $filenames man apropos whatis
local command cur curopt i
# walk back through command line and find last option
while [ $i -le $COMP_CWORD -a ${#COMPREPLY[@]} -eq 0 ]; do
curopt=${COMP_WORDS[COMP_CWORD-$i]}
COMPREPLY=( $( compgen -u -- $cur ) )
complete -F _renice renice
if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
# return list of available signals
# return list of available PIDs
# Linux and FreeBSD killall(1) completion.
[ $UNAME = Linux -o $UNAME = FreeBSD ] &&
if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( command ps axo command | \
sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \
sed -e "s/.*\///" )' -- $cur ) )
[ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _killall killall pkill
# Linux and FreeBSD pgrep(1) completion.
[ $UNAME = Linux -o $UNAME = FreeBSD ] &&
COMPREPLY=( $( compgen -W '$( command ps axo command | \
sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \
sed -e "s/.*\///" )' -- $cur ) )
[ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _pgrep pgrep
# Linux pidof(8) completion.
[ $UNAME = Linux ] && complete -F _pgrep pidof
# GNU find(1) completion. This makes heavy use of ksh style extended
# globs and contains Linux specific code for completing the parameter
local cur prev i exprfound onlyonce
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- $cur ) )
-?(a|c)newer|-fls|-fprint?(0|f)|-?(i)?(l)name|-?(i)wholename)
# this is highly non-portable
if [ -n "$bash205" ]; then
COMPREPLY=( $( compgen -g -- $cur 2>
/dev/null) )
COMPREPLY=( $( compgen -W 'b c d p f l s' -- $cur ) )
COMPREPLY=( $( compgen -u -- $cur ) )
COMP_WORDS=(COMP_WORDS[0] $cur)
-[acm]min|-[acm]time|-?(i)?(l)name|-inum|-?(i)path|-?(i)regex| \
-links|-perm|-size|-used|-printf)
# do nothing, just wait for a parameter to be given
# set exprfound to 1 if there is already an expression present
for i in ${COMP_WORDS[@]}; do
[[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break
# handle case where first parameter is not a dash option
if [ "$exprfound" != 1 ] && [[ "$cur" != [-\(\),\!]* ]]; then
# complete using basic options
COMPREPLY=( $( compgen -W '-daystart -depth -follow -help -maxdepth \
-mindepth -mount -noleaf -version -xdev -amin -anewer \
-atime -cmin -cnewer -ctime -empty -false -fstype \
-gid -group -ilname -iname -inum -ipath -iregex \
-links -lname -mmin -mtime -name -newer -nouser \
-nogroup -perm -regex -size -true -type -uid -used \
-user -xtype -exec -fls -fprint -fprint0 -fprintf -ok \
-print -print0 -printf -prune -ls' -- $cur ) )
# this removes any options from the list of completions that have
# 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 \
COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \
[ "${onlyonce/ ${i%% *} / }" == "$onlyonce" ] &&
# flatten array with spaces on either side,
# otherwise we cannot grep on word boundaries of
COMPREPLY=" ${COMPREPLY[@]} "
# remove word from list of completions
COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
complete -F _find $filenames find
# Linux iwconfig(8) completion
[ $UNAME = Linux ] && have iwconfig &&
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'managed ad-hoc master \
repeater secondary monitor' -- $cur ) )
COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
COMPREPLY=( "${COMPREPLY[@]}" \
$( iwlist ${COMP_WORDS[1]} scan | \
awk -F '"' '/ESSID/ {print $2}' | \
COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \
awk '/^[[:space:]]*Channel/ {print $2}' | \
COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \
awk '/^[[:space:]]*Channel/ {print $4"G"}' | \
COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
COMPREPLY=( "${COMPREPLY[@]}" \
$( iwlist ${COMP_WORDS[1]} scan | \
awk -F ': ' '/Address/ {print $2}' | \
COMPREPLY=( $( compgen -W 'auto fixed' -- $cur ) )
COMPREPLY=( "${COMPREPLY[@]}" \
$( iwlist ${COMP_WORDS[1]} rate | \
awk '/^[[:space:]]*[0-9]/ {print $1"M"}' | \
COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) )
COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) )
COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) )
COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) )
COMPREPLY=( $( compgen -W 'period timeout off on' -- $cur ) )
COMPREPLY=( $( compgen -W 'off on auto' -- $cur ) )
COMPREPLY=( $( compgen -W 'limit lifetime' -- $cur ) )
if [ $COMP_CWORD -eq 1 ]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
COMPREPLY=( $( compgen -W 'essid nwid mode freq channel sens mode \
ap nick rate rts frag enc key power txpower commit' -- $cur ) )
complete -F _iwconfig iwconfig
# Linux iwlist(8) completion
[ $UNAME = Linux ] && have iwlist &&
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD -eq 1 ]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
COMPREPLY=( $( compgen -W 'scan scanning freq frequency \
channel rate bit bitrate key enc encryption power \
txpower retry ap accesspoint peers event' -- $cur ) )
complete -F _iwlist iwlist
# Linux iwspy(8) completion
[ $UNAME = Linux ] && have iwspy &&
if [ $COMP_CWORD -eq 1 ]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
COMPREPLY=( $( compgen -W 'setthr getthr off' -- $cur ) )
# Linux iwpriv(8) completion
[ $UNAME = Linux ] && have iwpriv &&
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
COMPREPLY=( $( compgen -W 'ad-hoc managed' -- $cur ) )
if [ $COMP_CWORD -eq 1 ]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
COMPREPLY=( $( compgen -W '--all roam port' -- $cur ) )
complete -F _iwpriv iwpriv
# RedHat & Debian
GNU/Linux if{up,down} completion
[ $UNAME = Linux ] && { have ifup || have ifdown; } &&
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") )
complete -F _ifupdown ifup ifdown
[ $UNAME = Linux ] && have ifstatus && complete -F _ifupdown ifstatus
[ $UNAME = Linux ] && have ipsec &&
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look \
manual pluto ranbits rsasigkey \
setup showdefaults showhostkey spi \
spigrp tncfg whack' -- $cur ) )
COMPREPLY=( $( compgen -W '--asynchronous --up --add --delete \
--replace --down --route --unroute \
--ready --status --rereadsecrets' \
COMPREPLY=( $( compgen -W '--up --down --route --unroute \
COMPREPLY=( $( compgen -W '--quick --continuous --bytes' \
COMPREPLY=( $( compgen -W '--start --stop --restart' -- $cur ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $cur == '-' ]]; then
if [[ $prev == '-c' ]]; then
if [[ $prev == '-D' ]]; then
COMPREPLY=( $( compgen -W 'start' -- "`get_cword`" ) )
COMPREPLY=( $( compgen -W 'start stop reload abort flush check' -- \
complete -F _postfix postfix
# postalias(1) and postmap(1)
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $cur == '-' ]]; then
COMPREPLY=(-N -f -i -n -o -p -r -v -w -c -d -q)
if [[ $prev == '-c' ]]; then
if [[ $prev == -[dq] ]]; then
if [[ "$cur" == *:* ]]; then
COMPREPLY=( $( compgen -f -- ${cur#*:} ) )
if [[ "$cur" == "${pval:0:$len}" ]]; then
if [[ $idx -eq 0 ]]; then
COMPREPLY=( $( compgen -f -- "$cur" ) )
complete -F _postmap postmap postalias
local cur prev pval len idx qfile
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $cur == '-' ]]; then
if [[ $prev == '-c' ]]; then
for idx in "${COMP_WORDS[@]}"; do
[[ "$idx" = -q ]] && qfile=1 && break
if [[ $qfile == 1 ]]; then
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
if [[ "$cur" == "${pval:0:$len}" ]]; then
complete -F _postcat postcat
local cur prev pval len idx eqext
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $cur == '-' ]]; then
COMPREPLY=(-c -d -e -h -m -l -n -v)
if [[ $prev == '-c' ]]; then
if [[ $prev == '-e' ]]; then
if [[ "$cur" == "${pval:0:$len}" ]]; then
COMPREPLY[$idx]="$pval$eqext"
complete -F _postconf postconf
local cur prev pval len idx
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $cur == '-' ]]; then
COMPREPLY=(-c -d -h -H -p -r -s -v)
for pval in $( echo ALL; mailq | \
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
if [[ "$cur" == "${pval:0:$len}" ]]; then
for pval in $( echo ALL; mailq | \
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//; /!$/d' ); do
if [[ "$cur" == "${pval:0:$len}" ]]; then
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=( $( compgen -W 'hold incoming active deferred' -- $cur ) )
complete -F _postsuper postsuper
[ -z ${prefix:-} ] || prefix=${cur%/*}/
if [ -n "$prefix" ]; then
COMPREPLY=( $( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ) )
COMPREPLY=( $( command ls -d ${cvsroot}/!(CVSROOT) ) )
local cur count mode i cvsroot cvsroots pwd
local -a flags miss files entries changed newremoved
for i in "${COMP_WORDS[@]}"; do
[ $count -eq $COMP_CWORD ] && break
# Last parameter was the CVSROOT, now go back to mode selection
if [ "${COMP_WORDS[((count))]}" == "$cvsroot" -a "$mode" == "cvsroot" ]; then
cvsroot=${COMP_WORDS[((count+1))]}
elif [[ "$i" = -* ]]; then
flags=( "${flags[@]}" $i )
if [[ "$cur" != -* ]]; then
if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}
CVS/Entries ]; then
files=$( command ls -Ad !(CVS) ) || \
for i in "${entries[@]}"; do
files=( ${files[@]/#$i//} )
COMPREPLY=( $( compgen -W '${files[@]}' -- \
COMPREPLY=( $( compgen -W '-k -m' -- $cur ) )
if [[ "$cur" = -* ]]; then
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' -- \
if [[ "$cur" = -* ]]; then
COMPREPLY=( $( compgen -W '-D -F -f -l -R -r' -- $cur ) )
COMPREPLY=( $( compgen -W '${entries[@]}' -- $cur ) )
if [[ "$cur" != -* ]]; then
[ -z "$cvsroot" ] && cvsroot=$CVSROOT
COMPREPLY=( $( cvs -d "$cvsroot" co -c 2>
/dev/null | \
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
COMPREPLY=( $( compgen -W '-A -N -P -R -c -f -l -n -p \
-s -r -D -d -k -j' -- $cur ) )
if [[ "$cur" != -* ]] && [ -r ${prefix:-}
CVS/Entries ]; then
# if $COMP_CVS_REMOTE is not null, 'cvs commit' will
# complete on remotely checked-out files (requires
# passwordless access to the remote repository
if [ -n "${COMP_CVS_REMOTE:-}" ]; then
# this is the least computationally intensive
# way found so far, but other changes
changed=( $( cvs -q diff --brief 2>&1 | \
sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ) )
newremoved=( $( cvs -q diff --brief 2>&1 | \
sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ) )
COMPREPLY=( $( compgen -W '${changed[@]:-} \
${newremoved[@]:-}' -- $cur ) )
COMPREPLY=( $( compgen -W '-n -R -l -f -F -m -r' -- \
if [ -r ~/.cvspass ]; then
# Ugly escaping because of bash treating ':' specially
cvsroots=$( sed 's/^[^ ]* //; s/:/\\:/g' ~/.cvspass )
COMPREPLY=( $( compgen -W '$cvsroots' -- $cur ) )
if [[ "$cur" != -* ]]; then
[ -z "$cvsroot" ] && cvsroot=$CVSROOT
COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
COMPREPLY=( $( compgen -W '-N -f -l -R -n \
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '${entries[@]:-}' -- $cur ) )
if [[ "$cur" != -* ]]; then
if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}
CVS/Entries ]; then
# find out what files are missing
for i in "${entries[@]}"; do
[ ! -r "$i" ] && miss=( "${miss[@]}" $i )
COMPREPLY=( $(compgen -W '${miss[@]:-}' -- $cur) )
COMPREPLY=( $( compgen -W '-f -l -R' -- $cur ) )
if [[ "$cur" != -* ]]; then
# starts with same algorithm as checkout
[ -z "$cvsroot" ] && cvsroot=$CVSROOT
if [ -r ${cvsroot}/${prefix} ]; then
COMPREPLY=( ${COMPREPLY[@]#$cvsroot} )
COMPREPLY=( ${COMPREPLY[@]#\/} )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' -- \
COMPREPLY=( $( compgen -W '-d -k -I -b -m -W' -- $cur ))
if [[ "$cur" = -* ]]; then
COMPREPLY=( $( compgen -W '-A -P -C -d -f -l -R -p \
COMPREPLY=( $( compgen -W 'add admin annotate checkout ci co \
commit diff delete edit export \
freeze get history import log new \
patch rcs rdiff release remove \
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 ) )
complete -F _cvs $default cvs
# helper functions for rpm completion
_rpm_installed_packages()
# using RHL 7.2 or later - this is quicker than querying the DB
's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+.*\.rpm$|\1|p' \
if [[ "$ver" > "4.0.4" ]]; then
if [[ "$ver" > "4.0.99" ]]; then
COMPREPLY=( $( rpm -qa $nodig $nosig | sed -ne \
's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+$|\1|p' ) )
# remove trailing backslash, or grep will complain
COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat '%{group}\n' | \
# backslash escape spaces and translate newlines to tabs
COMPREPLY=( $( echo "${COMPREPLY[@]}" | sed 's/ /\\ /g' | tr '\n' '\t' ) )
local cur prev ver nodig nosig
prev=${COMP_WORDS[COMP_CWORD-1]}
ver=$(rpm --version); ver=${ver##* }
if [[ "$ver" > "4.0.4" ]]; then
if [[ "$ver" > "4.0.99" ]]; then
if [ $COMP_CWORD -eq 1 ]; then
# first parameter on line
COMPREPLY=( $( compgen -W '-ba -bb -bc -bi -bl -bp -bs'\
COMPREPLY=( $( compgen -W '-ta -tb -tc -ti -tl -tp -ts'\
COMPREPLY=( $( compgen -W '--help --version --initdb \
--checksig --recompile --rebuild --resign --addsign \
--rebuilddb --showrc --setperms --setugids --tarbuild \
--eval --install --upgrade --query --freshen --erase \
--verify --querytags --rmsource --rmspec --clean \
COMPREPLY=( $( compgen -W '-b -e -F -i -q -t -U -V' \
--@(@(db|exclude)path|prefix|relocate|root))
COMPREPLY=( $( sed -ne 's|^\(%'${cur#\%}'[^ '$'\t'']*\).*$|\1|p' \
COMPREPLY=( $( compgen -c -- $cur ) )
# complete on .spec files
if [[ "$cur" == */* ]]; then
# complete on capabilities
COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat \
'%{providename}\n' | grep "^$cur" ) )
# complete on capabilities
COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat \
'%{requirename}\n' | grep "^$cur" ) )
case "${COMP_WORDS[1]}" in
-@([iFU]*|-install|-freshen|-upgrade))
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--percent --force --test \
--replacepkgs --replacefiles --root --excludedocs \
--includedocs --noscripts --rcfile --ignorearch \
--dbpath --prefix --ignoreos --nodeps --allfiles \
--ftpproxy --ftpport --justdb --httpproxy --httpport \
--noorder --relocate --badreloc --notriggers \
--excludepath --ignoresize --oldpackage --define \
--eval --pipe --queryformat --repackage --nosuggests \
--nodigest --nosignature' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--allmatches --noscripts \
--notriggers --nodeps --test --repackage' -- $cur ) )
# check whether we're doing file completion
if [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--scripts --root \
--rcfile --requires --ftpport --ftpproxy \
--httpproxy --httpport --provides --triggers \
--dump --changelog --dbpath \
--docfiles --configfiles --queryformat \
--conflicts --obsoletes \
--nodigest --nosignature \
--triggerscripts' -- $cur ) )
elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
# uninstalled package completion
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--scripts --root \
--rcfile --whatprovides --whatrequires \
--requires --triggeredby --ftpport --ftpproxy \
--httpproxy --httpport --provides --triggers \
--dump --changelog --dbpath --filesbypkg \
--define --eval --pipe --showrc --info --list \
--state --docfiles --configfiles --queryformat\
--conflicts --obsoletes --nodigest \
--nosignature' -- $cur ) )
# installed package completion
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--scripts --root \
--rcfile --whatprovides --whatrequires \
--requires --triggeredby --ftpport --ftpproxy \
--httpproxy --httpport --provides --triggers \
--dump --changelog --dbpath --specfile \
--querybynumber --last --filesbypkg --define \
--eval --pipe --showrc --info --list --state \
--docfiles --configfiles --queryformat \
--conflicts --obsoletes --pkgid --hdrid \
--fileid --tid --nodigest --nosignature \
--triggerscripts' -- $cur ) )
elif [ "${COMP_LINE#* -*([^ -])a}" == "$COMP_LINE" ]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--nopgp --nogpg --nomd5 \
--nodigest --nosignature' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--root --rcfile --dbpath \
--nodeps --nogroup --nolinkto --nomode --nomtime \
--nordev --nouser --nofiles --noscripts --nomd5 \
--querytags --specfile --whatrequires --whatprovides \
--nodigest --nosignature' -- $cur ) )
# check whether we're doing file completion
elif [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--short-circuit --timecheck \
--clean --rmsource --rmspec --test --sign --buildroot \
--target -- buildarch --buildos --nobuild --nodeps \
--nodirtokens' -- $cur ) )
elif [[ ${COMP_WORDS[1]} == -b* ]]; then
_filedir '@(tgz|tar.@(gz|bz2))'
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--nodeps --rmsource \
--rmspec --sign --nodirtokens --target' -- $cur ) )
_filedir '@(tgz|tar.@(gz|bz2))'
--@(clean|rms@(ource|pec)))
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--clean --rmsource \
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--import --dbpath --root' \
complete -F _rpm $filenames rpm rpmbuild
# Debian apt-get(8) completion.
prev=${COMP_WORDS[COMP_CWORD-1]}
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
if [[ ${COMP_WORDS[i]} == @(install|remove|purge|source|build-dep) ]]; then
if [ -n "$special" ]; then
COMPREPLY=( $( _comp_dpkg_installed_packages \
COMPREPLY=( $( apt-cache pkgnames $cur 2>
/dev/null ) )
-@(t|-target-release|-default-release))
COMPREPLY=( $( apt-cache policy | \
sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2>
/dev/null) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d -f -h -v -m -q -s -y \
-u -t -b -c -o --download-only --fix-broken \
--help --version --ignore-missing \
--fix-missing --no-download --quiet --simulate \
--just-print --dry-run --recon --no-act --yes \
--assume-yes --show-upgraded --only-source \
--compile --build --ignore-hold \
--target-release --no-upgrade --force-yes \
--print-uris --purge --reinstall \
--list-cleanup --default-release \
--trivial-only --no-remove --diff-only \
--tar-only --config-file --option --auto-remove' -- $cur ) )
COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \
dist-upgrade install remove purge source \
build-dep check clean autoclean autoremove' \
complete -F _apt_get $filenames apt-get
# Debian apt-cache(8) completion.
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ "$cur" != show ]; then
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
if [[ ${COMP_WORDS[i]} == @(add|depends|dotty|policy|rdepends|madison|show?(pkg|src|)) ]]; then
if [ -n "$special" ]; then
COMPREPLY=( $( apt-cache pkgnames $cur 2>
/dev/null ) )
-@(c|p|s|-config-file|-@(pkg|src)-cache))
if [[ "$cur" != -* ]]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-h -v -p -s -q -i -f -a -g -c \
-o --help --version --pkg-cache --src-cache \
--quiet --important --full --all-versions \
--no-all-versions --generate --no-generate \
--names-only --all-names --recurse \
--config-file --option' -- $cur ) )
COMPREPLY=( $( compgen -W 'add gencaches show showpkg showsrc \
stats dump dumpavail unmet search search \
depends rdepends pkgnames dotty xvcg \
policy madison' -- $cur ) )
complete -F _apt_cache $filenames apt-cache
# Debian aptitude(1) completion
_comp_dpkg_hold_packages()
grep-status -P -e "^$1" -a -FStatus 'hold' -n -s Package
_comp_dpkg_hold_packages()
local cur dashoptions prev special i
prev=${COMP_WORDS[COMP_CWORD-1]}
dashoptions='-S -u -i -h --help --version -s --simulate -d \
--download-only -P --prompt -y --assume-yes -F \
--display-format -O --sort -w --width -f -r -g \
--with-recommends --with-suggests -R -G \
--without-recommends --without-suggests -t \
--target-release -V --show-versions -D --show-deps\
-Z -v --verbose --purge-unused'
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
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) ]]; then
#exclude some mutually exclusive options
[[ ${COMP_WORDS[i]} == '-u' ]] && dashoptions=${dashoptions/-i}
[[ ${COMP_WORDS[i]} == '-i' ]] && dashoptions=${dashoptions/-u}
if [[ -n "$special" ]]; then
@(install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|changelog|why|why-not))
COMPREPLY=( $( apt-cache pkgnames $cur 2>
/dev/null ) )
@(purge|remove|reinstall|forbid-version))
COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
COMPREPLY=( $( _comp_dpkg_hold_packages $cur ) )
# don't complete anything if these options are found
@(autoclean|clean|forget-new|search|upgrade|safe-upgrade|update|keep-all))
-@(t|-target-release|-default-release))
COMPREPLY=( $( apt-cache policy | \
sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2>
/dev/null ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
COMPREPLY=( $( compgen -W 'update upgrade safe-upgrade forget-new clean \
autoclean install reinstall remove \
hold unhold purge markauto unmarkauto why why-not \
dist-upgrade full-upgrade download search show \
forbid-version changelog keep-all' -- $cur ) )
complete -F _aptitude $default aptitude
# Debian apt-build(1) completion.
prev=${COMP_WORDS[COMP_CWORD-1]}
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
if [[ ${COMP_WORDS[i]} == @(install|remove|source|info|clean) ]]; then
if [ -n "$special" ]; then
COMPREPLY=( $( apt-cache pkgnames $cur 2>
/dev/null ) )
COMPREPLY=( $( _comp_dpkg_installed_packages \
--@(patch|build-dir|repository-dir))
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --show-upgraded -u --build-dir \
--repository-dir --build-only \
--build-command --reinstall --rebuild \
--remove-builddep --no-wrapper --purge \
--patch --patch-strip -p --yes -y \
--version -v --no-source' -- $cur ) )
COMPREPLY=( $( compgen -W 'update upgrade install remove \
source dist-upgrade world clean info \
clean-build update-repository ' -- $cur ) )
complete -F _apt_build $filenames apt-build
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ "$prev" = "-s" ]; then
COMPREPLY=( $( chsh -l | grep "^$cur" ) )
COMPREPLY=( $( compgen -u -- $cur ) )
# chkconfig(8) completion
prev=${COMP_WORDS[COMP_CWORD-1]}
@([1-6]|--@(list|add|del)))
COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--list --add --del --level' -- $cur ) )
if [ $COMP_CWORD -eq 2 -o $COMP_CWORD -eq 4 ]; then
COMPREPLY=( $( compgen -W 'on off reset' -- $cur ) )
complete -F _chkconfig chkconfig
# This function provides simple user@host completion
if [[ $cur == *@* ]]; then
COMPREPLY=( $( compgen -u -- "$cur" ) )
shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
# This function performs host completion based on ssh's known_hosts files,
# defaulting to standard host completion if they don't exist.
local cur curd ocur user suffix aliases global_kh user_kh hosts i host
[ "$1" = -a ] || [ "$2" = -a ] && aliases='yes'
[ "$1" = -c ] || [ "$2" = -c ] && suffix=':'
[[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}
[ -r "${HOME}/.ssh/config" ] &&
config=( "${config[@]}" "${HOME}/.ssh/config" )
[ -r "${HOME}/.ssh2/config" ] &&
config=( "${config[@]}" "${HOME}/.ssh2/config" )
if [ ${#config[@]} -gt 0 ]; then
# expand path (if present) to global known hosts file
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[@]}" ) )
# expand path (if present) to user known hosts file
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[@]}" ) )
# Global known_hosts files
kh=( "${kh[@]}" "$global_kh" )
kh=( "${kh[@]}" "$user_kh" )
[ -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 )
# If we have known_hosts files to use
if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 ]; then
# Escape slashes and dots in paths for awk
if [[ "$cur" == [0-9]*.* ]]; then
# Digits followed by a dot - just search for that
elif [[ "$cur" == [0-9]* ]]; then
# Digits followed by no dot - search for digits followed
# A blank - search for a dot or an alpha character
if [ ${#kh[@]} -gt 0 ]; then
# FS needs to look for a comma separated list
COMPREPLY=( $( awk 'BEGIN {FS=","}
/^[^|]/ {for (i=1; i<=2; ++i) { \
if ($i ~ /'$cur'/) {print $i} \
if [ ${#khd[@]} -gt 0 ]; then
# Needs to look for files called
# .../.ssh2/key_22_<hostname>.pub
# dont fork any processes, because in a cluster environment,
# there can be hundreds of hostkeys
for i in "${khd[@]}" ; do
if [[ "$i" == *key_22_$curd*.pub ]] && [ -r "$i" ] ; then
COMPREPLY=( "${COMPREPLY[@]}" $host )
# append any available aliases from config files
if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^*?]*\)$/\2/p' "${config[@]}" )
hosts=$( compgen -W "$host_aliases" -- $ocur )
COMPREPLY=( "${COMPREPLY[@]}" $hosts )
# Now add results of normal hostname completion
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -A hostname -- $ocur ) )
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=$user${COMPREPLY[i]}$suffix
# Just do normal hostname completion
COMPREPLY=( $( compgen -A hostname -S "$suffix" -- $cur ) )
complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \
ping ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'blowfish 3des 3des-cbc blowfish-cbc \
arcfour cast128-cbc' -- $cur ) )
COMPREPLY=( $( compgen -u -- $cur ) )
[ $COMP_CWORD -eq 1 ] || \
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
shopt -u hostcomplete && complete -F _ssh ssh slogin sftp xhost autossh
if [[ "$cur" == *:* ]]; then
# remove backslash escape from :
path=${path//\\\\\\\\ / }
# default to home dir of specified user on remote host
path=$(ssh -o 'Batchmode yes' $userhost pwd 2>
/dev/null)
# escape spaces; remove executables, aliases, pipes and sockets;
# add space at end of file names
COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
sed -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\\\\\\\\\&/g" \
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
[[ "$cur" == */* ]] || _known_hosts -c -a
COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \
-e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\&/g" \
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
complete -F _scp $nospace scp
local cur prev shell i userhost path
prev=${COMP_WORDS[COMP_CWORD-1]}
--@(config|password-file|include-from|exclude-from))
-@(T|-temp-dir|-compare-dest))
COMPREPLY=( $( compgen -W 'rsh ssh' -- $cur ) )
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
for (( i=1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == -@(e|-rsh) ]]; then
if [[ "$shell" == ssh ]]; then
# remove backslash escape from :
path=${path//\\\\\\\\ / }
# default to home dir of specified
path=$(ssh -o 'Batchmode yes' \
# escape spaces; remove executables, aliases, pipes
# and sockets; add space at end of file names
COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
sed -e 's/ /\\\\\\\ /g' -e 's/[*@|=]$//g' \
complete -F _rsync $nospace $filenames rsync
# Linux route(8) completion
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ "$prev" = dev ]; then
COMPREPLY=( $( ifconfig -a | sed -ne 's|^\('$cur'[^ ]*\).*$|\1|p' ))
COMPREPLY=( $( compgen -W 'add del -host -net netmask metric mss \
window irtt reject mod dyn reinstate dev \
COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \
[ "$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 / } )
[ $UNAME = Linux ] && complete -F _route route
have make || have gmake || have gnumake || have pmake &&
local file makef makef_dir="." makef_inc cur prev i
prev=${COMP_WORDS[COMP_CWORD-1]}
# --name value style option
# --name=value style option
if [[ "$cur" == *=* ]]; then
--@(directory|include-dir))
if [[ "$cur" == -* ]]; then
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 ) )
# before we check for makefiles, see if a path was specified
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]}
# make reads `GNUmakefile', then `makefile', then `Makefile'
if [ -f ${makef_dir}/GNUmakefile ]; then
makef=${makef_dir}/GNUmakefile
elif [ -f ${makef_dir}/makefile ]; then
makef=${makef_dir}/makefile
elif [ -f ${makef_dir}/Makefile ]; then
makef=${makef_dir}/Makefile
makef=${makef_dir}/*.mk # local convention
# before we scan for targets, see if a Makefile name was
for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
if [[ ${COMP_WORDS[i]} == -f ]]; then
# eval for tilde expansion
eval makef=${COMP_WORDS[i+1]}
[ ! -f $makef ] && return 0
# deal with included Makefiles
makef_inc=$( grep -E '^-?include' $makef | sed -e "s,^.* ,"$makef_dir"/," )
for file in $makef_inc; do
[ -f $file ] && makef="$makef $file"
COMPREPLY=( $( awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \
{split($1,A,/ /);for(i in A)print A[i]}' \
complete -f -F _make $filenames make gmake gnumake pmake
local cur ext regex tar untar
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W 'c t x u r d A' -- $cur ) )
case "${COMP_WORDS[1]}" in
ext='t@(ar?(.@(Z|gz|bz?(2)))|gz|bz?(2))'
regex='t\(ar\(\.\(Z\|gz\|bz2\?\)\)\?\|gz\|bz2\?\)'
regex='t\(ar\.\)\?\(gz\|Z\)'
if [[ "$COMP_LINE" == *$ext' ' ]]; then
# complete on files in tar file
# get name of tar file from command line
tar=$( echo "$COMP_LINE" | \
sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' )
# devise how to untar and list it
untar=t${COMP_WORDS[1]//[^Izjyf]/}
COMPREPLY=( $( compgen -W "$( echo $( tar $untar $tar \
# file completion on relevant files
[ -n "${COMP_TAR_INTERNAL_PATHS:-}" ] && complete -F _tar $dirnames tar ||
complete -F _tar $filenames tar
if [ $COMP_CWORD = 1 ]; then
COMPREPLY=( $( compgen -W 'c t x u' -- $cur ) )
case "${COMP_WORDS[1]}" in
complete -F _jar $filenames jar
# Linux iptables(8) completion
local cur prev table chain
prev=${COMP_WORDS[COMP_CWORD-1]}
chain='s/^Chain \([^ ]\+\).*$/\1/p'
if [[ $COMP_LINE == *-t\ *filter* ]]; then
elif [[ $COMP_LINE == *-t\ *nat* ]]; then
elif [[ $COMP_LINE == *-t\ *mangle* ]]; then
COMPREPLY=( $( compgen -W '`iptables $table -nL | \
sed -ne "s/^Chain \([^ ]\+\).*$/\1/p"`' -- $cur ) )
COMPREPLY=( $( compgen -W 'nat filter mangle' -- $cur ) )
if [ "$table" = "-t filter" -o "$table" = "" ]; then
COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
`iptables $table -nL | sed -ne "$chain" \
-e "
s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
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//"`' \
elif [ "$table" = "-t mangle" ]; then
COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
MARK TOS `iptables $table -nL | sed -ne "$chain" \
-e "
s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
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") )
complete -F _iptables iptables
prev=${COMP_WORDS[COMP_CWORD-1]}
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 \
complete -F _tcpdump tcpdump
COMPREPLY=( $( compgen -W '--notty --debug --help --version \
auto add fullinfo info help install list \
complete -F _autorpm autorpm
# This meta-cd function observes the CDPATH variable, so that cd additionally
# completes on directories under those specified in CDPATH.
local IFS=$'\t\n' cur=`_get_cword` i j k
# try to allow variable completion
if [[ "$cur" == ?(\\)\$* ]]; then
COMPREPLY=( $( compgen -v -P '$' -- "${cur#?(\\)$}" ) )
# Use standard dir completion if no CDPATH or parameter starts with /,
if [ -z "${CDPATH:-}" ] || [[ "$cur" == ?(.)?(.)/* ]]; then
local -r mark_dirs=$(_rl_enabled mark-directories && echo y)
local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y)
# we have a CDPATH, so loop on its contents
for i in ${CDPATH//:/$'\t'}; do
# create an array of matched subdirs
for j in $( compgen -d $i/$cur ); do
if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
if [ "$i" == "$cur" ] && [[ $i != "*/" ]]; then
if shopt -q cdable_vars; then
complete -v -F _cd $nospace $filenames cd
complete -F _cd $nospace $filenames cd
if [[ COMP_CWORD -eq 0 ]]; then
elif [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
local old_cw0="${COMP_WORDS[0]}"
local new_cw0="${COMP_WORDS[1]}"
local old_length="${#COMP_LINE}"
COMP_LINE=${COMP_LINE#${old_cw0}}
local head=${COMP_LINE:0:${#new_cw0}}
while [[ $head != $new_cw0 ]]; do
head=${COMP_LINE:0:${#new_cw0}}
local new_length="${#COMP_LINE}"
COMP_POINT=$(( COMP_POINT + new_length - old_length))
COMP_CWORD=$(( COMP_CWORD - 1 ))
for (( i=0; i < ${#COMP_WORDS[@]} - 1; ++i )); do
COMP_WORDS[i]="${COMP_WORDS[i+1]}"
unset COMP_WORDS[${#COMP_WORDS[@]}-1]
# 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
# completion definition - currently not quite foolproof (
e.g. mount and umount
# don't work properly), but still quite useful.
local cur func cline cspec noglob cmd done i \
_COMMAND_FUNC _COMMAND_FUNC_ARGS
# If the the first arguments following our meta-command-invoker are
# switches, get rid of them. Most definitely not foolproof.
if [[ "$cmd" == -* ]] && [ $COMP_CWORD -ge 1 ]; then
elif [[ "$cmd" == -* ]] && [[ $COMP_CWORD -eq 0 ]]; then
if [ $COMP_CWORD -eq 0 ]; then
COMPREPLY=( $( compgen -c -- $cur ) )
cspec=$( complete -p $cmd )
if [ "${cspec#* -F }" != "$cspec" ]; then
# COMP_CWORD and COMP_WORDS() are not read-only,
# so we can set them before handing off to regular
if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
$func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}"
$func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}"
# remove any \: generated by a command that doesn't
# default to filenames or dirnames (
e.g. sudo chown)
# FIXME: I'm pretty sure this does not work!
if [ "${cspec#*-o }" != "$cspec" ]; then
if [[ "$cspec" != @(dir|file)names ]]; then
COMPREPLY=("${COMPREPLY[@]//\\\\:/:}")
elif [ -n "$cspec" ]; then
COMPREPLY=( $( eval compgen "$cspec" -- "$cur" ) );
[ ${#COMPREPLY[@]} -eq 0 ] && _filedir
complete -F _command $filenames nohup exec nice eval strace time ltrace then \
else do vsound command xargs
complete -F _root_command $filenames sudo fakeroot really
local cur prev buildfile i
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
# relevant options completion
COMPREPLY=( $( compgen -W '-help -projecthelp -version -quiet \
-verbose -debug -emacs -logfile -logger \
-listener -buildfile -f -D -find' -- $cur ) )
# available targets completion
# find which buildfile to use
for (( i=1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == -buildfile ]]; then
buildfile=${COMP_WORDS[i+1]}
[ ! -f $buildfile ] && return 0
# parse buildfile for targets
COMPREPLY=( $( awk -F'"' '/<target name="/ {print $2}' \
$buildfile | grep "^$cur" )
$( awk -F"'" "/<target name='/ "'{print $2}' \
$buildfile | grep "^$cur" )
$( awk -F'"' '/<target [^n]/ {if ($1 ~ /name=/) { print $2 } else if ($3 ~ /name=/) {print $4} else if ($5 ~ /name=/) {print $6}}' \
$buildfile | grep "^$cur" ) )
complete -F _ant $filenames ant
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 \
complete -F _nslookup nslookup
# mysqladmin(1) completion
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -u -- $cur ) )
COMPREPLY=( $( compgen -W '-# -f -? -C -h -p -P -i -r -E -s -S -t -u \
COMPREPLY=( "${COMPREPLY[@]}" \
$( compgen -W 'create drop extended-status flush-hosts \
flush-logs flush-status flush-tables \
flush-threads flush-privileges kill \
password ping processlist reload refresh \
shutdown status variables version' \
complete -F _mysqladmin mysqladmin
local cur prev xspec IFS=$'\t\n'
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c -d -f \
-h -l -L -n -N -q -r -S -t -v -V \
-1 -2 -3 -4 -5 -6 -7 -8 -9 \
--stdout --decompress --force --help --list \
--license --no-name --name --quiet --recursive \
--suffix --test --verbose --version --fast \
if [[ "$prev" == --* ]]; then
[[ "$prev" == --decompress || \
"$prev" == --test ]] && xspec="!"$xspec
[[ "$prev" == --force ]] && xspec=
elif [[ "$prev" == -* ]]; then
[[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec
[[ "$prev" == -*f* ]] && xspec=
elif [ "$prev" = '>' ]; then
elif [ "$prev" = '<' ]; then
COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
$( compgen -d -- $cur ) )
complete -F _gzip $filenames gzip
local cur prev xspec IFS=$'\t\n'
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 ) )
if [[ "$prev" == --* ]]; then
[[ "$prev" == --decompress || \
"$prev" == --test ]] && xspec="!"$xspec
[[ "$prev" == --compress ]] && xspec=
elif [[ "$prev" == -* ]]; then
[[ "$prev" == -*[dt]* ]] && xspec="!"$xspec
[[ "$prev" == -*z* ]] && xspec=
COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
$( compgen -d -- $cur ) )
complete -F _bzip2 $filenames bzip2
for (( i=2; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == -config ]]; then
config=${COMP_WORDS[i+1]}
[ ! -f $config ] && return 0
COMPREPLY=( $( awk '/\[.*\]/ {print $2} ' $config | grep "^$cur" ) )
if [ $COMP_CWORD -eq 1 ]; then
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 \
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-inform -in -out -noout -offset \
-length -i -oid -strparse' -- $cur ) )
-@(config|revoke|cert|in|out|spkac|ss_cert))
-@(name|crlexts|extensions))
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 ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-v -ssl2 -ssl3 -tls1' -- $cur ) )
COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-inform -outform -text -in -out -noout \
-hash -issuer -lastupdate -nextupdate -CAfile -CApath' -- $cur ) )
COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-inform -outform -in -out -print_certs' -- $cur ) )
-@(out|sign|verify|prvrify|signature))
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-md5 -md4 -md2 -sha1 -sha -mdc2 -ripemd160 -dss1 \
-c -d -hex -binary -out -sign -verify -prverify -signature' -- $cur ) )
COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-inform -outform -in -passin -out -passout -des -des3 -idea -text -noout \
-modulus -pubin -pubout' -- $cur ) )
COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-inform -outform -in -out -noout \
-text -C -rand -genkey' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-ciphername -in -out -pass \
-e -d -a -A -k -kfile -S -K -iv -p -P -bufsize -debug' -- $cur ) )
COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-inform -outform -in -out -dsaparam -noout \
-text -C -2 -5 -rand' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-out -des -des3 -idea -rand' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-out -passout -des -des3 -idea -f4 -3 -rand' -- $cur ) )
COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-inform -outform -in -out -print_certs -text -noout' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-out -rand -base64' -- $cur ) )
COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
-@(in|out|rand|key|keyout|config))
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 ) )
COMPREPLY=( $( compgen -W 'DER NET PEM' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-inform -outform -in -passin -out -passout \
-sgckey -des -des3 -idea -text -noout -modulus -check -pubin \
-pubout -engine' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-in -out -inkey -pubin -certin -sign -verify \
-encrypt -decrypt -pkcs -ssl -raw -hexdump -asn1parse' -- $cur ) )
-@(cert|key|CAfile|rand))
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 ) )
-@(cert|key|dcert|dkey|dhparam|CAfile|rand))
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 \
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-connect -www -cert -key -CApath -CAfile -reuse \
-new -verify -nbio -time -ssl2 -ssl3 -bugs -cipher' -- $cur ) )
COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-inform -outform -in -out -text -noout \
COMPREPLY=( $( compgen -W 'SMIME DER PEM' -- $cur ) )
-@(in|out|certfile|signer|recip|inkey|content|rand))
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 \
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-engine' -- $cur ) )
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 ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-CApath -CAfile -purpose -untrusted -help -issuer_checks \
-verbose -certificates' -- $cur ) )
-@(in|out|CA|CAkey|CAserial|extfile))
COMPREPLY=( $( compgen -W 'DER PEM NET' -- $cur ) )
COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
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 ) )
@(md5|md4|md2|sha1|sha|mdc2|ripemd160))
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c -d' -- $cur ) )
complete -F _openssl $default openssl
prev=${COMP_WORDS[COMP_CWORD-1]}
[ "$COMP_CWORD" -ge 2 ] && preprev=${COMP_WORDS[COMP_CWORD-2]}
if [ "$preprev" = "-d" -o "$preprev" = "-D" -a "$prev" = "-r" -o \
COMPREPLY=( $( command screen -ls | \
sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*$|\1|p' ) )
COMPREPLY=( $( command screen -ls | \
sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*Detached.*$|\1|p' ) )
COMPREPLY=( $( command screen -ls | \
sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*Attached.*$|\1|p' ) )
complete -F _screen $default screen
# lftp(1) bookmark completion
if [ $COMP_CWORD -eq 1 ] && [ -f ~/.lftp/bookmarks ]; then
COMPREPLY=( $( compgen -W '$( sed -ne "s/^\(.*\)'$'\t''.*$/\1/p" \
~/.lftp/bookmarks )' -- $cur ) )
complete -F _lftp $default lftp
# ncftp(1) bookmark completion
if [ $COMP_CWORD -eq 1 ] && [ -f ~/.ncftp/bookmarks ]; then
COMPREPLY=( $( compgen -W '$( sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \
~/.ncftp/bookmarks )' -- $cur ) )
complete -F _ncftp $default ncftp
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -c -- $cur ) )
elif [ $COMP_CWORD -eq 2 ]; then
COMPREPLY=( $( compgen -fW "$( command ps axo comm,pid | \
awk '{if ($1 ~ /^'"$prev"'/) print $2}' ) )" \
complete -F _gdb $filenames gdb
sed -e '1,/^-/d' -e '/^(/,$d' | \
awk '{print $1}' | grep "^$cur" ) )
#COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>
/dev/null | \
#[ ${#COMPREPLY[@]} -eq 0 ] &&
COMPREPLY=( $( compgen -u -- $cur ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-D -T -E -h -p -U -W -e -q \
--location= --template= --encoding= --host= --port= \
--username= --password --echo --quiet --help' -- $cur ))
complete -F _createdb $default createdb
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-h -p -U -W -e -q \
--host= --port= --username= --password \
--interactive --echo --quiet --help' -- $cur ) )
complete -F _dropdb $default dropdb
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
# 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 \
# return list of available databases
complete -F _psql $default psql
if [[ "$cur" == --*=* ]]; then
# cut backslash that gets inserted before '=' sign
COMPREPLY=( $( compgen -P "$opt=" -W '${COMPREPLY[@]}' -- $cur))
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( $1 --help 2>&1 | sed -e '/--/!d' \
-e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | \
command grep "^$cur" | sort -u ) )
elif [[ "$1" == @(mk|rm)dir ]]; then
# makeinfo and texi2dvi are defined elsewhere.
for i in a2ps autoconf automake bc gprof ld nm objcopy objdump readelf strip \
bison cpio diff patch enscript cp df dir du ln ls mkfifo mknod mv rm \
touch vdir awk gperf grep grub indent less m4 sed shar date \
tee who texindex cat csplit cut expand fmt fold head \
md5sum nl od paste pr ptx sha1sum sort split tac tail tr unexpand \
uniq wc ldd bash id irb mkdir rmdir; do
have $i && complete -F _longopt $filenames $i
# 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
# 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.
backend=cc1 # (near-)universal backend
if [[ "$cur" == -* ]]; then
cc=$( $1 -print-prog-name=$backend )
# for C/C++/ObjectiveC it's useless
COMPREPLY=( $( $cc --help 2>
/dev/null | tr '\t' ' ' | \
sed -e '/^ *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | \
command grep "^$cur" | sort -u ) )
complete $filenames -F _gcc gcc g++ c++ g77 gcj gpc
[ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Cygwin ] && \
[ -n "${have:-}" ] && complete $filenames -F _gcc cc
# Linux cardctl(8) completion
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W 'status config ident suspend \
resume reset eject insert scheme' \
complete -F _cardctl cardctl
# This function is required by _dpkg() and _dpkg-reconfigure()
_comp_dpkg_installed_packages()
grep -B 1 -E "ok installed|half-installed|unpacked| \
half-configured|config-files" | \
grep "Package: $1" | cut -d\ -f2
# Debian dpkg(8) completion
prev=${COMP_WORDS[COMP_CWORD-1]}
# find the last option flag
if [[ $cur != -* ]]; then
while [[ $prev != -* && $i != 1 ]]; do
-@(c|i|A|I|f|e|x|X|-@(install|unpack|record-avail|contents|info|fsys-tarfile|field|control|extract)))
-@(s|p|l|-@(status|print-avail|list)))
COMPREPLY=( $( apt-cache pkgnames $cur 2>
/dev/null ) )
-@(r|L|P|-@(remove|purge|listfiles)))
COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
COMPREPLY=( $( compgen -W '-i --install --unpack -A --record-avail \
--configure -r --remove -P --purge --get-selections \
--set-selections --update-avail --merge-avail \
--clear-avail --command-fd --forget-old-unavail -s \
--status -p --print-avail -L --listfiles -l --list \
-S --search -C --audit --print-architecture \
--print-gnu-build-architecture \
--print-installation-architecture \
--compare-versions --help --version --force-help \
--force-all --force-auto-select --force-downgrade \
--force-configure-any --force-hold --force-bad-path \
--force-not-root --force-overwrite \
--force-overwrite-diverted --force-bad-verify \
--force-depends-version --force-depends \
--force-confnew --force-confold --force-confdef \
--force-confmiss --force-conflicts --force-architecture\
--force-overwrite-dir --force-remove-reinstreq \
--force-remove-essential -Dh \
--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 \
-b --build -I --info -f --field -c --contents \
-x --extract -X --vextract --fsys-tarfile -e --control \
--ignore-depends= --abort-after' -- $cur ) )
complete -F _dpkg $filenames dpkg dpkg-deb
# Debian GNU dpkg-reconfigure(8) completion
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W '${opt[@]}' -- $cur ) )
COMPREPLY=( $( compgen -W 'low medium high critical' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-f --frontend -p --priority -a --all \
-u --unseen-only -h --help -s --showold \
--force --terse' -- $cur ) )
COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
complete -F _dpkg_reconfigure $default dpkg-reconfigure
# Debian dpkg-source completion
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"
options=`echo "-x -b $packopts $unpackopts" | xargs echo | sort -u | xargs echo`
if [ "$1" != "dpkg-source" ]; then
prev=${COMP_WORDS[COMP_CWORD-1]}
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
if [[ ${COMP_WORDS[$i]} == "-x" ]]; then
elif [[ ${COMP_WORDS[$i]} == "-b" ]]; then
elif [[ ${COMP_WORDS[$i]} == "-h" ]]; then
# if currently seeing a complete option, return just itself.
if [ "$cur" = "$i" ]; then
if [ "$cur" = "-" -o "$cur" = "-s" ]; then
COMPREPLY=( $( compgen -d -- "$cur" ) \
$( compgen -f -X '!*.dsc' -- "$cur" ) )
COMPREPLY=( $unpackopts $(compgen -d -f -- "$cur" ) )
if [ "$cur" = "-" ]; then
if [ "$cur" = "-s" ]; then
COMPREPLY=( "-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" \
"-sA" "-sK" "-sP" "-sU" "-sR" )
COMPREPLY=( $( compgen -d -- "$cur" ) )
"-c"|"-l"|"-T"|"-i"|"-I")
# -l: get per-version info from this file
# -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 ) )
# -F: force change log format
# -V: set a substitution variable
# we don't know anything about possible variables or values
# so we don't try to suggest any completion.
# -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
COMPREPLY=( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files )
# Suggest possible fieldnames
COMPREPLY=( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files )
# 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" )
# else return all possible options.
complete -F _dpkg_source dpkg-source
# Debian Linux dselect(8) completion.
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--admindir --help --version --licence \
--license --expert --debug' -- $cur ) )
COMPREPLY=( $( compgen -W 'access update select install config \
complete -F _dselect $filenames dselect
# available path elements completion
# exact classpath determination
# 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]}
[ -z "$classpath" ] && classpath=$CLASSPATH
# default to current directory
[ -z "$classpath" ] && classpath=.
# exact sourcepath determination
# search first in current options
for (( i=1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == -sourcepath ]]; then
sourcepath=${COMP_WORDS[i+1]}
[ -z "$sourcepath" ] && _java_find_classpath
# available classes completion
# find which classpath to use
# convert package syntax to path syntax
# parse each classpath element for classes
for i in ${classpath//:/ }; do
if [ -r $i ] && [[ "$i" == *.@(jar|zip) ]]; then
COMPREPLY=( "${COMPREPLY[@]}" $( zipinfo -1 \
"$i" | grep "^$cur" | grep '\.class$' | \
COMPREPLY=( "${COMPREPLY[@]}" $( jar tf "$i" \
"$cur" | grep "\.class$" | grep -v "\\$" ) )
COMPREPLY=( "${COMPREPLY[@]}" $( find "$i" -type f \
grep -v "\\$" | sed -e "s|^$i/||" ) )
COMPREPLY=( ${COMPREPLY[@]%.class} )
# convert path syntax to package syntax
COMPREPLY=( ${COMPREPLY[@]//\//.} )
# available packages completion
# find wich sourcepath to use
# convert package syntax to path syntax
# parse each sourcepath element for packages
for i in ${sourcepath//:/ }; do
COMPREPLY=( "${COMPREPLY[@]}" $( command ls -F -d \
$i/$cur* 2>
/dev/null | sed -e 's|^'$i'/||' ) )
COMPREPLY=( $( echo "${COMPREPLY[@]}" | tr " " "\n" | grep "/$" ) )
# remove packages extension
COMPREPLY=( ${COMPREPLY[@]%/} )
# convert path syntax to package syntax
cur=${COMPREPLY[@]//\//.}
prev=${COMP_WORDS[COMP_CWORD-1]}
for ((i=1; i < $COMP_CWORD; i++)); do
case ${COMP_WORDS[$i]} in
((i++)) # skip the classpath string.
# once we've seen a class, just do filename completion
if [[ "$cur" == -* ]]; then
# relevant options completion
COMPREPLY=( $( compgen -W '-client -hotspot -server -classic \
-cp -classpath -D -verbose -verbose:class \
-verbose:gc -version:jni -version \
-showversion -? -help -X -jar \
-ea -enableassertions -da -disableassertions \
-esa -enablesystemassertions \
-dsa -disablesystemassertions ' -- $cur ) )
if [[ "$prev" == -jar ]]; then
complete -F _java $filenames java
prev=${COMP_WORDS[COMP_CWORD-1]}
-@(overview|helpfile|stylesheetfile))
-@(classpath|bootclasspath|docletpath|sourcepath|extdirs))
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' -- \
# source files completion
complete -F _javadoc $filenames javadoc
prev=${COMP_WORDS[COMP_CWORD-1]}
-@(classpath|bootclasspath|sourcepath|extdirs))
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 ) )
# source files completion
complete -F _javac $filenames javac
# PINE address-book completion
COMPREPLY=( $( compgen -W '$( awk "{print \$1}" ~/.addressbook 2>
/dev/null)' \
complete -F _pineaddr $default pine
# 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.
have mutt || have muttng && {
newconffiles=( $(sed -rn 's|^source[[:space:]]+([^[:space:]]+).*$|\1|p' $(eval echo $1) ) )
for file in "${newconffiles[@]}"; do
[[ ! "$file" ]] || [[ "${sofar/ ${file} / }" != "$sofar" ]] &&
sofar=" $(eval _muttconffiles \"$sofar\" $file) "
local -a conffiles aliases
[ -f ~/.${muttcmd}/${muttcmd}rc ] && muttrc="~/.${muttcmd}/${muttcmd}rc"
[ -f ~/.${muttcmd}rc ] && muttrc="~/.${muttcmd}rc"
[ -z "$muttrc" ] && return 0
conffiles=( $(eval _muttconffiles $muttrc $muttrc) )
aliases=( $( sed -rn 's|^alias[[:space:]]+([^[:space:]]+).*$|\1|p' \
$(eval echo "${conffiles[@]}") ) )
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${aliases[*]}" -- $cur ) )
querycmd="$( $muttcmd -Q query_command | sed -r 's|^query_command=\"(.*)\"$|\1|; s|%s|'$cur'|' )"
if [ -z "$cur" -o -z "$querycmd" ]; then
queryresults=( $( $querycmd | \
sed -nr '2,$s|^([^[:space:]]+).*|\1|p' ) )
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${queryresults[*]}" \
local cur folder spoolfile
# This is currently not working so well. Perhaps this function should
# just call _filedir() for the moment.
if [[ $cur == [=+]* ]]; then
folder="$( $muttcmd -Q folder | sed -r 's|^folder=\"(.*)\"$|\1|' )"
# Match any file in $folder beginning with $cur
# (minus the leading '=' sign).
COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) )
COMPREPLY=( ${COMPREPLY[@]#$folder/} )
elif [ "$cur" == !* ]; then
spoolfile="$( $muttcmd -Q spoolfile | sed -r 's|^spoolfile=\"(.*)\"$|\1|' )"
[ ! -z "$spoolfile" ] && eval cur="${cur/^!/$spoolfile}";
prev=${COMP_WORDS[COMP_CWORD-1]}
[ ${COMP_WORDS[0]} == muttng ] && muttcmd="muttng" || muttcmd="mutt"
COMPREPLY=( $( compgen -W '-A -a -b -c -e -f -F -H -i -m -n \
-p -Q -R -s -v -x -y -z -Z -h' \
-@(e|m|Q|s|h|p|R|v|y|z|Z))
complete -F _mutt $default $filenames mutt muttng
# if $COMP_CONFIGURE_HINTS is not null, then completions of the form
# --option=SETTING will include 'SETTING' as a contextual hint
[[ "$cur" != -* ]] && return 0
if [ -n "$COMP_CONFIGURE_HINTS" ]; then
COMPREPLY=( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' | grep ^$cur ) )
COMPREPLY=( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,=].*//g' | grep ^$cur ) )
complete -F _configure_func $default configure
# Debian reportbug(1) completion
prev=${COMP_WORDS[COMP_CWORD-1]}
-f|--filename|-i|--include|--mta|-o|--output)
COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \
COMP_WORDS=(COMP_WORDS[0] $cur)
COMPREPLY=( $( compgen -W "novice standard expert" -- $cur ) )
COMPREPLY=( $( compgen -W "grave serious important normal \
minor wishlist" -- $cur ) )
COMPREPLY=( $( compgen -W "newt text gnome" -- $cur ) )
COMPREPLY=( $( compgen -W "gnats debbugs" -- $cur ) )
COMPREPLY=( $( compgen -W "none patch security upstream sid \
woody potato sarge fixed" -- $cur ))
COMPREPLY=($( compgen -W '-h --help -v --version -a --af -b \
--no-query-bts --query-bts -B --bts -c --configure \
--no-config-files --check-available -d --debug \
--no-check-available -e --editor --email -f \
--filename -g --gnupg -H --header -i --include -j \
--justification -l --ldap --no-ldap -L --list-cc -m \
--maintonly --mode --mua --mta --mutt -n --mh --nmh \
-o --output -p --print -P --pgp --proxy --http_proxy\
-q --quiet -Q --query-only --realname --report-quiet \
--reply-to --replyto -s --subject -S --severity \
--smtphost -t --type -T --tags --template -V -x \
--no-cc --package-version -z --no-compress \
wnpp boot-floppies kernel-image' -- $cur ) \
$( apt-cache pkgnames -- $cur 2>
/dev/null ) )
complete -F _reportbug $filenames reportbug
# Debian querybts(1) completion
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \
COMPREPLY=($( compgen -W "newt text gnome" -- $cur ))
COMPREPLY=($( compgen -W '-h --help -v --version -A --archive \
-B --bts -l --ldap --no-ldap --proxy= --http_proxy= \
-s --source -w --web -u --ui --interface \
wnpp boot-floppies' -- $cur ) \
$( apt-cache pkgnames -- $cur 2>
/dev/null ) )
complete -F _querybts $filenames querybts
# update-alternatives completion
have update-alternatives && {
for (( i=1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == --admindir ]]; then
admindir=${COMP_WORDS[i+1]}
COMPREPLY=( $( command ls $admindir | grep "^$cur" ) )
local cur prev mode args i
prev=${COMP_WORDS[COMP_CWORD-1]}
# find wich mode to use and how many real args used so far
for (( i=1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all) ]]; then
args=$(($COMP_CWORD - i))
COMPREPLY=( $( compgen -W '--verbose --quiet --help --version \
--altdir --admindir' -- $cur ) \
$( compgen -W '--install --remove --auto --display \
complete -F _update_alternatives update-alternatives
prev=${COMP_WORDS[COMP_CWORD-1]##*/}
COMPREPLY=( $( compgen -W "old new warn warnall" -- $cur ) )
COMPREPLY=( $( compgen -W "ignore default all module once error" -- $cur ) )
[[ ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]] && _filedir
# if '-c' is already given, complete all kind of files.
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
if [[ ${COMP_WORDS[i]} == -c ]]; then
if [[ "$cur" != -* ]]; then
COMPREPLY=( $( compgen -W "- -d -E -h -i -O -Q -S -t -u \
-U -v -V -W -x -c" -- $cur ) )
complete -F _python $filenames python
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 ) )
local cur prev prefix temp
prev=${COMP_WORDS[COMP_CWORD-1]}
# completing an option (may or may not be separated by a space)
if [[ "$cur" == -?* ]]; then
# only handle module completion for now
COMPREPLY=( $( compgen -d -P "$prev" -- "$cur" ) )
# handle case where first parameter is not a dash option
if [[ "${COMP_WORDS[COMP_CWORD]}" != -* ]]; then
# complete using basic options
COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p \
-n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) )
complete -F _perl $filenames perl
local cur prev prefix temp
prev=${COMP_WORDS[COMP_CWORD-1]}
# completing an option (may or may not be separated by a space)
if [[ "$cur" == -?* ]]; then
# complete builtin perl functions
COMPREPLY=( $( compgen -W 'chomp chop chr crypt hex index lc \
lcfirst length oct ord pack q qq reverse rindex sprintf \
substr tr uc ucfirst y m pos quotemeta s split study qr abs \
atan2 cos exp hex int log oct rand sin sqrt srand pop push \
shift splice unshift grep join map qw reverse sort unpack \
delete each exists keys values binmode close closedir \
dbmclose dbmopen die eof fileno flock format getc print \
printf read readdir rewinddir seek seekdir select syscall \
sysread sysseek syswrite tell telldir truncate warn write \
pack read syscall sysread syswrite unpack vec -X chdir chmod \
chown chroot fcntl glob ioctl link lstat mkdir open opendir \
readlink rename rmdir stat symlink umask unlink utime caller \
continue do dump eval exit goto last next redo return \
sub wantarray caller import local my our package use defined \
formline reset scalar undef \
alarm exec fork getpgrp getppid getpriority kill pipe qx \
setpgrp setpriority sleep system times wait waitpid \
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 ) )
COMPREPLY=( $( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- $cur ))
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '$( PAGER=cat man perl 2>
/dev/null | sed -ne "/perl.*Perl overview/,/perlwin32/s/^[^a-z0-9]*\([a-z0-9]*\).*$/\1/p")' -- $cur ) )
complete -F _perldoc $default perldoc
local cur prev file dir i
prev=${COMP_WORDS[COMP_CWORD-1]}
# 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=( "${COMPREPLY[@]}" $( compgen -G "$dir/$file*,v" ) )
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[$i]=${COMPREPLY[$i]%,v}
# default to files if nothing returned and we're checking in.
# otherwise, default to directories
[ ${#COMPREPLY[@]} -eq 0 -a $1 = ci ] && _filedir || _filedir -d
complete -F _rcs $filenames ci co rlog rcs rcsdiff
COMPREPLY=( $( awk -F'=' '/label/ {print $2}' \
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'help ChRul EBDA geom geom= \
table= video' -- $cur ) )
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' -- \
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 ) )
COMPREPLY=( $( compgen -W '$( < ~/.links/
links.his )' \
complete -F _links $filenames links
[ $UNAME = FreeBSD ] && {
# FreeBSD package management tool completion
prev=${COMP_WORDS[COMP_CWORD-1]}
[ "$prev" = "-o" -o "$prev" = "-p" -o "$prev" = "-W" ] && return 0
COMPREPLY=( $( compgen -d $pkgdir$cur ) )
COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
complete -F _pkg_delete $dirnames pkg_delete pkg_info
have pkg_deinstall && complete -F _pkg_delete $dirnames pkg_deinstall
# FreeBSD kernel module commands
COMPREPLY=( $( compgen -f $moddir$cur ) )
COMPREPLY=( ${COMPREPLY[@]#$moddir} )
COMPREPLY=( ${COMPREPLY[@]%.ko} )
complete -F _kldload $filenames kldload
COMPREPLY=( $(kldstat | sed -ne "s/^.*[ \t]\+\($cur[a-z_]\+\).ko$/\1/p") )
complete -F _kldunload $filenames kldunload
# FreeBSD portupgrade completion
prev=${COMP_WORDS[COMP_CWORD-1]}
[ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0
COMPREPLY=( $( compgen -d $pkgdir$cur ) )
COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
COMPREPLY=( ${COMPREPLY[@]%-*} )
complete -F _portupgrade $dirnames portupgrade
# FreeBSD portinstall completion
local cur portsdir prev indexfile
prev=${COMP_WORDS[COMP_CWORD-1]}
# Then INDEX if INDEX-5 does not exist or system is not FreeBSD
5.x [ "${OSTYPE%.*}" = "freebsd5" -a -f $indexfile ] ||
[ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0
COMPREPLY=( $( egrep "^$cur" < $indexfile | cut -d'|' -f1 ) )
COMPREPLY2=( $( egrep "^[^\|]+\|$portsdir$cur" < $indexfile | \
COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
COMPREPLY=( "${COMPREPLY[@]}" "${COMPREPLY2[@]}" )
complete -F _portinstall $dirnames portinstall
# Slackware Linux removepkg completion
complete -F _removepkg $filenames removepkg &&
complete $dirnames -f -X '!*.tgz' installpkg upgradepkg explodepkg
if [ $COMP_CWORD = 1 ]; then
COMPREPLY=( $( compgen -W '$(look $cur)' ) )
complete -F _look $default look
# ypcat(1) and ypmatch(1) completion
[ $1 = ypcat ] && [ $COMP_CWORD -gt 1 ] && return 0
[ $1 = ypmatch ] && [ $COMP_CWORD -gt 2 ] && return 0
if [ $1 = ypmatch ] && [ $COMP_CWORD -eq 1 ] && \
[ ${#COMP_WORDS[@]} -eq 3 ]; then
COMPREPLY=( $( compgen -W '$( ypcat $map | \
cut -d':' -f 1 )' -- $cur) )
[ $1 = ypmatch ] && [ $COMP_CWORD -ne 2 ] && return 0
COMPREPLY=( $( compgen -W \
'$( echo $(ypcat -x | cut -d"\"" -f 2))' -- $cur))
complete -F _ypmatch ypmatch ypcat
sed -e '1,/^Available/d' | awk '{print $1}' | \
sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' | \
local cmd cur prev skinsdir IFS=$' \t\n' i j k=0
prev=${COMP_WORDS[COMP_CWORD-1]}
-@(ac|afm|vc|vfm|ao|vo|vop|fstype))
_mplayer_options_list mplayer $prev
_mplayer_options_list mencoder $prev
_filedir '@(mp3|MP3|mpg|MPG|ogg|OGG|wav|WAV|mid|MID|flac|FLAC|mka|MKA)'
_filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js|ssa|SSA|aas|AAS)'
_filedir '@(idx|IDX|ifo|IFO|sub|SUB)'
COMPREPLY=( $( for i in "${COMPREPLY[@]}"; do
if [ -f $i -a -r $i ]; then
_filedir '@(bin|BIN|cue|CUE)'
# if you don't have installed mplayer in /usr you
# may want to set the MPLAYER_SKINS_DIR global variable
if [ -n "$MPLAYER_SKINS_DIR" ]; then
skinsdir=$MPLAYER_SKINS_DIR
for i in ~/.mplayer/Skin $skinsdir; do
if [ -d $i -a -r $i ]; then
for j in $( compgen -d $i/$cur ); do
-@(mixer|@(cdrom|dvd)-device|dvdauth|fb|zrdev))
-@(edl?(out)|lircconf|menu-cfg|playlist|csslib|dumpfile)| \
-@(subfile|vobsub|aofile|fbmodeconfig|include|o|dvdkey)| \
-@(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)| \
-@(monitor@(aspect|-@(dotclock|[hv]freq))|panscan|saturation)| \
-@(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)))
COMPREPLY=( $( compgen -W 'ec er= bug= idct= gray' \
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' \
COMPREPLY=( $( compgen -W 'lgb= cgb= ls= cs= chs= \
COMPREPLY=( $( compgen -W 'noprogressive progressive \
nobaseline baseline optimize= \
smooth= quality= outdir=' -- $cur ) )
COMPREPLY=( $( compgen -W 'dr2 nodr2' -- $cur ) )
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 ) )
COMPREPLY=( $( compgen -W 'br= key= deinterlace q= \
min_quant= max_quant= rc_period= \
rc_reaction_period= crispness= \
rc_reaction_ratio= pass= vbrpass= \
COMPREPLY=( $( compgen -W 'name= artist= genre= \
subject= copyright= srcform= \
comment= help' -- $cur ) )
COMPREPLY=( $( compgen -W 'vbr= abr cbr br= q= aq= \
ratio= vol= mode= padding= fast \
preset= help' -- $cur ) )
COMPREPLY=( $( compgen -W 'on channels= rate= \
samplesize= format=' -- $cur ) )
COMPREPLY=( $( compgen -W 'on fps= sqcif qcif cif \
4cif pal ntsc w= h= y420 yv12 yuy2 \
y8 format= size=' -- $cur ) )
COMPREPLY=( $( compgen -W 'list= delay= format= fout= \
volume= mul= softclip' -- $cur ) )
COMPREPLY=( $( compgen -W 'ar-mode= iec958-encoded \
iec958-decoded mute ucode= 75ire bw \
color interlaced macrovision= norm= \
square-pixel ccir601-pixel cr-left= \
cr-right= cr-top= cr-bot= ck-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 \
overlay-ratio= update-cache' -- $cur ))
COMPREPLY=( $( compgen -W 'on noaudio driver= device= \
input= freq= outfmt= width= height= \
buffersize= norm= channel= chanlist= \
audiorate= forceaudio alsa amode= \
forcechan= adevice= audioid= volume= \
bass= treble= balance= fps= \
channels= immediatemode=' -- $cur ) )
COMPREPLY=( $( compgen -W 'on w= h= fps= type=' \
COMPREPLY=( $( compgen -W 'speed= paranoia= \
generic-dev= sector-size= overlap= \
toc-bias toc-offset= skip noskip' \
COMPREPLY=( $( compgen -W 'conf= ar-delay ar-rate \
keylist cmdlist js-dev file' -- $cur ) )
COMPREPLY=( $( compgen -W 'resample resample= \
channels channels= format format= \
volume volume= delay delay= pan \
pan= sub sub= surround surround=' \
COMPREPLY=( $( compgen -W 'force= list=' -- $cur ) )
COMPREPLY=( $( compgen -W '-aid -alang -audio-demuxer \
-audiofile -cdrom-device -cache -cdda \
-channels -chapter -csslib -demuxer \
-dvd -dvd-device -dvdangle -dvdauth \
-dvdkey -dvdnav -forceidx -fps -frames \
-hr-mp3-seek -idx -mc -mf -ni -nobps \
-passwd -rawaudio -rtsp-stream-over-tcp\
-skipopening -sb -srate -ss -tv -user \
-vcd -vid -vivo -ifo -ffactor -font \
-noautosub -nooverlapsub -sid -slang \
-sub -subcc -subcp -sub-demuxer \
-subdelay -subfont-autoscale \
-subfont-blur -subfont-encoding \
-subfont-osd-scale -subfont-outline \
-subfont-text-scale -subfps -subfile \
-subpos -unicode -utf8 -vobsub \
-vobsubid -ac -afm -aspect -flip \
-lavdopts -noaspect -nosound -pp -ssf \
-stereo -sws -vc -vfm -vop -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 \
# add mplayer specific options
[[ "$cmd" == @(?(g)mplayer) ]] && COMPREPLY=( "${COMPREPLY[@]}" \
$(compgen -W '-autoq -autosync -benchmark \
-framedrop -h -help -hardframedrop \
-identify -input -lircconf -loop \
-nojoystick -nolirc -nortc -playlist \
-quiet -really-quiet -rnd -sdp -skin \
-slave -softsleep -speed -sstep \
-use-stdin -dumpaudio -dumpfile \
-dumpstream -dumpvideo -dumpmicrodvdsub\
-dumpmpsub -dumpsrtsub -dumpjacosub \
-dumpsami -dumpsub -osdlevel -af \
-af-adv -ao -aofile -aop -delay -mixer \
-nowaveheader -bpp -brightness \
-contrast -display -double -dr -dxr2 \
-fb -fbmode -fbmodeconfig -forcexv -fs \
-geometry -hue -icelayer -jpeg \
-monitor-dotclock -monitor-hfreq \
-monitor-vfreq -monitoraspect \
-nograbpointer -noslices -panscan \
-rootwin -saturation -screenw -screenh \
-stop-xscreensaver -vm -vo -vsync -wid \
-xineramascreen -z -zrbw -zrcrop \
-zrdev -zrfd -zrhelp -zrnorm -zrquality \
-zrvdec -zrhdec -zrxdoff -zrydoff -y \
-edl -edlout -enqueue -fixed-vo \
-menu -menu-root -menu-cfg -shuffle \
-format -aahelp -dfbopts -fstype \
-guiwid -nokeepaspect -x --help \
-aaosdcolor -aasubcolor -aadriver \
-aaextended -aaeight' -- $cur) )
# add mencoder specific options
[[ "$cmd" = mencoder ]] && COMPREPLY=( "${COMPREPLY[@]}" \
$(compgen -W '-audio-density -audio-delay \
-audio-preload -divx4opts -endpos \
-ffourcc -include -info -lameopts \
-lavcopts -noskip -o -oac -ofps -ovc \
-passlogfile -skiplimit -vobsubout \
-vobsuboutindex -vobsuboutid \
-xvidencopts -of --verbose' -- $cur) )
_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|fli|FLI|flv|FLV|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[34]|MP[34]|m4v|M4V|og[gm]|OG[GM]|wav|WAV|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|ts|TS|3gp|mpc|MPC|flac|FLAC|flv|FLV|divx|DIVX)'
complete $filenames -F _mplayer mplayer mencoder gmplayer kplayer
compstr=$( command echo ${COMP_WORDS[*]} | sed "s/ $cur$//" )
COMPREPLY=( $( compgen -W '$( command $compstr | sed s/\(.*\)// )' -- $cur ) )
local cur prev config i IFS=$'\t\n'
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W '--config --chat \
--remotename --help --version --no-syslog' \
# start with global and personal config files
# replace with command line config file if present
for (( i=1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == "--config" ]]; then
config=${COMP_WORDS[i+1]}
# parse config files for sections and
"s|^\[Dialer \($cur.*\)\]$|\1|p" \
COMPREPLY=${COMPREPLY// /\\ }
complete -F _wvdial wvdial
prev=${COMP_WORDS[COMP_CWORD-1]}
-@(s|-sign|-clearsign|-decrypt-files|-load-extension))
--@(export|@(?(l|nr|nrl)sign|edit)-key))
# return list of public keys
COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>
/dev/null | sed -ne 's@^pub.*/\([^ ]*\).*\(<\([^>]*\)>\).*$@\1 \3@p')" -- "$cur" ))
COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>
/dev/null | sed -ne 's@^pub.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ))
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/
gpg.conf )" -- "$cur") )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-s -b -e -f -c -d -a -r -u -Z -o -v\
-q -n -N $(gpg --dump-options)' -- $cur ) )
complete -F _gpg $default gpg
prev=${COMP_WORDS[COMP_CWORD-1]}
-@(f|t|-@(from|to)-code))
COMPREPLY=( $( compgen -W \
'$( iconv --list | sed -e "s@//@@;" )' -- "$cur" ) )
if [[ "$cur" = -* ]]; then
COMPREPLY=( $( compgen -W '--from-code -f --to-code -t --list
--output -o --verbose' -- "$cur" ) )
complete -F _iconv $default iconv
{ have dict || have rdict; } && {
's/^['$'\t '']['$'\t '']*\([^'$'\t '']*\).*$/\1/p'
local cur prev host port db dictfile
prev=${COMP_WORDS[COMP_CWORD-1]}
for (( i=1; i < COMP_CWORD; i++ )); do
case "${COMP_WORDS[i]}" in
[ -n "$host" ] && host="-h $host"
[ -n "$port" ] && port="-p $port"
[ -n "$db" ] && host="-d $db"
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' \
COMPREPLY=( $( compgen -W '$( _dictdata -D )' -- "$cur" ) )
COMPREPLY=( $( compgen -W '$( _dictdata -S )' -- "$cur" ) )
COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) )
complete -F _dict $default dict rdict
local cur prev i generic_options track_options track_mode
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == *=* ]]; then
COMPREPLY=( $( compgen -W 'help all fast \
track unreserve trtail unclose session' \
COMPREPLY=( $( compgen -W 'burnfree noburnfree\
varirec= audiomaster forcespeed noforcespeed\
speedread nospeedread singlesession \
nosinglesession hidecdr nohidecdr tattooinfo\
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= \
# look if previous was either a file or a track option
if [ $COMP_CWORD -gt 1 ]; then
for (( i=0; i < ${#track_options[@]}; i++ )); do
if [[ "${track_options[i]}" == "$prev" ]]; then
# files are always eligible completion
# track options are always available
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '${track_options[@]}' -- $cur ) )
# general options are no more available after file or track option
if [ $track_mode -eq 0 ]; then
COMPREPLY=( "${COMPREPLY[@]}" \
$( compgen -W '${generic_options[@]}' -- $cur ) )
complete -F _cdrecord $filenames cdrecord
prev=${COMP_WORDS[COMP_CWORD-1]}
-@(o|abstract|biblio|check-session|copyright|log-file|root-info|prep-boot|*-list))
COMPREPLY=( $( mkisofs -input-charset help 2>&1 | \
tail +3 | grep "^$cur") )
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 \
-dvd-video -f -file-mode -gid -gui \
-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 ))
complete -F _mkisofs $filenames mkisofs
prev=${COMP_WORDS[COMP_CWORD-1]}
# -name value style option
# --name=value style option
if [[ "$cur" == *=* ]]; then
--@(edit|view|ftplog|printwd))
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 ) )
complete -F _mc $filenames mc
prev=${COMP_WORDS[COMP_CWORD-1]}
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
if [[ ${COMP_WORDS[i]} == @(install|update|upgrade|remove|erase|deplist) ]]; then
if [ -n "$special" ]; then
COMPREPLY=( $( compgen -W '$( yum -C list | cut -d" " -f1 )' -- $cur ) )
COMPREPLY=( $( compgen -W '--installroot --version --help --enablerepo --disablerepo --exclude --obsoletes --noplugins' -- $cur ) )
COMPREPLY=( $( compgen -W '-c -e -d -y -t -R -C -h' -- $cur ) )
COMPREPLY=( $( compgen -W 'all available updates installed extras obsoletes recent' -- $cur ) )
COMPREPLY=( $( compgen -W 'packages headers metadata cache dbcache all' -- $cur ) )
COMPREPLY=( $( compgen -W 'install update check-update upgrade remove list \
search info provides clean groupinstall groupupdate \
grouplist deplist erase groupinfo groupremove \
localinstall localupdate makecache resolvedep \
shell whatprovides' -- $cur ) )
complete -F _yum $filenames yum
COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l -q' -- $cur ) )
complete -F _yum_arch $filenames yum-arch
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'Red Green Blue Opacity \
Matte Cyan Magenta Yellow Black' -- $cur ) )
COMPREPLY=( $( compgen -W 'shared private' -- $cur ) )
COMPREPLY=( $( compgen -W 'GRAY OHTA RGB Transparent \
XYZ YCbCr YIQ YPbPr YUV CMYK' -- $cur ) )
COMPREPLY=( $( compgen -W 'Over In Out Atop Xor Plus \
Minus Add Subtract Difference Multiply Bumpmap\
Copy CopyRed CopyGreen CopyBlue CopyOpacity' \
COMPREPLY=( $( compgen -W 'None BZip Fax Group4 JPEG \
Lossless LZW RLE Zip' -- $cur ) )
COMPREPLY=( $( compgen -W 'Undefined None Background \
COMPREPLY=( $( compgen -W 'AdobeCustom AdobeExpert \
AdobeStandard AppleRoman BIG5 GB2312 Latin2 \
None SJIScode Symbol Unicode Wansung' -- $cur))
COMPREPLY=( $( compgen -W 'MSB LSB' -- $cur ) )
COMPREPLY=( $( compgen -W 'Point Box Triangle Hermite \
Hanning Hamming Blackman Gaussian Quadratic \
Cubic Catrom Mitchell Lanczos Bessel Sinc' \
COMPREPLY=( $( convert -list format | \
awk '/ [r-][w-][+-] / {print $1}' | \
tr -d '*' | tr [:upper:] [:lower:] | \
COMPREPLY=( $( compgen -W 'Northwest North NorthEast \
West Center East SouthWest South SouthEast' \
COMPREPLY=( $( compgen -W 'Absolute Perceptual \
Relative Saturation' -- $cur ) )
COMPREPLY=( $( compgen -W 'None Line Plane Partition' \
COMPREPLY=( $( compgen -W 'Disk File Map Memory' \
COMPREPLY=( $( compgen -W 'Delegate Format Magic \
Module Resource Type' -- $cur ) )
COMPREPLY=( $( compgen -W 'best default gray red \
COMPREPLY=( $( compgen -W 'Uniform Gaussian \
Impulse Laplacian Poisson' -- $cur ) )
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' \
-@(mask|profile|texture|tile|write))
COMPREPLY=( $( compgen -W 'Bilevel Grayscale Palette \
PaletteMatte TrueColor TrueColorMatte \
ColorSeparation ColorSeparationlMatte \
COMPREPLY=( $( compgen -W 'Undefined PixelsPerInch \
PixelsPerCentimeter' -- $cur ) )
COMPREPLY=( $( compgen -W 'Constant Edge mirror tile' \
COMPREPLY=( $( compgen -W 'StaticGray GrayScale \
StaticColor PseudoColor TrueColor \
DirectColor defaut visualid' -- $cur ))
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-adjoin -affine -antialias -append \
-authenticate -average -background -black-threshold \
-blue-primary -blur -border -bordercolor -channel \
-charcoal -chop -clip -coalesce -colorize -colors \
-colorspace -comment -compress -contrast -convolve \
-crop -cycle -debug -deconstruct -delay -density \
-depth -despeckle -display -dispose -dither -draw \
-edge -emboss -encoding -endian -enhance -equalize \
-extract -fill -filter -flatten -flip -flop -font \
-frame -fuzz -gamma -gaussian -geometry \
-green-primary -gravity -help -implode -intent \
-interlace -label -lat -level -limit -list -log -loop \
-map -mask -matte -median -modulate -monochrome \
-morph -mosaic -negate -noop -noise -normalize \
-opaque -ordered-dither -page -paint -ping -pointsize \
-preview -profile -quality -raise -random-threshold \
-region -raise -red-primary -render -resize -resample \
-roll -rotate -sample -sampling-factor -scale -scene \
-seed -segment -shade -sharpen -shave -shear -size \
-solarize -spread -stroke -strokewidth -swirl \
-texture -threshold -thumbnail -tile -transform \
-transparent -treedepth -trim -type -undercolor \
-units -unsharp -verbose -version -view \
-virtual-pixel -wave -white-point -white-threshold \
elif [[ "$cur" == +* ]]; then
COMPREPLY=( $( compgen -W '+adjoin +append +compress \
+contrast +debug +dither +endian +gamma +label +map \
+mask +matte +negate +noise +page +raise +render \
complete -F _convert $filenames convert
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-affine -antialias -authenticate \
-background -black-threshold -blue-primary -blur \
-border -bordercolor -channel -charcoal -chop \
-colorize -colors -colorspace -comment -compress \
-contrast -convolve -crop -cycle -debug -delay \
-density -depth -despeckle -display -dispose -dither \
-draw -edge -emboss -encoding -endian -enhance \
-equalize -extract -fill -filter -flip -flop -font \
-format -frame -fuzz -gamma -gaussian -geometry \
-green-primary -implode -interlace -help -label -lat \
-level -limit -list -log -loop -map -mask -matte \
-median -modulate -monochrome -negate -noop \
-normalize -opaque -page -paint -fill -ordered-dither \
-pointsize -profile -quality -raise -random-threshold \
-red-primary -region -resample -resize -roll -rotate \
-sample -sampling-factor -scale -scene -seed -segment \
-shade -sharpen -shear -size -solarize -spread \
-stroke -strokewidth -swirl -texture -threshold \
-thumbnail -tile -transform -transparent -treedepth \
-trim -type -undercolor -units -unsharp -verbose \
-version -view -virtual-pixel -wave -white-point \
-white-threshold' -- $cur ) )
elif [[ "$cur" == +* ]]; then
COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
+endian +gamma +label +map +mask +matte +negate +page \
complete -F _mogrify $filenames mogrify
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-authenticate -backdrop -border \
-colormap -colors -colorspace -comment -compress \
-contrast -crop -debug -delay -density -depth \
-despeckle -display -dispose -dither -edge -endian \
-enhance -extract -filter -flip -flop -frame -gamma \
-geometry -help -immutable -interlace -label -limit \
-log -map -matte -monochrome -negate -noop -page \
-quality -raise -remote -roll -rotate -sample \
-sampling-factor -scene -segment -sharpen -size \
-texture -treedepth -trim -update -verbose -version \
-virtual-pixel -window -window_group -write' -- $cur))
elif [[ "$cur" == +* ]]; then
COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
+endian +gamma +label +map +matte +negate +page \
+raise +write' -- $cur ) )
complete -F _display $filenames display
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-authenticate -backdrop -colormap \
-colors -colorspace -crop -debug -delay -density \
-depth -display -dither -extract -gamma -geometry \
-help -interlace -limit -log -matte -map -monochrome \
-noop -pause -remote -rotate -sampling-factor -scene \
-size -treedepth -trim -verbose -version -visual \
-virtual-pixel -window' -- $cur ) )
elif [[ "$cur" == +* ]]; then
COMPREPLY=( $( compgen -W '+debug +dither +gamma +map +matte' -- $cur ) )
complete -F _animate $filenames animate
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-authenticate -debug -density \
-depth -extract -format -help -interlace -limit -list \
-log -size -sampling-factor -verbose -version \
-virtual-pixel' -- $cur ) )
elif [[ "$cur" == +* ]]; then
COMPREPLY=( $( compgen -W '+debug ' -- $cur ) )
complete -F _identify $filenames identify
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-adjoin -affine -authenticate \
-blue-primary -blur -colors -colorspace -comment \
-compose -compress -crop -debug -density -depth \
-display -dispose -dither -draw -encoding -endian \
-extract -fill -filter -flip -flop -frame -gamma \
-geometry -gravity -green-primary -interlace -help \
-label -limit -log -matte -mode -monochrome -noop \
-page -pointsize -quality -red-primary -resize \
-rotate -sampling-factor -scene -shadow -size \
-stroke -texture -thumbnail -tile -transform \
-transparent -treedepth -trim -type -verbose \
-version -virtual-pixel -white-point' -- $cur ) )
elif [[ "$cur" == +* ]]; then
COMPREPLY=( $( compgen -W '+adjoin +compress +debug +dither \
+endian +gamma +label +matte +page' -- $cur ) )
complete -F _montage $filenames montage
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-affine -authenticate \
-blue-primary -colors -colorspace -comment -compose \
-compress -debug -density -depth -displace -display \
-dispose -dissolve -dither -encoding -endian -extract \
-filter -font -geometry -gravity -green-primary -help \
-interlace -label -limit -log -matte -monochrome \
-negate -page -profile -quality -red-primary -rotate \
-resize -sampling-factor -scene -sharpen -size \
-stegano -stereo -thumbnail -tile -transform \
-treedepth -type -units -unsharp -verbose -version \
-virtual-pixel -watermark -white-point -write' \
elif [[ "$cur" == +* ]]; then
COMPREPLY=( $( compgen -W '+compress +debug +dither +endian +label \
+matte +negate +page +write' -- $cur ) )
complete -F _composite $filenames composite
COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock \
lcase notrunc ucase swab noerror sync' \
COMPREPLY=( $( compgen -W '--help --version' -- $cur ) \
$( compgen -W 'bs cbs conv count ibs if obs of seek skip'\
complete -F _dd $nospace $filenames dd
# CUPS cancel(1) completion
COMPREPLY=( $( lpstat | cut -d' ' -f1 | grep "^$cur" ) )
complete -F _cancel $filenames cancel
COMPREPLY=( $( command ls $datadir/*.@(multi|alias) ) )
COMPREPLY=( ${COMPREPLY[@]%.@(multi|alias)} )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]#$datadir/}' -- $cur ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
# --name value style option
COMPREPLY=( $( compgen -W 'master personal repl' -- $cur ) )
# --name=value style option
if [[ "$cur" == *=* ]]; then
--@(conf|personal|repl|per-conf))
--@(conf-dir|data-dir|dict-dir|home-dir|local-data-dir|prefix))
COMPREPLY=( $( compgen -W 'none url email sgml tex' -- $cur ) )
COMPREPLY=( $( compgen -W 'ultra fast normal bad-speller' -- $cur ) )
COMPREPLY=( $( compgen -W 'aspell ispell' -- $cur ) )
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 ) )
COMPREPLY=( $( compgen -W '-? help -c check -a pipe -l list \
config config soundslike filter -v version dump \
create merge' -- $cur ) )
complete -F _aspell $filenames aspell
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 ) )
_filedir '@(mp[23]|MP[23]|ogg|OGG|wav|WAV|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)'
complete -F _xmms $filenames xmms
# default completion if parameter contains /
if [[ "$cur" == */* ]]; then
if [ "${INFOPATH: -1:1}" == ':' ]; then
infopath=${INFOPATH}${infopath}
elif [ ${INFOPATH:+set} ]; then
infopath="${infopath//://$cur* }"
infopath="${infopath//:// }"
# 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[@]##*/?(:)} )
for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do
if [ "${COMPREPLY[$i]}" == 'dir' ]; then
# strip suffix from info pages
COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2)} )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
complete -F _info $filenames info
have dhclient && _dhclient()
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-p -d -q -1 -r -lf -pf \
-cf -sf -s -g -n -nw -w' -- $cur ) )
complete -F _dhclient dhclient
COMPREPLY=( $(compgen -W "$( vgscan 2>
/dev/null | \
sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- $cur ) )
COMPREPLY=( $(compgen -W "$( pvscan 2>
/dev/null | \
sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- $cur ) )
COMPREPLY=( $(compgen -W "$( lvscan 2>
/dev/null | \
sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- $cur ) )
COMPREPLY=( $( compgen -W 'h s b k m g t H K M G T' -- $cur ) )
COMPREPLY=( $( compgen -W 'k K m M g G t T' -- $cur ) )
if [[ "${COMP_WORDS[0]}" == lvm ]]; then
for (( i=$offset; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" != -* ]]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d --debug -h -? --help -l \
--lvmpartition -v --verbose --version' -- $cur ) )
complete -F _lvmdiskscan lvmdiskscan
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 ) )
complete -F _pvscan pvscan
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'pv_fmt pv_uuid \
pv_size pv_free pv_used pv_name \
pv_pe_alloc_count' -- $cur ) )
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 ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
-v --verbose -d --debug -h --help --version' -- $cur ) )
complete -F _pvdisplay pvdisplay
prev=${COMP_WORDS[COMP_CWORD-1]}
-@(A|x|-autobackup|--allocatable))
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a --all -A --autobackup \
-d --debug -h --help -t --test -u --uuid -x \
--allocatable -v --verbose --addtag --deltag \
complete -F _pvchange pvchange
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
COMPREPLY=( $( compgen -W '0 1 2' -- $cur ) )
--@(metadatasize|setphysicalvolumesize))
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 ) )
complete -F _pvcreate pvcreate
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
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 ) )
complete -F _pvmove pvmove
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d --debug -f --force -h -? \
--help -y --yes -t --test -v --verbose \
complete -F _pvremove pvremove
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d --debug -h --help \
--ignorelockingfailure --mknodes -P \
--partial -v --verbose --version' -- $cur ) )
complete -F _vgscan vgscan
prev=${COMP_WORDS[COMP_CWORD-1]}
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 \
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 ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
-P --partial -A --activevolumegroups -v --verbose \
-d --debug -h --help --version' -- $cur ) )
complete -F _vgdisplay vgdisplay
prev=${COMP_WORDS[COMP_CWORD-1]}
-@(a|A|x|-available|-autobackup|-resizeable))
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
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 ) )
complete -F _vgchange vgchange
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
-@(s|-physicalextentsize))
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 \
complete -F _vgcreate vgcreate
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d --debug -h --help -t --test \
-v --verbose --version' -- $cur ) )
complete -F _vgremove vgremove
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
-? --help -t --test -v --verbose --version' -- $cur ) )
complete -F _vgrename vgrename
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a --all -A --autobackup -d \
--debug -h --help --removemissing -t --test -v \
--verbose --version' -- $cur ) )
complete -F _vgreduce vgreduce
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
-? --help -t --test -v --verbose --version' -- $cur ) )
complete -F _vgextend vgextend
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a --all -d --debug -h \
-? --help -v --verbose --version' -- $cur ) )
complete -F _vgport vgimport vgexport
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d --debug -h \
-? --help -v --verbose --version' -- $cur ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
COMPREPLY=( $( compgen -W '0 1 2' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d --debug -h --help --labelsector \
-M --metadatatype --metadatacopies --metadatasize \
-t --test -v --verbose --version' -- $cur ) )
complete -F _vgconvert vgconvert
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d --debug -f --file -h --help \
--ignorelockingfailure -P --partial -v --verbose \
complete -F _vgcfgbackup vgcfgbackup
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d --debug -f --file -l --list \
-h --help -M --Metadatatype -n --name -t --test \
-v --verbose --version' -- $cur ) )
complete -F _vgcfgrestore vgcfgrestore
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-A --autobackup -d --debug \
-h --help -l --list -t --test -v --verbose \
complete -F _vgmerge vgmerge
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-A --autobackup -d --debug \
-h --help -l --list -M --metadatatype -t --test \
-v --verbose --version' -- $cur ) )
if [ $args -eq 0 -o $args -eq 1 ]; then
complete -F _vgsplit vgsplit
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d --debug -h --help -v --verbose \
complete -F _vgmknodes vgmknodes
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-b --blockdevice -d --debug \
-h -? --help --ignorelockingfailure -P \
--partial -v --verbose --version' -- $cur ) )
complete -F _lvscan lvscan
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'lv_uuid lv_name \
lv_attr lv_minor lv_size seg_count \
origin snap_percent segtype stripes \
stripesize chunksize seg_start \
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 ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
-P --partial -m --maps -v --verbose -d --debug -h \
--help --version' -- $cur ) )
complete -F _lvdisplay lvdisplay
prev=${COMP_WORDS[COMP_CWORD-1]}
-@(a|A|C|M|-available|-autobackup|-continguous|-persistent))
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
COMPREPLY=( $( compgen -W 'r rw' -- $cur ) )
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 ) )
complete -F _lvchange lvchange
prev=${COMP_WORDS[COMP_CWORD-1]}
-@(A|C|M|Z|-autobackup|-continguous|-persistent|-zero))
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
COMPREPLY=( $( compgen -W 'r rw' -- $cur ) )
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 \
complete -F _lvcreate lvcreate
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -f \
--force -h -? --help -t --test -v --verbose \
complete -F _lvremove lvremove
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
-? --help -t --test -v --verbose --version' -- $cur ) )
complete -F _lvrename lvrename
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
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 ) )
complete -F _lvreduce lvreduce
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
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 ) )
complete -F _lvresize lvresize
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
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 ) )
complete -F _lvextend lvextend
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 \
prev=${COMP_WORDS[COMP_CWORD-1]}
# --name value style option
# --name=value style option
if [[ "$cur" == *=* ]]; then
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' \
complete -F _mkinitrd mkinitrd
# pkgconfig(1) completion
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 \
--cflags-only-I --cflags-only-other --variable= \
--define-variable= --exists --uninstalled \
--atleast-version= --exact-version= --max-version= \
--list-all --debug --print-errors --silence-errors \
--errors-to-stdout -? --help --usage' -- $cur))
COMPREPLY=( $( pkg-config --list-all 2>
/dev/null | \
awk '{print $1}' | grep "^$cur" ) )
complete -F _pkg_config pkg-config
COMPREPLY=( $( compgen -W 'bin odc newc crc tar ustar hpbin hpodc' -- $cur ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
# --name value style option
# --name=value style option
if [[ "$cur" == *=* ]]; then
COMPREPLY=( $( compgen -c -- $cur ) )
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through' -- $cur) )
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\
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\
--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\
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\
--no-preserve-owner --sparse --help\
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a -g --group -G --groups -n --name\
-r --real -u --user --help --version' -- $cur ) )
COMPREPLY=( $( compgen -u $cur ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -u $cur ) )
COMPREPLY=( $( compgen -g $cur ) )
COMPREPLY=( $( compgen -s $cur ) )
COMPREPLY=( $( compgen -A hostname $cur ) )
COMPREPLY=( $( getent protocols | awk '{print $1}' | grep "^$cur" ) )
COMPREPLY=( $( getent networks | awk '{print $1}' | grep "^$cur" ) )
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W 'passwd group hosts services protocols networks' -- $cur ) )
complete -F _getent getent
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -u $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-4 -6 -b -B -d -Q -q -s -u -v -a\
-e -k -p -o -r -t' -- $cur ) )
complete -F _ntpdate ntpdate
COMPREPLY=( $( compgen -W 'errorsonly silent' -- $cur ) )
COMPREPLY=( $( compgen -W 'ata scsi 3ware' -- $cur ) )
COMPREPLY=( $( compgen -W 'warn exit ignore' -- $cur ) )
COMPREPLY=( $( compgen -W 'normal conservative permissive verypermissive' -- $cur ) )
COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- $cur ) )
COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
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 ) )
COMPREPLY=( $( compgen -W 'none samsung samsung2' -- $cur ) )
COMPREPLY=( $( compgen -W 'use ignore show showall' -- $cur ) )
COMPREPLY=( $( compgen -W 'offline short long conveyance select afterselect,on afterselect,off pending' -- $cur ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
# --name value style option
_smartctl_vendorattribute
# --name=value style option
if [[ "$cur" == *=* ]]; then
_smartctl_vendorattribute
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 ) )
complete -F _smartctl smartctl
# vncviewer(1) completion
prev=${COMP_WORDS[COMP_CWORD-1]}
# 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 ) )
complete -F _vncviewer vncviewer
COMPREPLY=( $( compgen -W "$(sysctl -N -a 2>
/dev/null)" -- $cur ) )
complete -F _sysctl sysctl
# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
local cur prev sysvdir services options valid_options
prev=${COMP_WORDS[COMP_CWORD-1]}
services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)) )
services=( ${services[@]#$sysvdir/} )
if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
echo "${COMP_WORDS[@]} ${options[@]}" \
| sed -ne "/$( echo "${options[@]}" | sed "s/ /\\|/g" )/p" \
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
if [[ "$cur" == [0-9] || -z "$cur" ]]; then
COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
elif [[ "$cur" == [0-9][0-9] ]]; then
elif [[ "$prev" == ?([0-9][0-9]|[0-6S]) ]]; then
if [[ $prev == [0-9][0-9] ]]; then
COMPREPLY=( 0 1 2 3 4 5 6 S )
COMPREPLY=( 0 1 2 3 4 5 6 S . )
elif [[ "$cur" == [0-6S.] ]]; then
elif [[ "$prev" == "." ]]; then
COMPREPLY=( $(compgen -W "start stop" -- $cur) )
# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
local cur prev sysvdir services options valid_options
prev=${COMP_WORDS[COMP_CWORD-1]}
services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)) )
services=( ${services[@]#$sysvdir/} )
options=( --help --quiet --force --try-anyway --disclose-deny --query --no-fallback )
if [[ ($COMP_CWORD -eq 1) || ("$prev" == --* ) ]]; then
echo ${COMP_WORDS[@]} ${options[@]} \
| sed -ne "/$( echo ${options[@]} | sed "s/ /\\\\|/g" )/p" \
COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- \
elif [ -x $sysvdir/$prev ]; then
COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-s -o -m -M -z -l -L -w -a -t \
-c -S -d -p -C -T -8' -- $cur ) )
complete -F _minicom minicom
local cur prev commands options command
commands='add blame praise annotate ann cat checkout co cleanup commit \
ci copy cp delete del remove rm diff di export help ? h import \
info list ls lock log merge mkdir move mv rename ren \
propdel pdel pd propedit pedit pe propget pget pg \
proplist plist pl propset pset ps resolved revert \
status stat st switch sw unlock update up'
if [[ $COMP_CWORD -eq 1 ]] ; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--version' -- $cur ) )
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W \
'$( iconv --list | sed -e "s@//@@;" )' \
--@(editor|diff|diff3)-cmd)
COMP_WORDS=(COMP_WORDS[0] $cur)
if [[ "$cur" == -* ]]; then
# possible options for the command
options='--auto-props --no-auto-props \
--force --targets --no-ignore \
--non-recursive -N -q --quiet'
@(blame|annotate|ann|praise))
options='-r --revisions --username \
--password --no-auth-cache \
--verbose --incremental --xml'
options='-r --revision --username \
--password --no-auth-cache \
options='-r --revision -q --quiet -N \
--non-recursive --username \
--password --no-auth-cache \
options='-m --message -F --file \
--encoding --force-log -q \
--quiet --non-recursive -N \
--non-interactive --no-unlock'
options='-m --message -F --file \
--encoding --force-log -r \
--password --no-auth-cache \
options='--force -m --message -F \
--file --encoding --force-log \
--password --no-auth-cache \
options='-r --revision -x --extensions \
--diff-cmd --no-diff-deleted \
-N --non-recursive --username \
--password --no-auth-cache \
--non-interactive --force \
--old --new --notice-ancestry'
options='-r --revision -q --quiet \
--non-recursive --force \
--native-eol --ignore-externals'
options='--auto-props --no-auto-props \
--encoding --force-log -q \
--quiet --non-recursive \
--no-ignore --editor-cmd \
options='--username --password \
--revision --xml --targets \
-R --recursive --incremental'
options='-r --revision -v --verbose -R \
--password --no-auth-cache \
options='-m --message -F --file \
--targets --force --username \
--password --no-auth-cache \
options='-r --revision -v --verbose \
--password --no-auth-cache \
--stop-on-copy --incremental \
--xml -q --quiet --limit'
options='-r --revision -N \
--non-recursive -q --quiet \
--force --dry-run --diff3-cmd \
options='-m --message -F --file \
--encoding --force-log -q \
options='-m --message -F --file \
--encoding --force-log -r \
options='-q --quiet -R --recursive -r \
options='-r --revision --revprop \
--encoding --editor-cmd \
--non-interactive --force'
options='-R --recursive -r --revision \
--revprop --strict --username \
--password --no-auth-cache \
options='-v --verbose -R --recursive \
-r --revision --revprop -q \
--quiet --username --password \
options='-F --file -q --quiet \
--targets -R --recursive \
options='--targets -R --recursive -q \
options='--targets -R --recursive -q \
options='-u --show-updates -v \
--verbose -N --non-recursive \
--password --no-auth-cache \
--non-interactive --no-ignore \
options='--relocate -r --revision -N \
--non-recursive -q --quiet \
--non-interactive --diff3-cmd'
options='--targets --force --username \
--password --no-auth-cache \
options='-r --revision -N \
--non-recursive -q --quiet \
--diff3-cmd --ignore-externals'
options="$options --help -h --config-dir"
COMPREPLY=( $( compgen -W "$options" -- $cur ) )
if [[ "$command" == @(help|h|\?) ]]; then
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
complete -F _svn $default svn
local cur prev commands options mode
commands='create deltify dump help ? hotcopy list-dblogs \
list-unused-dblogs load lslocks lstxns recover rmlocks \
if [[ $COMP_CWORD -eq 1 ]] ; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--version' -- $cur ) )
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $( compgen -W 'fsfs bdb' -- $cur ) )
if [[ "$cur" == -* ]]; then
# possible options for the command
options='--bdb-txn-nosync \
--bdb-log-keep --config-dir \
options='-r --revision -q --quiet'
options='-r --revision --incremental \
options='--ignore-uuid --force-uuid \
--parent-dir -q --quiet \
options='-r --revision --bypass-hooks'
options="$options --help -h"
COMPREPLY=( $( compgen -W "$options" -- $cur ) )
if [[ "$command" == @(help|h|\?) ]]; then
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
complete -F _svnadmin $default svnadmin
local cur prev commands options mode
commands='author cat changed date diff dirs-changed help ? h history \
info lock log propget pget pg proplist plist pl tree uuid \
if [[ $COMP_CWORD -eq 1 ]] ; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--version' -- $cur ) )
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
if [[ "$cur" == -* ]]; then
# possible options for the command
@(author|cat|date|dirs-changed|info|log))
options='-r --revision -t \
options='-r --revision -t \
--transaction --copy-info'
options='-r --revision -t \
options='-r --revision --show-ids'
options='-r --revision -t \
options='-r --revision -t \
--transaction --show-ids \
options="$options --help -h"
COMPREPLY=( $( compgen -W "$options" -- $cur ) )
if [[ "$command" == @(help|h|\?) ]]; then
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
complete -F _svnlook $default svnlook
# get first exclusion compspec that matches this command
xspec=$( sed -ne $'/^complete .*[ \t]'${1##*/}$'\([ \t]\|$\)/{p;q;}' \
# prune to leave nothing but the -X spec
[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
done < <( compgen -d -- "$(quote_readline "$cur")" )
[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
done < <( eval compgen -f -X $xspec -- "\$(quote_readline "\$cur")" )
COMPREPLY=( "${toks[@]}" )
list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' \
# read exclusion compspecs
# ignore compspecs that are commented out
if [ "${line#\#}" != "$line" ]; then continue; fi
line=${line%# START exclude*}
line=${line%# FINISH exclude*}
list=( "${list[@]}" $line )
# remove previous compspecs
if [ ${#list[@]} -gt 0 ]; then
eval complete -r ${list[@]}
eval complete -F _filedir_xspec $filenames "${list[@]}"
# source completion directory definitions
if [ -d $BASH_COMPLETION_DIR -a -r $BASH_COMPLETION_DIR -a \
-x $BASH_COMPLETION_DIR ]; then
for i in $BASH_COMPLETION_DIR/*; do
[[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|.rpm*) ]] &&
[ \( -f $i -o -h $i \) -a -r $i ] && . $i
# source user completion file
[ $BASH_COMPLETION != ~/.bash_completion -a -r ~/.bash_completion ] \
unset UNAME RELEASE default dirnames filenames have nospace bashdefault \
set $BASH_COMPLETION_ORIGINAL_V_VALUE
unset BASH_COMPLETION_ORIGINAL_V_VALUE