#!/bin/sh
#
# Print to a file from within PriMa
#
# Maybe you have to change some settings
#

# file to save filename in
SAVED_FILENAME=~/.prima-filename

# prompt text
PROMPT="Output Filename: "
#PROMPT="Ausgabe-Datei: "

#set default filename
if [ -f $SAVED_FILENAME ] ; then
  DEFAULT_FILENAME=$(cat $SAVED_FILENAME)
else
  DEFAULT_FILENAME=~/PriMa-Output.ps
fi

# get new filename using PriMa.input 
NEW_FILENAME=$(PriMa.input "$PROMPT" "$DEFAULT_FILENAME" "PriMa File")

if [ $? = 1 ]; then
  exit 1
else	
  echo $NEW_FILENAME > $SAVED_FILENAME

#
# Copy output file to destination 
# 
  cp $1 $NEW_FILENAME
  exit $?
fi
