Here's an update to the zsh completion function for version 0.10.5. If
there's anything you'd like improved let me know.
I have a version that improves the -remote completion a little and adds
full -eval support (ie. it completes each option with the correct values
etc) but it's stuck on my work machine which I won't have access to for
a while and I'm, well, too lazy to rewrite it right now... ;-)
Regards,
Doug
#compdef elinks -value-,ELINKS_CONFDIR,-default- -P
-value-,(|E)LINKS_(TW|X)TERM,-default-
# ELinks 0.10.5
local curcontext="$curcontext" state line expl ret=1
typeset -A opt_args
case "$service" in
*ELINKS_CONFDIR*)
_directories && return 0
;;
*TERM*)
_terminals && return 0
;;
esac
_arguments -C -A '-*' \
'-anonymous[restrict to anonymous mode]' \
'-auto-submit[autosubmit first form]' \
'-base-session[clone internal session with given ID]:ID number:' \
'-config-dir[name of directory with configuration file]:configuration
directory:_files -/' \
'(- *)-config-dump[print default configuration file to stdout]' \
'-config-file[name of configuration file]:configuration file:_files' \
'(- *)-config-help[print help for configuration options]' \
'-default-mime-type[MIME type assumed for unknown document types]:MIME
type:_mime_types' \
'-default-keys[ignore user-defined keybindings]' \
'-dump[print formatted version of given URL to stdout]' \
'-dump-charset[codepage to use with -dump]:charset:->charset' \
'-dump-width[width of document formatted with -dump]:width:' \
'*-eval[evaluate configuration file directive]:configuration option:->eval' \
'-force-html[interpret documents of unkown types as HTML]' \
'(- *)-'{\?,h,help}'[print usage help and exit]' \
'-localhost[only permit local connections]' \
'(- *)-long-help[print detailed usage help and exit]' \
'(- *)-lookup[look up specified host]:host:_hosts' \
'-no-connect[run as separate instance]' \
'-no-home[disable use of files in ~/.elinks]' \
'-no-numbering[disable link numbering in dump output]' \
'-no-references[disable printing of link references in dump output]' \
'(- *)-remote[control an already running ELinks]:remote
command:->remote:*::URL:->urls' \
'-session-ring[connect to session ring with given ID]:ID number:' \
'-source[print the source of given URL to stdout]' \
'-touch-files[touch files in ~/.elinks when running with
-no-connect/-session-ring]' \
'-verbose[verbose level]:verbosity level:((0\:only\ show\ serious\ errors
1\:show\ serious\ errors\ and\ warnings 2\:show\ all\ messages))' \
'(- *)-version[print version information and exit]' \
'*:URL:->urls' && ret=0
local -a bookmarks shortcuts
local confdir=${ELINKS_CONFDIR:-~/.elinks}
if [[ -s $confdir/bookmarks ]]; then
bookmarks=( ${${${(f)"$(<$confdir/bookmarks)"}:#* *}/(#b)*
(*) * /$match[1]} )
fi
if [[ -s $confdir/elinks.conf ]]; then
shortcuts=(
${${(M)${(f)"$(<$confdir/elinks.conf)"}:#(#s)[[:blank:]]#set[[:blank:]]##protocol.rewrite.(dumb|smart).*}/(#b)*.(*)
=*/$match[1]} )
fi
case "$state" in
charset)
local -a charsets
charsets=(
SYSTEM 7BIT 8859_1 8859_2 8859_3 8859_4 8859_5 8859_6 8859_7 8859_8
8859_9 8859_10 8859_13 8859_14 8859_15 8859_16 CP1250 CP1251 CP1252
CP1256 CP1257 CP437 CP737 CP850 CP852 CP866 CP1125 MACROMAN MAC_LAT2
KAMEN KOI8_R KOI8_U KOI8_RU TCVN5712 VISCII UTF_8
)
_wanted charsets expl 'character set' compadd -a charsets && ret=0
;;
remote)
local -a remote_commands
remote_commands=(addBookmark openURL ping xfeDoCommand)
compset -P '*\('
if compset -S '(|\\)\)*'; then
set - -S "" "$@"
else
set - -S"${${QIPREFIX:+)}:-\)}$compstate[quote] " "$@"
fi
case $IPREFIX in
openURL*)
if compset -P "*,"; then
_wanted options expl 'option' compadd "$@" new-tab new-window && ret=0
else
compset -S ',*'
state=urls
fi
;;
addBookmark*)
unset bookmarks
state=urls
;;
ping*)
compadd "$@" "" && ret=0
;;
xfeDoCommand*)
_wanted commands expl 'command' compadd "$@" openBrowser && ret=0
;;
*)
_tags commands urls
while _tags; do
if _requested commands; then
compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}"
_wanted commands expl 'remote command' \
compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' -a \
remote_commands && ret=0
fi
if _requested urls; then
state=urls && ret=0
fi
(( ret )) || break
done
;;
esac
;;
eval)
local -a options suf
options=( ${${(M)${(f)"$(_call_program options $words[1]
-config-help)"}:#(#s) [[:lower:]]*}/(#b) ([^ ]##) */$match[1]} )
if compset -P '*='; then
_message -e values 'value'
else
compset -S '=*' || suf=( -qS '=' )
_wanted config-options expl 'configuration option' compadd -p 'set '
"[EMAIL PROTECTED]" -a options && ret=0
fi
;;
esac
if [[ "$state" = "urls" ]]; then
_alternative \
'files:file:_files' \
'bookmarks:bookmark:compadd -a bookmarks' \
'shortcuts:shortcut:compadd -a shortcuts' \
'urls:URL:_urls' && ret=0
fi
return ret
_______________________________________________
elinks-users mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-users