Code: Select all
$ pdflatex --output-dir ~/_build foo.tex
Code: Select all
$ export TEXMFOUTPUT="~/_build"
$ echo $TEXMFOUTPUT
~/_build
$ pdflatex foo.tex
Code: Select all
$ pdflatex --output-dir ~/_build foo.tex
Code: Select all
$ export TEXMFOUTPUT="~/_build"
$ echo $TEXMFOUTPUT
~/_build
$ pdflatex foo.tex
kpsewhich -var-value="TEXMFOUTPUT"
Code: Select all
$ kpsewhich -var-value="TEXMFOUTPUT"
/Users/my-mac/_build
Code: Select all
alias mypdflatex='pdflatex --output-dir ~/_build'
Code: Select all
mypdflatex foo
Indeed:rais wrote:OTOH, it might be easier to use an alias, as in
#!/bin/bash
# DESCRIPTION: tools for changing pdflatex's default build directory
# RE: http://latex-community.org/forum/viewto ... 52&t=28499
#
# INSTALL :
# copy to a directory in $PATH
# $ chmod 755 thisfile.sh
#
# USAGE:
# $ source thisfile.sh
# $ eval "ls *.?($TEXBUILDEXT)" # Lists TeX build files in the current dir
# $ rmtexbuild # Removes TeX build files from the current dir
# $ pdflatexredirect foo.tex # Writes to ~/_build
#
# TESTED OK UNDER:
# - GNU bash, version 4.3.46(1)-release (x86_64-apple-darwin15.5.0)
export TEXBUILDEXT='log|dvi|out|pdf|aux|blg|bbl'; #anything else?
shopt -s extglob;
alias rmtexbuild='eval "rm *.?($TEXBUILDEXT)"';
alias pdflatexredirect='pdflatex --output-dir ~/_build';
looks suspiciously like ``remove everything from the current folder with the extension of <list according to $TEXBUILDEXT>''erwann wrote:that depends on your workflow.export TEXBUILDEXT='log|dvi|out|pdf|aux|blg|bbl'; #anything else?
Of the top of my head, I'd add
bcf (biber control file)
glg (glossaries log file)
glo (glossaries file)
gls (glossaries file)
idx (index file, input for makeindex)
ilg (index log file)
ind (index file, output from makeindex)
lof (list of figures)
lot (list of tables)
mt* (minitoc helper files)
nlg (nomenclature log file, if -t option to makeindex was used accordingly)
nlo (nomenclature file)
nls (nomenclature file)
ps (post script file, used to be an in-between dvi and pdf)
toc (table of contents)
and a few more I may remember, if I put my head a bit sideways, such that enough brain mass can concentrate in one corner![]()
Speaking of glossaries, you may have to parse the tex file to see what kind of extensions will be useed.
Anyway, thiserwann wrote:alias rmtexbuild='eval "rm *.?($TEXBUILDEXT)"';
Feel free to provide a variant of 'rmtexbuild' that takes care of eliminating the "suspicion" your raise by prompting the caller to provide the basename (without the extension) of the files to delete, in this example, 'foo' (or perhaps 'f*', '?(foo|bar)' etc.).Don't you think there may be source files removed by this? E.g., some picture file included by the .tex file via \includegraphics/\includepdf may fail, if you remove all pdf files from the current folder...
why should I prompt the caller for something, (s)he should have provided with calling the program in question in the first place?erwann wrote:Feel free to provide a variant of 'rmtexbuild' that takes care of eliminating the "suspicion" your raise by prompting the caller to provide the basename
why without? You could give this program a filename (with or without extension), strip off the extension and remove everything matching your pattern. If you allow .tex as the only (possible) extension, you could use that to verify, if this .tex file is even present---before doing anything rash (like removing some files)erwann wrote:(without the extension)
Code: Select all
#!/bin/bash
# save as <whatever>.sh, then run make <whatever> and put the resulting <whatever> script somewhere along $PATH
# see http://latex-community.org/forum/viewtopic.php?f=52&t=28499 for the original code, 2016-09-23-rais
# ... and the original hint(s)
#
if [ -z "$1" ]; then
echo "Usage: $0 file-to-clean-help-files-from[.tex]"
else
TBRBN=${1%.tex} #the basename of the files-to-be-removed
if [ -r $TBRBN.tex ]; then # if `source' (the .tex file with same basename as the files-to-be-removed) is readable
for X in aux bbl bcf blg and-so-on; do
TBRF=$TBRBN.$X
test -r $TBRF && rm $TBRF #only try to remove something that's really there
# come to think of it, it might be better to use `echo' before the `rm' in the initial test phase...
done
else
echo "Could not read source file ($SF)---aborting."
fi
fi
# INSTALL :
# copy to a directory in $PATH (say ~/bin)
# $ cd ~/bin
# $ chmod 755 thisfile.sh
# $ mkdir ~/_build
#
# USAGE:
# $ source thisfile.sh
# $ echo $TEXTBUILDEXT # Recognize build files' extensions
# $ eval "ls *.?($TEXBUILDEXT)" # Lists TeX build files in the current dir
# $ rmtexbuild foo # Removes foo build files in ~/_build'
# $ rmtexbuildpwd foo # Removes foo build files in curr. dir
# $ pdflatexbuild foo.tex # Writes to ~/_build (*)
# $ bibtexbuild foo.aux # Creates bbl in ~/build (*)
#
# (*) .tex and .aux optional
#
# TESTED OK UNDER:
# - GNU bash, version 4.3.46(1)-release (x86_64-apple-darwin15.5.0)
#
# ALSO SEE:
# http://tex.stackexchange.com/questions/ ... -compiling
#
# TODO:
# Error handling
export TEXBUILDEXT='log|dvi|out|aux|blg|bbl|pdf|bcf|glg|glo|gls|idx|ilg|ind|lof|lot|mt*|nlg|nlo|nls|ps|toc';
shopt -s extglob;
function rmtexbuild(){
eval "rm ~/_build/$1.?($TEXBUILDEXT)";
}
function rmtexbuildpwd(){
eval "rm ./$1.?($TEXBUILDEXT)";
}
function mvtexbuild(){
eval "mv ./$1.?($TEXBUILDEXT) ~/_build/";
}
function mvtexbuildtopwd(){
eval "mv ~/_build/$1.?($TEXBUILDEXT) ./";
}
alias pdflatexbuild='pdflatex --output-dir ~/_build';
function texbuildgeneric(){
rmtexbuildpwd $2;
mvtexbuildtopwd $2;
eval "$1 $2";
mvtexbuild $2;
}
function bibtexbuild(){
texbuildgeneric bibtex "${1%.aux}"
# bibtex ~/_build/$1 not allowed, hence this solution
}