diff --git a/bash_completion b/bash_completion index 38241f2d..1b43e8d2 100644 --- a/bash_completion +++ b/bash_completion @@ -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 } diff --git a/debian/changelog b/debian/changelog index 476b530e..f2433e14 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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.