2000-04-17 10:22:44 +02:00
|
|
|
#compdef -value- -array-value-
|
1999-11-02 13:51:20 +01:00
|
|
|
|
|
|
|
_value () {
|
2000-04-17 10:22:44 +02:00
|
|
|
# You can customize completion for different parameters by writing a
|
2000-07-26 10:16:39 +02:00
|
|
|
# function `_value:<name>', where <name> is the name of the parameter.
|
|
|
|
# When completing values of elements of associative arrays, we first
|
|
|
|
# search for a function `_value:<assoc>-<key>' and then for
|
|
|
|
# `_value:<assoc>', so it's simple to define different functions
|
|
|
|
# for different keys or one function for a whole association.
|
2000-04-17 10:22:44 +02:00
|
|
|
|
1999-11-02 13:51:20 +01:00
|
|
|
if (( $+functions[_value:$compstate[parameter]] )); then
|
|
|
|
"_value:$compstate[parameter]" "$@"
|
2000-07-26 10:16:39 +02:00
|
|
|
elif (( $+functions[_value:${compstate[parameter]%%-*}] )); then
|
|
|
|
"_value:${compstate[parameter]%%-*}" "$@"
|
2000-04-17 10:22:44 +02:00
|
|
|
elif [[ "$compstate[parameter]" != *-* &&
|
|
|
|
"${(Pt)${compstate[parameter]}}" = assoc* ]]; then
|
|
|
|
if (( CURRENT & 1 )); then
|
|
|
|
_wanted association-keys expl 'association key' \
|
2000-05-31 11:38:25 +02:00
|
|
|
compadd -k "$compstate[parameter]"
|
2000-04-17 10:22:44 +02:00
|
|
|
else
|
|
|
|
compstate[parameter]="${compstate[parameter]}-${words[CURRENT-1]}"
|
|
|
|
_value "$@"
|
|
|
|
fi
|
1999-11-02 13:51:20 +01:00
|
|
|
else
|
2000-04-17 10:22:44 +02:00
|
|
|
local pats
|
|
|
|
|
|
|
|
if { zstyle -a ":completion:${curcontext}:" assign-list pats &&
|
|
|
|
[[ "$compstate[parameter]" = (${(j:|:)~pats}) ]] } ||
|
|
|
|
[[ "$PREFIX$SUFFIX" = *:* ]]; then
|
|
|
|
compset -P '*:'
|
|
|
|
compset -S ':*'
|
2000-04-18 14:26:30 +02:00
|
|
|
_default -r '\-\n\t /:' "$@"
|
2000-04-17 10:22:44 +02:00
|
|
|
else
|
|
|
|
_default "$@"
|
|
|
|
fi
|
1999-11-02 13:51:20 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_value:CPPFLAGS () {
|
|
|
|
compset -q
|
|
|
|
if compset -P '-I'; then
|
|
|
|
_files -/ "$@"
|
|
|
|
else
|
|
|
|
_default "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_value:LDFLAGS () {
|
|
|
|
compset -q
|
|
|
|
if compset -P '-L'; then
|
|
|
|
_files -/ "$@"
|
|
|
|
elif compset -P '-R'; then
|
|
|
|
compset -P '*:'
|
2000-04-17 10:22:44 +02:00
|
|
|
compset -S ':*'
|
2000-04-18 14:26:30 +02:00
|
|
|
_files -/ -S/ -r '\n\t\- /:' "$@"
|
1999-11-02 13:51:20 +01:00
|
|
|
else
|
|
|
|
_default "$@"
|
|
|
|
fi
|
|
|
|
}
|
2000-04-17 10:22:44 +02:00
|
|
|
|
|
|
|
_value "$@"
|