Improved filename based man page completion.

This commit is contained in:
Ville Skyttä 2009-01-12 00:23:32 +02:00
parent ff5247fac8
commit b80e3f66a8
2 changed files with 17 additions and 6 deletions

View File

@ -848,7 +848,9 @@ complete -F _insmod $filenames insmod modprobe modinfo
-o $UNAME = OpenBSD ] &&
_man()
{
local cur prev sect manpath UNAME
local cur prev sect manpath manext UNAME
manext="@([0-9lnp]|[0-9][px]|man)?(.@(gz|bz2|lzma))"
COMPREPLY=()
cur=`_get_cword`
@ -856,15 +858,15 @@ _man()
case $prev in
-l)
_filedir;
_filedir $manext
return 0;
esac
_expand || return 0
# default completion if parameter contains /
# file based completion if parameter contains /
if [[ "$cur" == */* ]]; then
_filedir
_filedir $manext
return 0
fi
@ -898,10 +900,18 @@ _man()
# weed out directory path names and paths to man pages
COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
# strip suffix from man pages
COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2)} )
COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|lzma)} )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
[[ "$prev" != [0-9ln] ]] && _filedir '[0-9ln]'
if [[ "$prev" != @([0-9lnp]|[0-9][px]) ]]; then
# File based completion for the rest, prepending ./ if needed
# (man 1.6f needs that for man pages in current dir)
local start=${#COMPREPLY[@]}
_filedir $manext
for (( i=$start; i < ${#COMPREPLY[@]}; i++ )); do
[[ ${COMPREPLY[i]} == */* ]] || COMPREPLY[i]=./${COMPREPLY[i]}
done
fi
return 0
}

1
debian/changelog vendored
View File

@ -61,6 +61,7 @@ bash-completion (200811xx) UNRELEASED; urgency=low
(Ville Skyttä).
* Improved features and performance of yum completion (Ville Skyttä).
* Added support for p (POSIX) and x (x.org) man sections (Ville Skyttä).
* Improved filename based man page completion (Ville Skyttä).
* Merge from Gentoo:
- fix 'find' completion so that it properly completes on -?(i)whilename.
Patch by Ciaran McCreesh.