2 # Copyleft 2010 Cengiz Gunay <cengique@users.sf.net>
10 shopt -q extglob && g=1
11 test $g -eq 0 && shopt -s extglob
14 cur=${COMP_WORDS[COMP_CWORD]}
16 local dbg_cmds=( "none info init key gui \
17 parser lyxrc kbmap latex mathed font tclass \
18 lyxvc lyxserver action lyxlex depend insets \
19 files workarea clipboard graphics changes \
20 external painting debug any undo scrolling \
21 macros rtl locale selection find" )
23 # The below code would get rid of the hardcoding, but could be fragile:
24 # local dbg_cmds=$( lyx -dbg | awk '{print $2}' | tail -n +2 )
25 # If it is ever used, please put a comment in the code for -dbg output
26 # about breaking auto completion if the format is changed.
28 #echo "cmds: '$dbg_cmds'"
30 if [[ $COMP_CWORD > 1 ]]; then
31 last=${COMP_WORDS[$(($COMP_CWORD - 1))]}
38 _filedir '+(pdf[1234]|PDF[1234]|pdf|PDF|ps|PS|xhtml|XHTML)';;
40 # check for multiple debug commands
41 if [[ $cur == *,* ]]; then #
42 COMPREPLY=( $( compgen -W '$dbg_cmds' \
43 -P ${cur%,*}, -- ${cur##*,} ) )
45 COMPREPLY=( $( compgen -W '$dbg_cmds' -- $cur ) )
48 COMPREPLY=( $( compgen -W 'all main none' -- $cur ) );;
52 # LyX command line options
53 COMPREPLY=( $( compgen -W '-help -userdir -sysdir \
54 -geometry -dbg -x --execute -e --export \
55 -i --import -version -batch -E --export-to \
56 -f --force-overwrite -n --no-remote \
57 -r --remote ' -- $cur ) ) ;;
65 # turn it off if necessary
66 test $g -eq 0 && shopt -u extglob
69 [ "${have:-}" ] && complete -F _lyx $filenames lyx