diff --git a/Makefile b/Makefile index dc8c743..5f494e6 100755 --- a/Makefile +++ b/Makefile @@ -29,6 +29,8 @@ help: @echo "" ; @echo " latex-edit: edit main.tex " ; @echo "" ; + @echo " latex-view: view main.pdf " ; + @echo "" ; @echo " project-start: start service " ; @echo "" ; @echo " project-stop: shutdown service" ; @@ -56,6 +58,9 @@ latex-edit: latex-build: @cd xelatex; ./bin/make-clean-ant-compile.sh 2>/dev/null ; true +latex-view: + @cd xelatex; ./bin/latex-view.sh 2>/dev/null ; true + latex-bib: @cd xelatex; ./bin/make-bib.sh 2>/dev/null ; true diff --git a/xelatex/bin/latex-view.sh b/xelatex/bin/latex-view.sh new file mode 100755 index 0000000..8aaa12a --- /dev/null +++ b/xelatex/bin/latex-view.sh @@ -0,0 +1,32 @@ +#/bin/bash + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + TARGET="$(readlink "$SOURCE")" + if [[ $TARGET == /* ]]; then + #echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'" + SOURCE="$TARGET" + else + DIR="$( dirname "$SOURCE" )" + #echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')" + SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located + fi +done + +SRPATH="$( dirname "$SOURCE" )" +SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +if [ "$SFPATH" != "$SRPATH" ]; then + RDIR=$SRPATH # relativ path directory +fi + +cwdir=$PWD +wdir=$SFPATH + +if [ "$cwdir" != "$wdir" ]; then + cd $wdir +fi + +echo $cwdir +echo $wdir + +docker run -it --rm --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" -v $cwdir/docs:/documents silvavlis/okular /documents/main.pdf