From eb4786c80d9db2219e1c64d18c81f3c7c4fdc8b6 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Tue, 6 Apr 2010 12:01:24 +0000 Subject: [PATCH] =?UTF-8?q?New=20version=20of=20bash=5Fcompletion=20from?= =?UTF-8?q?=20Cengiz=20G=C3=BCnay.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34067 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/scripts/bash_completion | 51 +++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/lib/scripts/bash_completion b/lib/scripts/bash_completion index bf18ffc54c..3b5b0cb529 100644 --- a/lib/scripts/bash_completion +++ b/lib/scripts/bash_completion @@ -1,40 +1,59 @@ # lyx(1) completion -# Modified inkscape template of allali@univ-mlv.fr -# by cengique@users.sf.net +# Copyleft 2010 Cengiz Gunay have lyx && _lyx() { local cur g last + # turn on extglob + shopt -q extglob && g=1 + test $g -eq 0 && shopt -s extglob + COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} + local dbg_cmds=( "none info init key gui \ + parser lyxrc kbmap latex mathed font tclass \ + lyxvc lyxserver roff action lyxlex depend insets \ + files workarea insettext graphics changes \ + external painting debug any" ) + + #echo "cmds: '$dbg_cmds'" + 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 - -*) + case "$last" in + +\(--export|-e\)) + _filedir '+(pdf[1234]|PDF[1234]|pdf|PDF|ps|PS|xhtml|XHTML)';; + -dbg) + # check for multiple debug commands + if [[ $cur == *,* ]]; then # + COMPREPLY=( $( compgen -W '$dbg_cmds' \ + -P ${cur%,*}, -- ${cur##*,} ) ) + else + COMPREPLY=( $( compgen -W '$dbg_cmds' -- $cur ) ) + fi;; + *) + case "$cur" in + -*) + # LyX command line options COMPREPLY=( $( compgen -W '-help -userdir -sysdir \ -geometry -dbg -x --execute -e --export \ - -i --import -version -batch' -- $cur ) ) ;; - *) + -i --import -version -batch ' -- $cur ) ) ;; + + *) + # LyX files _filedir '@(lyx)' - esac - fi + esac + esac # turn it off if necessary test $g -eq 0 && shopt -u extglob } -[ "${have:-}" ] && complete -F _lyxz $filenames lyx +[ "${have:-}" ] && complete -F _lyx $filenames lyx