]> git.lyx.org Git - lyx.git/blob - lib/scripts/bash_completion
3b5b0cb529cda4cafe4c0931bdcc0ce51f8ba992
[lyx.git] / lib / scripts / bash_completion
1 # lyx(1) completion 
2 # Copyleft 2010 Cengiz Gunay <cengique@users.sf.net>
3
4 have lyx &&
5 _lyx()
6 {
7         local cur g last
8
9         # turn on extglob       
10         shopt -q extglob && g=1
11         test $g -eq 0 && shopt -s extglob
12
13         COMPREPLY=()
14         cur=${COMP_WORDS[COMP_CWORD]}
15
16         local dbg_cmds=( "none info init key gui \
17                         parser lyxrc kbmap latex mathed font tclass \
18                         lyxvc lyxserver roff action lyxlex depend insets \
19                         files workarea insettext graphics changes \
20                         external painting debug any" )
21
22         #echo "cmds: '$dbg_cmds'"
23
24         if [[ $COMP_CWORD > 1 ]]; then
25                 last=${COMP_WORDS[$(($COMP_CWORD - 1))]}
26         else
27                 last=''
28         fi
29
30         case "$last" in
31         +\(--export|-e\))
32                 _filedir '+(pdf[1234]|PDF[1234]|pdf|PDF|ps|PS|xhtml|XHTML)';;
33         -dbg)
34                 # check for multiple debug commands
35                 if [[ $cur == *,* ]]; then #
36                         COMPREPLY=( $( compgen -W '$dbg_cmds' \
37                                                -P ${cur%,*}, -- ${cur##*,} ) )
38                 else
39                         COMPREPLY=( $( compgen -W '$dbg_cmds' -- $cur ) )
40                 fi;;
41         *)
42           case "$cur" in
43           -*)
44                 # LyX command line options
45                 COMPREPLY=( $( compgen -W '-help -userdir -sysdir \
46                                 -geometry -dbg -x --execute -e --export \
47                                 -i --import -version -batch ' -- $cur ) ) ;;
48           
49           *)
50                 # LyX files
51                 _filedir '@(lyx)' 
52           esac
53         esac
54
55         # turn it off if necessary
56         test $g -eq 0 && shopt -u extglob
57
58 }
59 [ "${have:-}" ] && complete -F _lyx $filenames lyx