break part of _gcc() into _longopt() and use this for ldd, wget, bash, id and
info completion, as demonstrated by Manu Rouat <emmanuel.rouat@wanadoo.fr>
This commit is contained in:
parent
318d304194
commit
bacf3a3e4c
@ -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.119 2002/02/15 23:53:58 ianmacd Exp $
|
# $Id: bash_completion,v 1.120 2002/02/16 01:13:00 ianmacd Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||||
#
|
#
|
||||||
@ -1719,6 +1719,34 @@ _psql ()
|
|||||||
}
|
}
|
||||||
[ "$have" ] && complete -F _psql psql
|
[ "$have" ] && complete -F _psql psql
|
||||||
|
|
||||||
|
_longopt()
|
||||||
|
{
|
||||||
|
case "$2" in
|
||||||
|
-*)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
\~*)
|
||||||
|
eval cmd=$1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
cmd="$1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[ "$4" = no_completion ] && return 0
|
||||||
|
|
||||||
|
COMPREPLY=( $( "$cmd" --help | sed -e '/--/!d' \
|
||||||
|
-e 's/.*--\([^ ]*\).*/--\1/'| \
|
||||||
|
grep ^"$2" | sort -u ) )
|
||||||
|
unset cmd
|
||||||
|
}
|
||||||
|
complete -o default -F _longopt ldd wget bash id info
|
||||||
|
|
||||||
# gcc(1) completion by Phil Edwards <phil@jaj.com>
|
# gcc(1) completion by Phil Edwards <phil@jaj.com>
|
||||||
#
|
#
|
||||||
# The only unusual feature is that we don't parse "gcc --help -v" output
|
# The only unusual feature is that we don't parse "gcc --help -v" output
|
||||||
@ -1732,26 +1760,13 @@ _psql ()
|
|||||||
have gcc &&
|
have gcc &&
|
||||||
_gcc()
|
_gcc()
|
||||||
{
|
{
|
||||||
local cc gcc backend
|
local cc cmd backend
|
||||||
|
|
||||||
case "$2" in
|
[[ "$2" != -* ]] && return 0
|
||||||
-*)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$1" in
|
_longopt "$1" "$2" "" no_completion
|
||||||
\~*)
|
|
||||||
eval gcc=$1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
gcc="$1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$gcc" in
|
case "$cmd" in
|
||||||
gcj)
|
gcj)
|
||||||
backend=jc1
|
backend=jc1
|
||||||
;;
|
;;
|
||||||
@ -1763,14 +1778,14 @@ _gcc()
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
cc=$( $gcc -print-prog-name=$backend )
|
cc=$( $cmd -print-prog-name=$backend )
|
||||||
|
|
||||||
# sink stderr:
|
# sink stderr:
|
||||||
# for C/C++/ObjectiveC it's useless
|
# for C/C++/ObjectiveC it's useless
|
||||||
# for FORTRAN/Java it's an error
|
# for FORTRAN/Java it's an error
|
||||||
COMPREPLY=( $( $cc --help 2>/dev/null | tr '\t' ' ' | \
|
COMPREPLY=( $( $cc --help 2>/dev/null | tr '\t' ' ' | \
|
||||||
sed -e '/^ *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | \
|
sed -e '/^ *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | \
|
||||||
grep ^"$2" | sort -u ) )
|
grep ^"$2" | sort -u ) )
|
||||||
}
|
}
|
||||||
[ "$have" ] && complete -o default -F _gcc gcc g++ c++ g77 gcj
|
[ "$have" ] && complete -o default -F _gcc gcc g++ c++ g77 gcj
|
||||||
[ $OS = Linux ] && complete -o default -F _gcc cc
|
[ $OS = Linux ] && complete -o default -F _gcc cc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user