2009-05-27 19:01:26 +02:00
|
|
|
# bash completion for info
|
|
|
|
|
2011-04-05 00:35:51 +03:00
|
|
|
have info || return
|
|
|
|
|
2009-05-27 19:01:26 +02:00
|
|
|
_info()
|
|
|
|
{
|
2011-04-20 17:13:48 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2009-10-04 19:42:50 +02:00
|
|
|
|
|
|
|
_expand || return 0
|
|
|
|
|
|
|
|
# default completion if parameter contains /
|
|
|
|
if [[ "$cur" == */* ]]; then
|
|
|
|
_filedir
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2011-04-20 17:13:48 +03:00
|
|
|
local i infopath=/usr/share/info
|
2009-10-04 19:42:50 +02:00
|
|
|
|
|
|
|
if [ "${INFOPATH: -1:1}" == ':' ]; then
|
|
|
|
infopath=${INFOPATH}${infopath}
|
|
|
|
elif [ ${INFOPATH:+set} ]; then
|
|
|
|
infopath=$INFOPATH
|
|
|
|
fi
|
|
|
|
|
|
|
|
infopath=$infopath:
|
|
|
|
if [ -n "$cur" ]; then
|
|
|
|
infopath="${infopath//://$cur* }"
|
|
|
|
else
|
|
|
|
infopath="${infopath//:// }"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# redirect stderr for when path doesn't exist
|
|
|
|
COMPREPLY=( $( eval command ls "$infopath" 2>/dev/null ) )
|
|
|
|
# weed out directory path names and paths to info pages
|
|
|
|
COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
|
|
|
|
# weed out info dir file
|
|
|
|
for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do
|
|
|
|
if [ "${COMPREPLY[$i]}" == 'dir' ]; then
|
|
|
|
unset COMPREPLY[$i];
|
|
|
|
fi;
|
|
|
|
done
|
|
|
|
# strip suffix from info pages
|
|
|
|
COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|xz|lzma)} )
|
|
|
|
COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
|
|
|
|
|
|
|
|
return 0
|
2009-05-27 19:01:26 +02:00
|
|
|
} &&
|
2010-11-01 19:26:53 +02:00
|
|
|
complete -F _info info
|
2009-10-01 20:54:51 +03:00
|
|
|
|
|
|
|
# Local variables:
|
|
|
|
# mode: shell-script
|
2009-10-04 19:42:50 +02:00
|
|
|
# sh-basic-offset: 4
|
2009-10-01 20:54:51 +03:00
|
|
|
# sh-indent-comment: t
|
2009-10-04 19:42:50 +02:00
|
|
|
# indent-tabs-mode: nil
|
2009-10-01 20:54:51 +03:00
|
|
|
# End:
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|