2

Possible Duplicate:
How to pass parameters to an alias?

I'm wondering if it is possible to define an alias with parameters.

For example, when I have to compile a tex file I execute pdflatex and then I have to open the pdf:

$ pdlatex Main.tex
$ Open Main.pdf

Is there a way for defining an alias like this:

alias buildPdf="pdflatex x.tex && Open x.pdf"

Where x is a parameter?

Maverik
  • 121

2 Answers2

7

You can use a function. Add to your .bashrc or simply copypasta into your terminal:

function buildPdf() {
  pdflatex "$1.tex" && Open "$1.pdf"
}
0

With bash this is not possible. Consider using a bash script instead:

#!/bin/bash
pdflatex "$1".tex
Open "$1".pdf
  • Call this 'buildPdf'
  • give it executable permission (chmod +x)
  • place it in a directory listed in $PATH

Voila!

Ulrich Dangel
  • 25,369
Evert
  • 111