Last active
May 15, 2023 19:13
-
-
Save WangNianyi2001/f462a9f376f254c49e4e49d29da483e7 to your computer and use it in GitHub Desktop.
Useful bash scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/bash | |
bn="$(basename $*)"; | |
fn=${bn%.*}; | |
echo $fn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd $1; | |
echo $(pwd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/bash | |
# Process a XeLaTeX source directory and output the result PDF to certain directory. | |
# Usage: ./xelatex.sh [source-file] [out-dir] | |
# It is assumed that all necessary auxiliary files are present along with the source TeX file in the same directory. | |
home=$(pwd); | |
bin=$(dirname $0); | |
srcDir=$($bin/realpath.sh $(dirname $1)); | |
srcName=$(basename $1); | |
srcFileName=$($bin/filename.sh $srcName); | |
outDir=$($bin/realpath.sh $2); | |
tmpDir=/tmp/xelatex; | |
mkdir $tmpDir; | |
extList=tex,toc; | |
cd $srcDir; | |
for ext in ${extList//,/ }; do | |
cp $srcFileName.$ext $tmpDir; | |
done; | |
cd $tmpDir; | |
xelatex -interaction=nonstopmode $srcName; | |
for ext in ${extList//,/ }; do | |
cp $srcFileName.$ext $srcDir; | |
done; | |
cp $srcFileName.pdf $outDir; | |
cd $home; | |
rm -rf $tmpDir; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment