#!/bin/bash # # Syntax: gv [-h] [postscript_file [...]] # # Purpose: Shows one or more postscript files using gv, kghostview, gsview, # or ghostview. # If no input argument is given, the most recently changed .ps # or .eps file in the current directory is shown. # The -h flag shows the help info for this command. # # See also: gvl # # Note: You may have to include a line like # alias gv=~/your_bin_dir/gv # in your login files (e.g., .bashrc) in order to be able to use # this command. # Created: Oct 12, 1998 by Bart De Schutter # Last revised: Sep 22, 2008 by Bart De Schutter # Status: public # Category: postscript, latex if [ $# -ge 1 -a "$1" = "-h" ]; then sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 fi GV_COMMAND=$(type -p gv) if [[ -z "$GV_COMMAND" || "$GV_COMMAND" == "$0" ]] then GV_COMMAND=$(type -p kghostview) if [ -z "$GV_COMMAND" ] then GV_COMMAND=$(type -p gsview) if [ -z "$GV_COMMAND" ] then GV_COMMAND=$(type -p ghostview) else echo >&2 echo >&2 "ERROR: No ps viewer found on this system." echo >&2 exit 1 fi fi fi if [ $# -eq 0 ]; then psfile=$((ls -t *.ps *.eps | head -n 1) 2>/dev/null) if [ -n "$psfile" ]; then $GV_COMMAND "$psfile" & else echo "No .ps or .eps files found." fi else for psfile in "$@" do echo "Viewing $psfile" $GV_COMMAND "$psfile" done fi