Skip to content

Instantly share code, notes, and snippets.

@linktohack
Last active October 20, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linktohack/169a93109e7a1359867e to your computer and use it in GitHub Desktop.
Save linktohack/169a93109e7a1359867e to your computer and use it in GitHub Desktop.
vim/emacs edit current region in lyx
#!/bin/bash
TMPNAME=$(mktemp -t lyxit)
tee ${TMPNAME}.tex 2>/dev/null 1>/dev/null
tex2lyx ${TMPNAME}.tex 2>/dev/null 1>/dev/null
lyx ${TMPNAME}.lyx 2>/dev/null 1>/dev/null
lyx -e latex ${TMPNAME}.lyx 2>/dev/null 1>/dev/null
sed -e '1,/\begin{document}/d' -e '/\end{document}/,$d' ${TMPNAME}.tex \
| sed -e '/./,$!d' -e ':a' -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba'
rm -rf ${TMPNAME}.{,tex,lyx}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment