#!/bin/bash # # Syntax: gv [-h] [postscript_file [...]] # # Purpose: Shows one or more postscript files using kghostview, gsview, # ghostview, or okular. # 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: Jun 30, 2016 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 /usr/bin/gv) if [ -z "$GV_COMMAND" ] 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) if [ -z "$GV_COMMAND" ] then GV_COMMAND=$(type -p okular) if [ -z "$GV_COMMAND" ] then echo >&2 echo >&2 "ERROR: No ps viewer found on this system." echo >&2 exit 1 fi fi fi fi fi if [ $# -eq 0 ]; then psfile=$((ls -t *.ps *.eps | head -n 1) 2>/dev/null) if [ -n "$psfile" ]; then LANG=C $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