Merge branch 'master' of git+ssh://git.debian.org/git/bash-completion/bash-completion

This commit is contained in:
Guillaume Rousse 2009-09-14 21:36:44 +02:00
commit c4b81f782d
1090 changed files with 6972 additions and 7502 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.tar*
*.swp
Makefile
Makefile.in
aclocal.m4

38
CHANGES
View File

@ -34,11 +34,13 @@ bash-completion (1.x)
* Added avahi-discovered hosts to _known_hosts_real() (Debian: #518561)
[ Ville Skyttä ]
* Split yum and yum-arch completion into contrib/yum.
* Install yum-arch completion only if yum-arch is installed.
* Split yum completion to contrib/_yum (no longer installed by default, the
intent is to move it to yum upstream soon).
* Split yum-arch completion into contrib/yum-arch, load completion only if
yum-arch is installed.
* Update list of yum commands and options.
* Add yum repolist, --enable/disablerepo, --disableexcludes, -d, -e, and
--color completions.
* Add yum repolist, --enable/disablerepo, --disableexcludes, -d, -e, --color,
and --enable/disableplugin completions.
* Add chkconfig --override and resetpriorities completions.
* Split mplayer and friends completions to contrib/mplayer.
* Parse top level mplayer and friends option completions from -list-options.
@ -71,8 +73,8 @@ bash-completion (1.x)
completion, assume only that --*file*= does, and that --*dir*= takes dirs.
* Add make --old/new-file, --assume-old/new, --what-if value completions.
* Add smartctl -n/--nocheck completion, add more other value completions.
* Fix leaking $prev from cpio, dsniff, freeciv, gkrellm, mkinitrd, and
tcpdump completions.
* Fix leaking $prev from cpio, dsniff, freeciv, gkrellm, mkinitrd, service,
and tcpdump completions.
* Split ant completion to contrib/ant, improve the built in one.
* Improve postfix completion.
* Improve samba completion.
@ -92,6 +94,21 @@ bash-completion (1.x)
to get various completions instead of simply "mplayer" or "mencoder".
* Associate OOXML/MS Office 2007 extensions with OpenOffice applications.
* Associate .tsv with oocalc.
* Add xmlwf completion.
* Associate *.po with poedit, gtranslator, kbabel, and lokalize.
* Add xz, xzcat, xzdec, and unxz completion.
* Add lzcat, lz*grep, lzless, lzmore, and unlzma completion.
* Load "modules" completion if /etc/profile.d/modules.sh exists even if
the "module" alias has not been defined (yet).
* Add *.ogv to xine-based players (Debian: #540033).
* Add $compopt (":" i.e. no-op with bash < 4, "compopt" with >= 4).
* Complete bzcat and zcat only on compressed files.
* Do not require a dot in bzcmp, bzdiff, bz*grep, zcmp, zdiff, z*grep, zless,
and zmore filename completions.
* Add xz and compress support and more tarball filename extensions to
rpmbuild -t*/--tarbuild completion.
* Don't hardcode path to lsmod.
* Fix sbcl file/dirname completion (Debian: #545743).
[ Todd Zullinger ]
* Make yum complete on filenames after install, deplist, update and upgrade
@ -135,6 +152,13 @@ bash-completion (1.x)
[ Freddy Vulto ]
* Patched _known_hosts() to support multiple {Global,User}KnownHosts in SSH
config files, thanks to Thomas Nilsson (Alioth: #311595) (Debian: #524190)
* Fix leaking $i from info, man and python completions.
* Added setting COMP_KNOWN_HOSTS_WITH_HOSTFILE. _known_hosts_real() will add
hosts from HOSTFILE, unless COMP_KNOWN_HOSTS_WITH_HOSTFILE is set to an
empty value (Alioth: #311821)
* Fix _known_hosts_real() to not glob awk script - thanks to Eric Blake
(Alioth #311614)
* Fix leaking $muttcmd from mutt completion
-- David Paleino <d.paleino@gmail.com> Thu, 18 Jun 2009 13:12:36 +0200
@ -345,7 +369,7 @@ bash-completion (20080617.4) experimental; urgency=low
- _known_hosts(): use files from UserKnownHostsFile options in
addition to standard ones.
- fixed _command() to correctly prune the command line
- disabled completion of PostgreSQL users and databases
- disabled completion of PostgreSQL users and databases (Ubuntu: #164772)
- fixed _java_packages()
- fixed _muttquery()
- added flv/FLV completion to mplayer

View File

@ -137,9 +137,11 @@ bashcomp_DATA = contrib/ant \
contrib/xhost \
contrib/xm \
contrib/xmllint \
contrib/xmlwf \
contrib/xmms \
contrib/xrandr \
contrib/xz \
contrib/yp-tools \
contrib/yum
contrib/yum-arch
EXTRA_DIST = $(sysconf_DATA) $(bashcomp_DATA) contrib/_subversion
EXTRA_DIST = $(sysconf_DATA) $(bashcomp_DATA) contrib/_subversion contrib/_yum

View File

@ -65,6 +65,7 @@ if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} > 04 ]] ||
default="-o default"
dirnames="-o dirnames"
filenames="-o filenames"
compopt=:
fi
# features supported by bash 2.05b and higher
if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] ||
@ -81,6 +82,7 @@ fi
# features supported by bash 4.0 and higher
if [ ${BASH_VERSINFO[0]} -gt 3 ]; then
declare -r bash4=$BASH_VERSION 2>/dev/null || :
compopt=compopt
fi
# Turn on extended globbing and programmable completion
@ -96,17 +98,16 @@ complete -d pushd
# Do NOT break these over multiple lines.
#
# START exclude -- do NOT remove this line
complete -f -X '!*.?(t)bz?(2)' bunzip2
# TODO: see #455510
#complete -f -X '!*.?(t)bz?(2)' bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
complete -f -X '!*.*' bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
# bzcmp, bzdiff, bz*grep, bzless, bzmore intentionally not here, see Debian: #455510
complete -f -X '!*.?(t)bz?(2)' bunzip2 bzcat
complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo|xpi|sxw|ott|od[fgpst]|epub)' unzip zipinfo
complete -f -X '*.Z' compress znew
complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip
# TODO: see #455510
#complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
complete -f -X '!*.*' zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
# zcmp, zdiff, z*grep, zless, zmore intentionally not here, see Debian: #455510
complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip zcat
complete -f -X '!*.Z' uncompress
# lzcmp, lzdiff intentionally not here, see Debian: #455510
complete -f -X '!*.lzma' lzcat lzegrep lzfgrep lzgrep lzless lzmore unlzma
complete -f -X '!*.@(xz|lzma)' unxz xzcat
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
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
@ -120,7 +121,7 @@ complete -f -X '!*.@(?(e)ps|?(E)PS|pdf|PDF)' ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 p
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|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|ogg|OGG|ogm|OGM|wav|WAV|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))' xine aaxine fbxine kaffeine
complete -f -X '!*@(.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|og[gmv]|OG[GMV]|wav|WAV|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))' 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
@ -144,6 +145,7 @@ complete -f -X '!*.odb' oobase
complete -f -X '!*.rpm' rpm2cpio
complete -f -X '!*.sqlite' sqlite3
complete -f -X '!*.aux' bibtex
complete -f -X '!*.po' poedit gtranslator kbabel lokalize
# FINISH exclude -- do not remove this line
# start of section containing compspecs that can be handled within bash
@ -244,33 +246,29 @@ dequote()
# for things like scp where we want to return host:path and not only path.
_get_cword()
{
if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then
printf "%s" "${COMP_WORDS[COMP_CWORD]}"
else
local i
local cur="$COMP_LINE"
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
cur="${cur:1}"
index="$(( index - 1 ))"
done
if [[ "$i" -lt "$COMP_CWORD" ]]; then
local old_size="${#cur}"
cur="${cur#${COMP_WORDS[i]}}"
local new_size="${#cur}"
index="$(( index - old_size + new_size ))"
fi
local i
local LC_CTYPE=C
local WORDBREAKS=${COMP_WORDBREAKS}
if [ -n $1 ]; then
for (( i=0; i<${#1}; ++i )); do
local char=${1:$i:1}
WORDBREAKS=${WORDBREAKS//$char/}
done
if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then
# We messed up! At least return the whole word so things
# keep working
printf "%s" "${COMP_WORDS[COMP_CWORD]}"
else
printf "%s" "${cur:0:$index}"
fi
fi
local cur=${COMP_LINE:0:$COMP_POINT}
local tmp="${cur}"
local word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
while [ "$word_start" -ge 2 ]; do
local char=${cur:$(( $word_start - 2 )):1}
if [ "$char" != "\\" ]; then
break
fi
tmp=${COMP_LINE:0:$(( $word_start - 2 ))}
word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
done
cur=${cur:$word_start}
printf "%s" "$cur"
}
# This function performs file and directory completion. It's better than
@ -549,7 +547,7 @@ _modules()
#
_installed_modules()
{
COMPREPLY=( $( compgen -W "$( /sbin/lsmod | \
COMPREPLY=( $( compgen -W "$( PATH="$PATH:/sbin" lsmod | \
awk '{if (NR != 1) print $1}' )" -- $1 ) )
}
@ -637,7 +635,7 @@ _usb_ids()
{ have service || [ -d /etc/init.d/ ]; } &&
_service()
{
local cur sysvdir
local cur prev sysvdir
COMPREPLY=()
prev=${COMP_WORDS[COMP_CWORD-1]}
@ -1049,15 +1047,20 @@ shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
# `_known_hosts_real' instead.
_known_hosts()
{
local options
COMPREPLY=()
# NOTE: Passing "$@" is deprecated. See NOTE above.
_known_hosts_real "$@" "$(_get_cword)"
# NOTE: Using `_known_hosts' as a helper function and passing options
# to `_known_hosts' is deprecated: Use `_known_hosts_real' instead.
[ "$1" = -a ] || [ "$2" = -a ] && options=-a
[ "$1" = -c ] || [ "$2" = -c ] && options="$options -c"
_known_hosts_real $options "$(_get_cword)"
}
# Helper function for completing _known_hosts.
# This function performs host completion based on ssh's known_hosts files,
# defaulting to standard host completion if they don't exist.
# This function performs host completion based on ssh's known_hosts files.
# Also hosts from HOSTFILE (compgen -A hostname) are added, unless
# COMP_KNOWN_HOSTS_WITH_HOSTFILE is set to an empty value.
# Usage: _known_hosts_real [OPTIONS] CWORD
# Options: -a Use aliases
# -c Use `:' suffix
@ -1069,7 +1072,6 @@ _known_hosts_real()
local configfile flag prefix
local cur curd awkcur user suffix aliases global_kh user_kh hosts i host
local -a kh khd config
local IFS=$'\n'
local OPTIND=1
while getopts "acF:p:" flag "$@"; do
@ -1102,16 +1104,18 @@ _known_hosts_real()
fi
if [ ${#config[@]} -gt 0 ]; then
local OIFS=$IFS IFS=$'\n'
# expand path (if present) to global known hosts file
global_kh=($( 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[@]}" ))
global_kh=($( 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[@]}" ))
for (( i=0; i < ${#global_kh[@]}; i++ )); do
global_kh[i]=$(echo "${global_kh[i]//\"/}")
done
# expand path (if present) to user known hosts file
user_kh=($( 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[@]}" ))
user_kh=($( 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[@]}" ))
for (( i=0; i < ${#user_kh[@]}; i++ )); do
user_kh[i]=$(echo "${user_kh[i]//\"/}")
done
IFS=$OIFS
fi
# Global known_hosts files
@ -1144,79 +1148,78 @@ _known_hosts_real()
# If we have known_hosts files to use
if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 -o -n "$configfile" ]; then
# Escape slashes and dots in paths for awk
awkcur=${cur//\//\\\/}
awkcur=${awkcur//\./\\\.}
curd=$awkcur
# Escape slashes and dots in paths for awk
awkcur=${cur//\//\\\/}
awkcur=${awkcur//\./\\\.}
curd=$awkcur
if [[ "$awkcur" == [0-9]*.* ]]; then
# Digits followed by a dot - just search for that
awkcur="^$awkcur.*"
elif [[ "$awkcur" == [0-9]* ]]; then
# Digits followed by no dot - search for digits followed
# by a dot
awkcur="^$awkcur.*\."
elif [ -z "$awkcur" ]; then
# A blank - search for a dot or an alpha character
awkcur="[a-z.]"
else
awkcur="^$awkcur"
fi
if [[ "$awkcur" == [0-9]*.* ]]; then
# Digits followed by a dot - just search for that
awkcur="^$awkcur.*"
elif [[ "$awkcur" == [0-9]* ]]; then
# Digits followed by no dot - search for digits followed
# by a dot
awkcur="^$awkcur.*\."
elif [ -z "$awkcur" ]; then
# A blank - search for a dot or an alpha character
awkcur="[a-z.]"
else
awkcur="^$awkcur"
fi
if [ ${#kh[@]} -gt 0 ]; then
# FS needs to look for a comma separated list
COMPREPLY=( $( awk 'BEGIN {FS=","}
if [ ${#kh[@]} -gt 0 ]; then
# FS needs to look for a comma separated list
COMPREPLY=( $( awk 'BEGIN {FS=","}
/^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \
gsub(" .*$", "", $i); \
if ($i ~ /'$awkcur'/) {print $i} \
if ($i ~ /'"$awkcur"'/) {print $i} \
}}' "${kh[@]}" 2>/dev/null ) )
fi
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_$awkcurd*.pub ]] && [ -r "$i" ] ; then
host=${i/#*key_22_/}
host=${host/%.pub/}
COMPREPLY=( "${COMPREPLY[@]}" $host )
fi
fi
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_$awkcurd*.pub ]] && [ -r "$i" ] ; then
host=${i/#*key_22_/}
host=${host/%.pub/}
COMPREPLY=( "${COMPREPLY[@]}" $host )
fi
done
fi
# append any available aliases from config files
if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
local host_aliases=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^#*?]*\)\(#.*\)\?$/\2/p' "${config[@]}" )
hosts=$( compgen -W "$host_aliases" -- $cur )
COMPREPLY=( "${COMPREPLY[@]}" $hosts )
fi
# Add hosts reported by avahi, if it's available
# and if the daemon is started.
# The original call to avahi-browse also had "-k", to avoid
# lookups into avahi's services DB. We don't need the name
# of the service, and if it contains ";", it may mistify
# the result. But on Gentoo (at least), -k isn't available
# (even if mentioned in the manpage), so...
if type avahi-browse >&/dev/null; then
if [ -n "$(pidof avahi-daemon)" ]; then
COMPREPLY=( "${COMPREPLY[@]}" $(
compgen -W "$( avahi-browse -cpr _workstation._tcp | \
grep ^= | cut -d\; -f7 | sort -u )" -- $cur ) )
fi
fi
# apply suffix and prefix
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=$prefix$user${COMPREPLY[i]}$suffix
done
fi
# append any available aliases from config files
if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
local host_aliases=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^#*?]*\)\(#.*\)\?$/\2/p' "${config[@]}" )
hosts=$( compgen -W "$host_aliases" -- $cur )
COMPREPLY=( "${COMPREPLY[@]}" $hosts )
fi
fi
# Add hosts reported by avahi, if it's available
# and if the daemon is started.
# The original call to avahi-browse also had "-k", to avoid
# lookups into avahi's services DB. We don't need the name
# of the service, and if it contains ";", it may mistify
# the result. But on Gentoo (at least), -k isn't available
# (even if mentioned in the manpage), so...
if type avahi-browse >&/dev/null; then
if [ -n "$(pidof avahi-daemon)" ]; then
COMPREPLY=( "${COMPREPLY[@]}" $(
compgen -W "$( avahi-browse -cpr _workstation._tcp | \
grep ^= | cut -d\; -f7 | sort -u )" -- $cur ) )
fi
fi
# Now add results of normal hostname completion
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -A hostname -- $cur ) )
# apply suffix and prefix
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=$prefix$user${COMPREPLY[i]}$suffix
done
elif [ -z "$configfile" ]; then
# Just do normal hostname completion
COMPREPLY=( $( compgen -A hostname -S "$suffix" -- $cur ) )
# Add results of normal hostname completion, unless `COMP_KNOWN_HOSTS_WITH_HOSTFILE'
# is set to an empty value.
if [ -n "${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1}" ]; then
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -A hostname -P "$prefix$user" -S "$suffix" -- $cur ) )
fi
return 0
@ -1547,7 +1550,8 @@ unset i
[ $BASH_COMPLETION != ~/.bash_completion -a -r ~/.bash_completion ] \
&& . ~/.bash_completion
unset -f have
unset UNAME USERLAND default dirnames filenames have nospace bashdefault plusdirs
unset UNAME USERLAND default dirnames filenames have nospace bashdefault \
plusdirs compopt
set $BASH_COMPLETION_ORIGINAL_V_VALUE
unset BASH_COMPLETION_ORIGINAL_V_VALUE

180
contrib/_yum Normal file
View File

@ -0,0 +1,180 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
# yum(8) completion
#
have yum && {
_yum_list()
{
if [[ "$1" == all ]] ; then
# Try to strip in between headings like "Available Packages"
# This will obviously only work for English :P
COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \
sed -ne '/^\(Available\|Installed\|Updated\) /d' \
-e 's/[[:space:]].*//p' ) )
else
# Drop first line (e.g. "Updated Packages")
COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \
sed -ne 1d -e 's/[[:space:]].*//p' ) )
fi
}
_yum_repolist()
{
# -d 0 causes repolist to output nothing as of yum 3.2.22:
# http://yum.baseurl.org/ticket/83
# Drop first ("repo id repo name") and last ("repolist: ...") rows
yum --noplugins -C repolist $1 2>/dev/null | \
sed -ne '/^repo\(\s\+id\|list:\)/d' -e 's/[[:space:]].*//p'
}
_yum_plugins()
{
command ls /usr/lib/yum-plugins/*.py{,c,o} 2>/dev/null \
| sed -ne 's|.*/\([^./]*\)\.py[co]\?$|\1|p' | sort -u
}
_yum()
{
local cur prev special split=false
COMPREPLY=()
cur=`_get_cword`
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|info) ]]; then
special=${COMP_WORDS[i]}
fi
done
if [ -n "$special" ]; then
# TODO: install|update|upgrade should not match *src.rpm
if [[ "$cur" == */* && "$special" == @(deplist|install|update|upgrade) ]]; then
_filedir rpm
return 0
fi
case $special in
install)
_yum_list available
return 0
;;
deplist|info)
_yum_list all
return 0
;;
upgrade|update)
_yum_list updates
return 0
;;
remove|erase)
# _rpm_installed_packages is not arch-qualified
_yum_list installed
return 0
;;
esac
fi
_split_longopt && split=true
case $prev in
list)
COMPREPLY=( $( compgen -W 'all available updates \
installed extras obsoletes recent' -- $cur ) )
;;
clean)
COMPREPLY=( $( compgen -W 'packages headers metadata \
cache dbcache all' -- $cur ) )
;;
repolist)
COMPREPLY=( $( compgen -W 'all enabled disabled' \
-- $cur ) )
;;
localinstall|localupdate)
# TODO: should not match *src.rpm
_filedir rpm
;;
-d|-e)
COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9 10' \
-- $cur ) )
;;
-c)
_filedir
;;
--installroot)
_filedir -d
;;
--enablerepo)
COMPREPLY=( $( compgen -W '$( _yum_repolist \
disabled )' -- $cur ) )
;;
--disablerepo)
COMPREPLY=( $( compgen -W '$( _yum_repolist \
enabled )' -- $cur ) )
;;
--disableexcludes)
COMPREPLY=( $( compgen -W '$( _yum_repolist all ) \
all main' -- $cur ) )
;;
--enableplugin|--disableplugin)
COMPREPLY=( $( compgen -W '$( _yum_plugins )' -- $cur ))
;;
--color)
COMPREPLY=( $( compgen -W 'always auto never' -- $cur ))
;;
-R|-x|--exclude)
# argument required but no completions available
return 0
;;
-h|--help|--version)
# no other options useful with these
return 0
;;
*)
COMPREPLY=( $( compgen -W 'install update \
check-update upgrade remove erase list info \
provides whatprovides clean makecache \
groupinstall groupupdate grouplist \
groupremove groupinfo search shell resolvedep \
localinstall localupdate deplist repolist \
help' -- $cur ) )
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-h --help -t --tolerant -C -c -R \
-d --showduplicates -e -q --quiet -v --verbose -y \
--version --installroot --enablerepo --disablerepo -x \
--exclude --disableexcludes --obsoletes --noplugins \
--nogpgcheck --disableplugin --enableplugin \
--skip-broken --color' -- $cur ) )
return 0
fi
}
} &&
complete -F _yum $filenames yum
# yum-arch(8) completion
#
have yum-arch &&
_yum_arch()
{
local cur
COMPREPLY=()
cur=`_get_cword`
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l \
-q' -- $cur ) )
;;
*)
_filedir -d
;;
esac
return 0
} &&
complete -F _yum_arch $filenames yum-arch

View File

@ -32,7 +32,7 @@ _gdb()
elif [ $COMP_CWORD -eq 2 ]; then
prev=${prev##*/}
COMPREPLY=( $( compgen -fW "$( command ps axo comm,pid | \
awk '{if ($1 ~ /^'"$prev"'/) print $2}' ) )" \
awk '{if ($1 ~ /^'"$prev"'/) print $2}' )" \
-- "$cur" ) )
fi
} &&

View File

@ -6,7 +6,7 @@
have info &&
_info()
{
local cur infopath
local cur i infopath
COMPREPLY=()
cur=`_get_cword`

View File

@ -8,7 +8,7 @@
-o $UNAME = OpenBSD ] &&
_man()
{
local cur prev sect manpath manext mansect uname
local cur i prev sect manpath manext mansect uname
manext="@([0-9lnp]|[0-9][px]|man|3pm)?(.@(gz|bz2|lzma))"
mansect="@([0-9lnp]|[0-9][px]|3pm)"

View File

@ -17,7 +17,9 @@
# module command is an alias, and the `module avail' command returns
# its output as stderr.
type module &>/dev/null && {
# Test for existence of /etc/profile.d/modules.sh too because we may end up
# being sourced before it and thus before the `module' alias has been defined.
have module || [ -f /etc/profile.d/modules.sh ] && {
_module_list ()
{
@ -80,5 +82,5 @@ _module () {
fi
return 0
}
complete -o default -F _module module
complete -F _module $default module
}

View File

@ -39,7 +39,7 @@ _muttconffiles()
_muttaliases()
{
local cur muttrc
local cur muttrc muttcmd=${COMP_WORDS[0]}
local -a conffiles aliases
cur=`_get_cword =`
@ -57,7 +57,7 @@ _muttaliases()
_muttquery()
{
local cur querycmd
local cur querycmd muttcmd=${COMP_WORDS[0]}
local -a queryresults
cur=`_get_cword`
@ -77,7 +77,7 @@ _muttquery()
_muttfiledir()
{
local cur folder spoolfile
local cur folder spoolfile muttcmd=${COMP_WORDS[0]}
cur=`_get_cword`
# This is currently not working so well. Perhaps this function should
@ -108,8 +108,6 @@ _mutt()
COMPREPLY=()
[ ${COMP_WORDS[0]} == muttng ] && muttcmd="muttng" || muttcmd="mutt"
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '-A -a -b -c -e -f -F -H -i -m -n \

View File

@ -217,7 +217,7 @@ _openssl()
-crl_check_all -cert -certform \
-key -keyform -pass -dcert \
-dcertform -dkey -dkeyform \
-dpass -dhparam -nbio
-dpass -dhparam -nbio \
-nbio_test -crlf -debug -msg \
-state -CApath -CAfile -nocert \
-cipher -quiet -no_tmp_rsa \

View File

@ -6,7 +6,7 @@
have psql && {
_pg_databases()
{
return # intentionally disabled in 7ebed6af (TODO: why?)
return # See https://launchpad.net/bugs/164772
COMPREPLY=( $( compgen -W "$( psql -l 2>/dev/null | \
sed -e '1,/^-/d' -e '/^(/,$d' | \
awk '{print $1}' )" -- $cur ) )
@ -14,6 +14,7 @@ _pg_databases()
_pg_users()
{
# See https://launchpad.net/bugs/164772
#COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
# grep "^ $cur" ) )
#[ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- $cur ) )

View File

@ -6,55 +6,55 @@
have povray || have xpovray || have spovray &&
_povray()
{
local cur prev povcur pfx oext defoext
defoext=png # default output extension, if cannot be determined FIXME
local cur prev povcur pfx oext defoext
defoext=png # default output extension, if cannot be determined FIXME
COMPREPLY=()
povcur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=()
povcur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
_expand || return 0
_expand || return 0
case $povcur in
[-+]I*)
cur="${povcur#[-+]I}" # to confuse _filedir
pfx="${povcur%"$cur"}"
_filedir pov
COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
return 0
;;
[-+]O*)
# guess what output file type user may want
case $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]F' ) ) in
[-+]FN) oext=png ;;
[-+]FP) oext=ppm ;;
[-+]F[CT]) oext=tga ;;
*) oext=$defoext ;;
esac
# complete filename corresponding to previously specified +I
COMPREPLY=( $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]I' ) ) )
COMPREPLY=( ${COMPREPLY[@]#[-+]I} )
COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} )
cur="${povcur#[-+]O}" # to confuse _filedir
pfx="${povcur%"$cur"}"
_filedir $oext
COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
return 0
;;
*.ini\[|*.ini\[*[^]]) # sections in .ini files
cur="${povcur#*\[}"
pfx="${povcur%\["$cur"}" # prefix == filename
[ -r "$pfx" ] || return 0
COMPREPLY=( $(sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' -e 't' -e 'd' -- "$pfx") )
# to prevent [bar] expand to nothing. can be done more easily?
COMPREPLY=( "${COMPREPLY[@]/#/$pfx[}" )
return 0
;;
*)
cur="$povcur"
_filedir '?(ini|pov)'
return 0
;;
esac
case $povcur in
[-+]I*)
cur="${povcur#[-+]I}" # to confuse _filedir
pfx="${povcur%"$cur"}"
_filedir pov
COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
return 0
;;
[-+]O*)
# guess what output file type user may want
case $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]F' ) ) in
[-+]FN) oext=png ;;
[-+]FP) oext=ppm ;;
[-+]F[CT]) oext=tga ;;
*) oext=$defoext ;;
esac
# complete filename corresponding to previously specified +I
COMPREPLY=( $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]I' ) ) )
COMPREPLY=( ${COMPREPLY[@]#[-+]I} )
COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} )
cur="${povcur#[-+]O}" # to confuse _filedir
pfx="${povcur%"$cur"}"
_filedir $oext
COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
return 0
;;
*.ini\[|*.ini\[*[^]]) # sections in .ini files
cur="${povcur#*\[}"
pfx="${povcur%\["$cur"}" # prefix == filename
[ -r "$pfx" ] || return 0
COMPREPLY=( $(sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' -e 't' -e 'd' -- "$pfx") )
# to prevent [bar] expand to nothing. can be done more easily?
COMPREPLY=( "${COMPREPLY[@]/#/$pfx[}" )
return 0
;;
*)
cur="$povcur"
_filedir '?(ini|pov)'
return 0
;;
esac
} &&
complete -F _povray $filenames povray xpovray spovray

View File

@ -6,7 +6,7 @@
have python &&
_python()
{
local prev cur
local prev cur i
COMPREPLY=()
cur=`_get_cword`

View File

@ -255,7 +255,7 @@ _rpm()
elif [[ ${COMP_WORDS[1]} == -b* ]]; then
_filedir 'spec'
else
_filedir '@(tgz|tar.@(gz|bz2|lzma))'
_filedir '@(t?(ar.)@([gx]z|bz?(2))|tar.@(lzma|Z))'
fi
;;
--re@(build|compile))
@ -267,7 +267,7 @@ _rpm()
fi
;;
--tarbuild)
_filedir '@(tgz|tar.@(gz|bz2|lzma))'
_filedir '@(t?(ar.)@([gx]z|bz?(2))|tar.@(lzma|Z))'
;;
--@(re|add)sign)
_filedir 'rpm'

View File

@ -23,4 +23,4 @@ _sbcl()
return 0
} &&
complete -F _sbcl $default sbcl sbcl-mt
complete -F _sbcl $filenames sbcl sbcl-mt

View File

@ -52,7 +52,7 @@ _screen()
COMPREPLY=( $( grep ^${cur:-[^#]} /etc/shells ) )
;;
-c)
_filedirs
_filedir
return 0
;;
esac

View File

@ -29,8 +29,7 @@ _ssh_options() {
_ssh()
{
local cur prev
local optconfigfile
local cur prev configfile
local -a config
COMPREPLY=()
@ -75,26 +74,32 @@ _ssh()
;;
esac
if [[ "$cur" == -* ]]; then
if [[ "$cur" == -F* ]]; then
cur=${cur#-F}
_filedir
# Prefix completions with '-F'
COMPREPLY=( "${COMPREPLY[@]/#/-F}" )
cur=-F$cur # Restore cur
elif [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-1 -2 -4 -6 -A -a -C -f -g -K -k -M \
-N -n -q -s -T -t -V -v -X -v -Y -y -b -b -c -D -e -F \
-i -L -l -m -O -o -p -R -S -w' -- $cur ) )
else
# Search COMP_WORDS for '-F configfile' argument
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
set -- "${COMP_WORDS[@]}"
while [ $# -gt 0 ]; do
if [ "${1:0:2}" = -F ]; then
if [ ${#1} -gt 2 ]; then
optconfigfile="$(dequote "$1")"
configfile="$(dequote "${1:2}")"
else
shift
[ "$1" ] && optconfigfile="$(dequote "-F$1")"
[ "$1" ] && configfile="$(dequote "$1")"
fi
break
fi
shift
done
_known_hosts_real -a $optconfigfile "$cur"
_known_hosts_real -a -F "$configfile" "$cur"
if [ $COMP_CWORD -ne 1 ]; then
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
fi
@ -108,8 +113,7 @@ shopt -u hostcomplete && complete -F _ssh ssh slogin autossh
#
_sftp()
{
local cur prev
local optconfigfile
local cur prev configfile
COMPREPLY=()
cur=`_get_cword`
@ -117,7 +121,7 @@ _sftp()
case "$prev" in
-@(b|F|P))
_filedirs
_filedir
return 0
;;
-o)
@ -126,7 +130,13 @@ _sftp()
;;
esac
if [[ "$cur" == -* ]]; then
if [[ "$cur" == -F* ]]; then
cur=${cur#-F}
_filedir
# Prefix completions with '-F'
COMPREPLY=( "${COMPREPLY[@]/#/-F}" )
cur=-F$cur # Restore cur
elif [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-1 -C -v -B -b -F -o -P -R -S -s' \
-- $cur ) )
else
@ -135,16 +145,16 @@ _sftp()
while [ $# -gt 0 ]; do
if [ "${1:0:2}" = -F ]; then
if [ ${#1} -gt 2 ]; then
optconfigfile="$(dequote "$1")"
configfile="$(dequote "${1:2}")"
else
shift
[ "$1" ] && optconfigfile="$(dequote "-F$1")"
[ "$1" ] && configfile="$(dequote "$1")"
fi
break
fi
shift
done
_known_hosts_real -a $optconfigfile "$cur"
_known_hosts_real -a -F "$configfile" "$cur"
fi
return 0
@ -156,8 +166,7 @@ shopt -u hostcomplete && complete -F _sftp sftp
#
_scp()
{
local cur userhost path
local optconfigfile
local configfile cur userhost path prefix
COMPREPLY=()
cur=`_get_cword ":"`
@ -185,30 +194,34 @@ _scp()
return 0
fi
# Search COMP_WORDS for '-F configfile' argument
set -- "${COMP_WORDS[@]}"
while [ $# -gt 0 ]; do
if [ "${1:0:2}" = -F ]; then
if [ ${#1} -gt 2 ]; then
optconfigfile="$(dequote "$1")"
else
shift
[ "$1" ] && optconfigfile="$(dequote "-F$1")"
if [[ "$cur" = -F* ]]; then
cur=${cur#-F}
prefix=-F
else
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
set -- "${COMP_WORDS[@]}"
while [ $# -gt 0 ]; do
if [ "${1:0:2}" = -F ]; then
if [ ${#1} -gt 2 ]; then
configfile="$(dequote "${1:2}")"
else
shift
[ "$1" ] && configfile="$(dequote "$1")"
fi
break
fi
break
fi
shift
done
[[ "$cur" == */* ]] || _known_hosts_real -c -a $optconfigfile "$cur"
shift
done
[[ "$cur" == */* ]] || _known_hosts_real -c -a -F "$configfile" "$cur"
fi
# This approach is used instead of _filedir to get a space appended
# after local file/dir completions, and $nospace retained for others.
local IFS=$'\t\n'
COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \
2>/dev/null | sed \
-e "s/[][(){}<>\",:;^&\!$=?\`|\\ ']/\\\\&/g" \
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' -e "s/^/$prefix/") )
return 0
}

View File

@ -17,8 +17,24 @@ _xmllint()
_filedir
return 0
;;
--path|--dtdvalid|--dtdvalidfpi|--maxmem|--encode|--pattern|\
--relaxng|--schema|--schematron)
--path|--dtdvalidfpi|--maxmem|--encode|--pattern)
# argument required but no completions available
return 0
;;
--dtdvalid)
_filedir dtd
return 0
;;
--relaxng)
_filedir rng
return 0
;;
--schema)
_filedir xsd
return 0
;;
--schematron)
_filedir sch
return 0
;;
esac

35
contrib/xmlwf Normal file
View File

@ -0,0 +1,35 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for xmlwf(1)
have xmlwf &&
_xmlwf()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-d)
_filedir -d
return 0
;;
-e)
COMPREPLY=( $( compgen -W 'US-ASCII UTF-8 UTF-16 \
ISO-8859-1' -- $cur ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c -d -e -m -n -p -r -s -t -v -w \
-x' -- $cur ) )
return 0
fi
_filedir '@(*ml|htm|svg)'
} &&
complete -F _xmlwf $filenames xmlwf

99
contrib/xz Normal file
View File

@ -0,0 +1,99 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
# xz(1) completion
#
have xz &&
_xz()
{
COMPREPLY=()
local cur=`_get_cword`
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-z --compress -d --decompress \
-t --test -l --list -k --keep -f --force -c --stdout \
-S --suffix --files --files0 -F --format -C --check \
-0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -M --memory --lzma1 \
--lzma2 --x86 --powerpc --ia64 --arm --armthumb \
--sparc --delta -q --quiet -v --verbose -h --help \
-H --long-help -V --version' -- $cur ) )
return 0
fi
local split=false
_split_longopt && split=true
local xspec="*.@(xz|lzma)"
case "$prev" in
-@(!(-*)[dlt]*|-decompress|-list|-test))
xspec="!"$xspec
;;
--files|--files0)
_filedir
return 0
;;
-C|--check)
COMPREPLY=( $( compgen -W 'crc32 crc64 sha256' \
-- $cur ) )
return 0
;;
-F|--format)
COMPREPLY=( $( compgen -W 'auto xz lzma raw' -- $cur ) )
return 0
;;
-M|--memory|-S|--suffix|--delta|--lzma1|--lzma2)
# argument required but no completions available
return 0
;;
-h|--help|-H|--long-help|-V|--version)
# all other arguments are noop with these
return 0
;;
esac
$split && return 0
_expand || return 0
local IFS=$'\t\n'
COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
$( compgen -d -- $cur ) )
} &&
complete -F _xz $filenames xz
# xzdec(1) completion
#
have xzdec &&
_xzdec()
{
COMPREPLY=()
local cur=`_get_cword`
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-M --memory -h --help -V --version' \
-- $cur ) )
return 0
fi
local split=false
_split_longopt && split=true
case "$prev" in
-M|--memory)
# argument required but no completions available
return 0
;;
-h|--help|-V|--version)
# all other arguments are noop with these
return 0
;;
esac
$split && return 0
_filedir xz # no lzma support here as of xz 4.999.8beta
} &&
complete -F _xzdec $filenames xzdec

View File

@ -1,171 +0,0 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
# yum(8) completion
#
have yum && {
_yum_list()
{
if [[ "$1" == all ]] ; then
# Try to strip in between headings like "Available Packages"
# This will obviously only work for English :P
COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \
sed -ne '/^\(Available\|Installed\|Updated\) /d' \
-e 's/[[:space:]].*//p' ) )
else
# Drop first line (e.g. "Updated Packages")
COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \
sed -ne 1d -e 's/[[:space:]].*//p' ) )
fi
}
_yum_repolist()
{
# -d 0 causes repolist to output nothing as of yum 3.2.22:
# http://yum.baseurl.org/ticket/83
# Drop first ("repo id repo name") and last ("repolist: ...") rows
yum --noplugins -C repolist $1 2>/dev/null | \
sed -ne '/^repo\(\s\+id\|list:\)/d' -e 's/[[:space:]].*//p'
}
_yum()
{
local cur prev special split=false
COMPREPLY=()
cur=`_get_cword`
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|info) ]]; then
special=${COMP_WORDS[i]}
fi
done
if [ -n "$special" ]; then
# TODO: install|update|upgrade should not match *src.rpm
if [[ "$cur" == */* && "$special" == @(deplist|install|update|upgrade) ]]; then
_filedir rpm
return 0
fi
case $special in
install)
_yum_list available
return 0
;;
deplist|info)
_yum_list all
return 0
;;
upgrade|update)
_yum_list updates
return 0
;;
remove|erase)
# _rpm_installed_packages is not arch-qualified
_yum_list installed
return 0
;;
esac
fi
_split_longopt && split=true
case $prev in
list)
COMPREPLY=( $( compgen -W 'all available updates \
installed extras obsoletes recent' -- $cur ) )
;;
clean)
COMPREPLY=( $( compgen -W 'packages headers metadata \
cache dbcache all' -- $cur ) )
;;
repolist)
COMPREPLY=( $( compgen -W 'all enabled disabled' \
-- $cur ) )
;;
localinstall|localupdate)
# TODO: should not match *src.rpm
_filedir rpm
;;
-d|-e)
COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9 10' \
-- $cur ) )
;;
-c)
_filedir
;;
--installroot)
_filedir -d
;;
--enablerepo)
COMPREPLY=( $( compgen -W '$( _yum_repolist \
disabled )' -- $cur ) )
;;
--disablerepo)
COMPREPLY=( $( compgen -W '$( _yum_repolist \
enabled )' -- $cur ) )
;;
--disableexcludes)
COMPREPLY=( $( compgen -W '$( _yum_repolist all ) \
all main' -- $cur ) )
;;
--color)
COMPREPLY=( $( compgen -W 'always auto never' -- $cur ))
;;
-R|-x|--exclude)
# argument required but no completions available
return 0
;;
-h|--help|--version)
# no other options useful with these
return 0
;;
*)
COMPREPLY=( $( compgen -W 'install update \
check-update upgrade remove erase list info \
provides whatprovides clean makecache \
groupinstall groupupdate grouplist \
groupremove groupinfo search shell resolvedep \
localinstall localupdate deplist repolist \
help' -- $cur ) )
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-h --help -t --tolerant -C -c -R \
-d --showduplicates -e -q --quiet -v --verbose -y \
--version --installroot --enablerepo --disablerepo -x \
--exclude --disableexcludes --obsoletes --noplugins \
--nogpgcheck --disableplugin --enableplugin \
--skip-broken --color' -- $cur ) )
return 0
fi
}
} &&
complete -F _yum $filenames yum
# yum-arch(8) completion
#
have yum-arch &&
_yum_arch()
{
local cur
COMPREPLY=()
cur=`_get_cword`
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l \
-q' -- $cur ) )
;;
*)
_filedir -d
;;
esac
return 0
} &&
complete -F _yum_arch $filenames yum-arch

25
contrib/yum-arch Normal file
View File

@ -0,0 +1,25 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
# yum-arch(8) completion
#
have yum-arch &&
_yum_arch()
{
local cur
COMPREPLY=()
cur=`_get_cword`
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l \
-q' -- $cur ) )
;;
*)
_filedir -d
;;
esac
return 0
} &&
complete -F _yum_arch $filenames yum-arch

34
doc/bash_completion.txt Normal file
View File

@ -0,0 +1,34 @@
Bash completion
===============
Environment variables
---------------------
*COMP_CONFIGURE_HINTS*::
If set and not null, `configure` completion will return the entire option
string (e.g. `--this-option=DESCRIPTION`) so one can see what kind of data
is required and then simply delete the descriptive text and add one's own
data. If unset or null (default), `configure` completion will strip
everything after the '=' when returning completions.
*COMP_CVS_REMOTE*::
If set and not null, `cvs commit` completion will try to complete on
remotely checked-out files. This requires passwordless access to the
remote repository. Default is unset.
*COMP_KNOWN_HOSTS_WITH_HOSTFILE*::
If set and not null (default), known_hosts completion will complement
hostnames from ssh's known_hosts_files with hostnames taken from the file
specified by the HOSTFILE shell variable (compgen -A hostname). If null,
known_hosts completion will omit hostnames from HOSTFILE. Omitting
hostnames from HOSTFILE is useful if HOSTFILE contains many entries for
local web development or ad-blocking.
*COMP_TAR_INTERNAL_PATHS*::
If set and not null *before* sourcing bash_completion, `tar` completion
will do correct path completion for tar file contents. If unset or null,
`tar' completion will do correct completion for paths to tar files. See
also README.

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@ common Linux/UNIX commands, reducing the amount of typing sysadmins
and programmers need to do on a daily basis.
// include::intro.txt[]
// include::bash_completion.txt[]
include::bash_completion.txt[]
include::styleguide.txt[]
include::testing.txt[]

View File

@ -1,4 +1,4 @@
#!/bin/bash -eu
[ -d html~ ] || mkdir html~
a2x -D html~ -d book -f xhtml main.txt
a2x -D html~ -d book -f xhtml --asciidoc-opts="--unsafe" main.txt

View File

@ -10,10 +10,10 @@ The bash-completion test suite is written on top of the http://www.gnu.org/softw
Installing DejaGnu
------------------
Installing dependencies
-----------------------
Installing DejaGnu should be easy using your local package manager.
Installing dependencies should be easy using your local package manager.
Debian/Ubuntu
@ -25,6 +25,14 @@ sudo apt-get install dejagnu
-------------
This should also install the necessary `expect` and `tcl` packages.
Fedora/RHEL/CentOS
~~~~~~~~~~~~~~~~~~
On Fedora and RHEL/CentOS (with EPEL) you can use `yum`:
-------------
sudo yum install dejagnu tcllib
-------------
This should also install the necessary `expect` and `tcl` packages.
@ -72,7 +80,7 @@ Maintenance
Adding a completion test
~~~~~~~~~~~~~~~~~~~~~~~~
You can add script/generate to add a test.
You can run `cd test && ./generate` to add a test.
Fixing a completion test

View File

@ -1 +0,0 @@
source "lib/completions/enscript.exp"

View File

@ -1 +0,0 @@
source "lib/completions/env.exp"

View File

@ -1,12 +0,0 @@
set test "Completion via _filedir_xspec() should be installed"
set cmd "complete -p evince"
send "$cmd\r"
set expected "^$cmd\r\ncomplete -o filenames -F _filedir_xspec evince\r\n/@$"
expect {
-re $expected { pass "$test" }
-re /@ { fail "$test at prompt" }
}; # expect
source "lib/completions/evince.exp"

View File

@ -1 +0,0 @@
source "lib/completions/expand.exp"

View File

@ -1 +0,0 @@
source "lib/completions/filesnarf.exp"

View File

@ -1 +0,0 @@
source "lib/completions/find.exp"

View File

@ -1 +0,0 @@
source "lib/completions/find_member.exp"

View File

@ -1 +0,0 @@
source "lib/completions/fmt.exp"

View File

@ -1 +0,0 @@
source "lib/completions/fold.exp"

View File

@ -1 +0,0 @@
source "lib/completions/g++.exp"

View File

@ -1 +0,0 @@
source "lib/completions/g4.exp"

View File

@ -1 +0,0 @@
source "lib/completions/g77.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gcc.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gcj.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gcl.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gdb.exp"

View File

@ -1 +0,0 @@
source "lib/completions/genaliases.exp"

View File

@ -1 +0,0 @@
source "lib/completions/getent.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gkrellm.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gmplayer.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gnatmake.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gpc.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gperf.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gpg.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gprof.exp"

View File

@ -1 +0,0 @@
source "lib/completions/grep.exp"

View File

@ -1 +0,0 @@
source "lib/completions/grub.exp"

View File

@ -1 +0,0 @@
source "lib/completions/head.exp"

View File

@ -1 +0,0 @@
source "lib/completions/hg.exp"

View File

@ -1 +0,0 @@
source "lib/completions/iconv.exp"

View File

@ -1 +0,0 @@
source "lib/completions/id.exp"

View File

@ -1 +0,0 @@
source "lib/completions/identify.exp"

View File

@ -1 +0,0 @@
source "lib/completions/ifdown.exp"

View File

@ -1 +0,0 @@
source "lib/completions/ifup.exp"

View File

@ -1 +0,0 @@
source "lib/completions/indent.exp"

View File

@ -1 +0,0 @@
source "lib/completions/info.exp"

View File

@ -1 +0,0 @@
source "lib/completions/inject.exp"

View File

@ -1 +0,0 @@
source "lib/completions/insmod.exp"

View File

@ -1 +0,0 @@
source "lib/completions/invoke-rc.d.exp"

View File

@ -1 +0,0 @@
source "lib/completions/irb.exp"

View File

@ -1 +0,0 @@
source "lib/completions/isql.exp"

View File

@ -1 +0,0 @@
source "lib/completions/javac.exp"

View File

@ -1 +0,0 @@
source "lib/completions/javadoc.exp"

View File

@ -1 +0,0 @@
source "lib/completions/killall.exp"

View File

@ -1 +0,0 @@
source "lib/completions/kldload.exp"

View File

@ -1 +0,0 @@
source "lib/completions/kldunload.exp"

View File

@ -1 +0,0 @@
source "lib/completions/kplayer.exp"

View File

@ -1 +0,0 @@
source "lib/completions/larch.exp"

View File

@ -1 +0,0 @@
source "lib/completions/ld.exp"

View File

@ -1 +0,0 @@
source "lib/completions/ldd.exp"

View File

@ -1 +0,0 @@
source "lib/completions/less.exp"

View File

@ -1 +0,0 @@
source "lib/completions/lftp.exp"

View File

@ -1 +0,0 @@
source "lib/completions/links.exp"

View File

@ -1 +0,0 @@
source "lib/completions/lisp.exp"

View File

@ -1 +0,0 @@
source "lib/completions/list_admins.exp"

View File

@ -1 +0,0 @@
source "lib/completions/list_lists.exp"

View File

@ -1 +0,0 @@
source "lib/completions/list_members.exp"

View File

@ -1 +0,0 @@
source "lib/completions/list_owners.exp"

View File

@ -1 +0,0 @@
source "lib/completions/ln.exp"

View File

@ -1 +0,0 @@
source "lib/completions/look.exp"

View File

@ -1 +0,0 @@
source "lib/completions/ls.exp"

View File

@ -1 +0,0 @@
source "lib/completions/m4.exp"

View File

@ -1 +0,0 @@
source "lib/completions/macof.exp"

View File

@ -1 +0,0 @@
source "lib/completions/mailmanctl.exp"

View File

@ -1 +0,0 @@
source "lib/completions/mailsnarf.exp"

View File

@ -1 +0,0 @@
source "lib/completions/man.exp"

View File

@ -1 +0,0 @@
source "lib/completions/mc.exp"

View File

@ -1 +0,0 @@
source "lib/completions/mcrypt.exp"

View File

@ -1 +0,0 @@
source "lib/completions/md5sum.exp"

View File

@ -1 +0,0 @@
source "lib/completions/mdecrypt.exp"

View File

@ -1 +0,0 @@
source "lib/completions/mencoder.exp"

View File

@ -1 +0,0 @@
source "lib/completions/mkdir.exp"

Some files were not shown because too many files have changed in this diff Show More