- make _man() work on Darwin systems (MacOS X)
This commit is contained in:
parent
e02d36ec3b
commit
5eaea3f95e
@ -1,6 +1,6 @@
|
|||||||
# bash_completion - some programmable completion functions for bash 2.05a
|
# bash_completion - some programmable completion functions for bash 2.05a
|
||||||
#
|
#
|
||||||
# $Id: bash_completion,v 1.174 2002/03/02 01:13:23 ianmacd Exp $
|
# $Id: bash_completion,v 1.175 2002/03/02 01:56:21 ianmacd Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||||
#
|
#
|
||||||
@ -387,15 +387,13 @@ _insmod()
|
|||||||
}
|
}
|
||||||
[ $OS = Linux ] && complete -F _insmod -o filenames insmod modprobe
|
[ $OS = Linux ] && complete -F _insmod -o filenames insmod modprobe
|
||||||
|
|
||||||
# man(1) completion. This is Linux specific, in that 'man <section> <page>'
|
# man(1) completion. This is Linux and Darwin specific, in that
|
||||||
# is the expected syntax. This allows one to do something like
|
# 'man <section> <page>' is the expected syntax.
|
||||||
# 'man 3 str<tab>' to obtain a list of all string handling syscalls on
|
|
||||||
# the system.
|
|
||||||
#
|
#
|
||||||
[ $OS = Linux ] &&
|
[ $OS = Linux -o $OS = Darwin ] &&
|
||||||
_man()
|
_man()
|
||||||
{
|
{
|
||||||
local cur prev sect manpath
|
local cur prev sect manpath OS
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
@ -409,7 +407,13 @@ _man()
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
manpath=$( man --path )
|
OS=$( uname -s )
|
||||||
|
if [ $OS = Linux ]; then
|
||||||
|
manpath=$( man --path )
|
||||||
|
else
|
||||||
|
manpath=$MANPATH
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$manpath" ]; then
|
if [ -z "$manpath" ]; then
|
||||||
COMPREPLY=( $( compgen -c -- $cur ) )
|
COMPREPLY=( $( compgen -c -- $cur ) )
|
||||||
return 0
|
return 0
|
||||||
@ -426,7 +430,7 @@ _man()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# redirect stderr for when path doesn't exist
|
# redirect stderr for when path doesn't exist
|
||||||
COMPREPLY=( $( eval ls "$manpath" 2>/dev/null ) )
|
COMPREPLY=( $( eval \ls "$manpath" 2>/dev/null ) )
|
||||||
# weed out directory path names and paths to man pages
|
# weed out directory path names and paths to man pages
|
||||||
COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
|
COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
|
||||||
# strip suffix from man pages
|
# strip suffix from man pages
|
||||||
@ -440,7 +444,7 @@ _man()
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
[ $OS = Linux ] && complete -F _man -o filenames man
|
[ $OS = Linux -o $OS = Darwin ] && complete -F _man -o filenames man
|
||||||
|
|
||||||
# kill(1) completion
|
# kill(1) completion
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user