Speed up the work by shell scripts II
In addition to the shell scripts mentioned in this post I wrote another small script:
#!/bin/bash # texcd - change into the directory # corresponding to a certain tex related file if [ $# -eq 0 ]; then echo 1>&2 Usage: . texcd filename [pattern] echo 1>&2 examples: . texcd beamer.cls exit 1 fi cd `kpsewhich $1 | sed 's/(.*)/.*$/1/'` echo Changed to: `pwd`
It’s purpose is to change into the directory where a certain tex related file resides. For instance if you want to search through some beamer class theme files, you don’t have to know the directory, just type
. texcd beamer.cls
and you will enter (for instance) the directory /usr/share/texmf/tex/latex/beamer/base/. The dot at the beginning of the command is important. Thats one reason why I show this small script too. Normally if you change the directory inside a script, after the script is finished you will be back inside the directory where you were before, because the script starts a new shell for itself. If you want to run the commands inside your current shell you can use the source command, the dot I’ve used is just an abbreviation for source.
Some additional hints I didn’t mention in the other post: instead of putting the scripts into your home directory you could copy them into your local file system, for instance:
sudo cp texcd /usr/local/bin/
and those scripts should be made executable using chmod:
chmod a+x /usr/local/bin/texcd
Thats recommendable for the other scripts too.