2010-04-01 09:40:33 +00:00
|
|
|
# lyx(1) completion
|
2010-04-06 12:01:24 +00:00
|
|
|
# Copyleft 2010 Cengiz Gunay <cengique@users.sf.net>
|
2010-04-01 09:40:33 +00:00
|
|
|
|
2022-03-26 10:16:38 +00:00
|
|
|
_have lyx &&
|
2010-04-01 09:40:33 +00:00
|
|
|
_lyx()
|
|
|
|
{
|
2010-04-01 16:50:29 +00:00
|
|
|
local cur g last
|
2010-04-01 09:40:33 +00:00
|
|
|
|
2010-04-06 12:01:24 +00:00
|
|
|
# turn on extglob
|
|
|
|
shopt -q extglob && g=1
|
|
|
|
test $g -eq 0 && shopt -s extglob
|
|
|
|
|
2010-04-01 09:40:33 +00:00
|
|
|
COMPREPLY=()
|
|
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
|
|
2010-04-06 12:01:24 +00:00
|
|
|
local dbg_cmds=( "none info init key gui \
|
|
|
|
parser lyxrc kbmap latex mathed font tclass \
|
2012-09-25 05:13:40 +00:00
|
|
|
lyxvc lyxserver action lyxlex depend insets \
|
2015-07-08 08:57:04 +00:00
|
|
|
files workarea clipboard graphics changes \
|
2012-09-25 05:13:40 +00:00
|
|
|
external painting debug any undo scrolling \
|
|
|
|
macros rtl locale selection find" )
|
|
|
|
|
|
|
|
# The below code would get rid of the hardcoding, but could be fragile:
|
|
|
|
# local dbg_cmds=$( lyx -dbg | awk '{print $2}' | tail -n +2 )
|
|
|
|
# If it is ever used, please put a comment in the code for -dbg output
|
|
|
|
# about breaking auto completion if the format is changed.
|
2010-04-06 12:01:24 +00:00
|
|
|
|
|
|
|
#echo "cmds: '$dbg_cmds'"
|
|
|
|
|
2010-04-01 16:50:29 +00:00
|
|
|
if [[ $COMP_CWORD > 1 ]]; then
|
|
|
|
last=${COMP_WORDS[$(($COMP_CWORD - 1))]}
|
|
|
|
else
|
|
|
|
last=''
|
|
|
|
fi
|
|
|
|
|
2010-04-06 12:01:24 +00:00
|
|
|
case "$last" in
|
2022-04-01 20:56:57 +00:00
|
|
|
# check for export fmt. Short list presented
|
|
|
|
--export|-e|-E|--export-to)
|
|
|
|
COMPREPLY=( $(compgen -W 'latex pdflatex luatex xetex xhtml' -- $cur) );;
|
|
|
|
--import|-i)
|
|
|
|
# check for import format. Short list presented
|
|
|
|
# (-i | --import) requireas a second input _filedir
|
|
|
|
# must point to *tex | *text | *xhtml depending on choice
|
|
|
|
COMPREPLY=( $(compgen -W 'latex text luatex xetex xhtml' -- $cur) );;
|
2010-04-06 12:01:24 +00:00
|
|
|
-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;;
|
2012-09-25 05:13:40 +00:00
|
|
|
--force-overwrite|-f)
|
|
|
|
COMPREPLY=( $( compgen -W 'all main none' -- $cur ) );;
|
2022-04-01 20:56:57 +00:00
|
|
|
|
|
|
|
latex|xetex|luatex|text|xhtml)
|
|
|
|
# we need to know if previous token was -i or -E
|
|
|
|
if [[ $COMP_CWORD > 2 ]]; then
|
|
|
|
prev=${COMP_WORDS[$(($COMP_CWORD - 2))]}
|
|
|
|
else
|
|
|
|
prev=''
|
|
|
|
fi
|
|
|
|
if (test $prev=="-i")|(test $prev=="-E"); then
|
|
|
|
case $last in
|
|
|
|
text)
|
|
|
|
_filedir '@(txt)' ;;
|
|
|
|
latex|luatex|xetex)
|
|
|
|
_filedir '@(tex)' ;;
|
|
|
|
xhtml)
|
|
|
|
_filedir '@(xhtml)' ;;
|
|
|
|
esac
|
|
|
|
fi;;
|
|
|
|
pdflatex)
|
|
|
|
# we need to know if previous token was -E
|
|
|
|
if [[ $COMP_CWORD > 2 ]]; then
|
|
|
|
prev=${COMP_WORDS[$(($COMP_CWORD - 2))]}
|
|
|
|
else
|
|
|
|
prev=''
|
|
|
|
fi
|
|
|
|
if test $prev == "-E"; then
|
|
|
|
_filedir '@(pdf)'
|
|
|
|
fi;;
|
2010-04-06 12:01:24 +00:00
|
|
|
*)
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
# LyX command line options
|
2010-04-01 09:40:33 +00:00
|
|
|
COMPREPLY=( $( compgen -W '-help -userdir -sysdir \
|
|
|
|
-geometry -dbg -x --execute -e --export \
|
2012-09-25 05:13:40 +00:00
|
|
|
-i --import -version -batch -E --export-to \
|
|
|
|
-f --force-overwrite -n --no-remote \
|
|
|
|
-r --remote ' -- $cur ) ) ;;
|
2010-04-06 12:01:24 +00:00
|
|
|
|
|
|
|
*)
|
|
|
|
# LyX files
|
2022-04-01 20:56:57 +00:00
|
|
|
_filedir '@(lyx)'
|
2010-04-06 12:01:24 +00:00
|
|
|
esac
|
|
|
|
esac
|
2010-04-01 16:50:29 +00:00
|
|
|
|
|
|
|
# turn it off if necessary
|
|
|
|
test $g -eq 0 && shopt -u extglob
|
2010-04-01 09:40:33 +00:00
|
|
|
|
2022-03-26 10:16:38 +00:00
|
|
|
} && complete -F _lyx $filenames lyx
|
2022-04-01 20:56:57 +00:00
|
|
|
|