1#!/bin/sh 2# 3# tm_gnuplot 4# ========== 5# bash script for interfacing gnuplot from TeXmacs 6# needs option --texmacs for compatibility with TeXmacs interface convention and user information 7# 8# usage within TeXmacs: 9# ===================== 10# write gnuplot-commands within the input line, 11# use as many commands as necessary, 12# divide them by the ~ chararacter, because the ENTER key terminates the input and sends it to gnuplot. 13# output is the graph made by gnuplot. 14 15#ECHO=echo 16ECHO=/bin/echo 17 18if [ "$1" != "--texmacs" ] 19then 20 $ECHO tm_gnuplot. This script should be started only from TeXmacs. 21 exit 22fi 23 24# control characters 25tmp=`$ECHO DATA_BEGIN=X DATA_END=Y DATA_ESCAPE=Z | tr "XYZ" "\002\005\027" ` 26eval $tmp 27 28# defining pipe-gnuplot binary path and name 29# for unix/linux environments 30GNUPLOT_PATH= 31PIPE_GNUPLOT=gnuplot 32# for windows/cygwin environment 33# GNUPLOT_PATH=/cygdrive/w/tex_cd/programme/gnuplot/ 34# PIPE_GNUPLOT=pgnuplot.exe 35 36# defining temporary postscript file directory 37TEMP_DIR=/tmp 38if [ -d $TEMP_DIR ] 39then 40 : 41else 42 mkdir $TEMP_DIR 43fi 44 45# defining temporary postscript file name 46TEMP_PS_NAME=temp.eps 47 48# standard initialization of GNUplot 49init='reset~set terminal postscript eps enhanced ~set output "'$TEMP_DIR/$TEMP_PS_NAME'"~set size 1,1~set autoscale~' 50 51# startup banner 52$ECHO -n $DATA_BEGIN 53$ECHO verbatim:This is a TeXmacs interface for GNUplot. 54 55# prompt-input-gnuplot-output loop 56while [ 1 ]; do 57 # prompt 58 $ECHO -n $DATA_BEGIN 59 $ECHO -n channel:prompt 60 $ECHO -n $DATA_END 61 $ECHO -n GNUplot'] ' 62 $ECHO -n $DATA_END 63 64 #read a line from stdin 65 read input 66 67 #concat init string and input string 68 input=$init$input 69 70 #for debugging purposes 71 #$ECHO $input | tr "~" "\n" | tee tm_gnuplot.log | $GNUPLOT_PATH$PIPE_GNUPLOT 72 #$ECHO -E "$input" | tr "~" "\n" | $GNUPLOT_PATH$PIPE_GNUPLOT 73 $ECHO "$input" | tr "~" "\n" | $GNUPLOT_PATH$PIPE_GNUPLOT 74 75 $ECHO -n $DATA_BEGIN 76 $ECHO -n verbatim: 77 78 $ECHO -n $DATA_BEGIN 79 $ECHO -n ps: 80 cat $TEMP_DIR/$TEMP_PS_NAME 81 $ECHO -n $DATA_END 82 #$ECHO -ne "\n" 83 $ECHO "" 84 85 rm $TEMP_DIR/$TEMP_PS_NAME 86done 87