#!/bin/sh

# mp
# A script to run MetaPost and preview the PostScript output.
# Miroslav Broz (miroslav.broz@email.cz), Apr 4th 2006

if [ "$1" = "" ]; then
  echo "A script to run MetaPost and preview the PostScript output (run 'gv tmp.ps &' after this)."
  echo "Usage: mp FILE[.mp] [BEGINFIG_ID]"
  exit
fi

FILE=`echo $1 | awk '{ gsub(".mp",""); print; }'`
if [ "$2" = "" ]; then
  MP=1
else
  MP=$2
fi

TEX=csplain; export TEX

echo "prologues:=0;" > prologues.mp
echo "\\input epsf\\nopagenumbers\\noindent\\epsfbox{$FILE.$MP}\\end" > tmp.tex

mpost $FILE
csplain tmp
dvips -o tmp.ps tmp.dvi


