]> git.lyx.org Git - lyx.git/commitdiff
Next patch from Cengiz
authorPavel Sanda <sanda@lyx.org>
Thu, 1 Apr 2010 16:50:29 +0000 (16:50 +0000)
committerPavel Sanda <sanda@lyx.org>
Thu, 1 Apr 2010 16:50:29 +0000 (16:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34008 a592a061-630c-0410-9148-cb99ea01b6c8

lib/scripts/bash_completion

index 8236beb1a6cbb2c0b7579924d835a7805bb2fb93..bf18ffc54c0e32ed39a02825672537911a0d1c9c 100644 (file)
@@ -5,18 +5,36 @@
 have lyx &&
 _lyx()
 {
-        local cur
+        local cur g last
 
         COMPREPLY=()
         cur=${COMP_WORDS[COMP_CWORD]}
 
-        if [[ "$cur" == -* ]]; then
+       if [[ $COMP_CWORD > 1 ]]; then
+               last=${COMP_WORDS[$(($COMP_CWORD - 1))]}
+       else
+               last=''
+       fi
+
+       # turn on extglob
+       shopt -q extglob && g=1
+       test $g -eq 0 && shopt -s extglob
+
+       if [[ $last == +(--export|-e) ]]; then #'+(--export|-e)'
+               _filedir '+(pdf[1234]|PDF[1234]|pdf|PDF|ps|PS|xhtml|XHTML)'
+       else
+        case "$cur" in
+        -*)
                 COMPREPLY=( $( compgen -W '-help -userdir -sysdir \
                                -geometry -dbg -x --execute -e --export \
-                               -i --import -version -batch' -- $cur ) ) 
-        else
-                _filedir '@(lyx)'
-        fi
+                               -i --import -version -batch' -- $cur ) ) ;;
+        *)
+                _filedir '@(lyx)' 
+        esac
+       fi
+
+       # turn it off if necessary
+       test $g -eq 0 && shopt -u extglob
 
 }
-[ "${have:-}" ] && complete -F _lyx $filenames lyx
+[ "${have:-}" ] && complete -F _lyxz $filenames lyx