[TxMt] Re: Using mate command with templates

Hans-Jörg Bibiko bibiko at eva.mpg.de
Wed Jan 14 12:39:01 UTC 2009


On 14.01.2009, at 12:43, Arne Eilermann wrote:
> is there a possibility to create an new file from template using the
> mate terminal command?

Maybe try this:

you have a template file saved as ~/Desktop/template.txt which is an  
HTML template

<html>
<body>
Hello, I'm a \"template\"
Date: `date`
Name: ${1:Write here your name}
</body>
</html>


then you can invoke that shell command in the Terminal:

mate untitled.html;osascript -e "tell app \"TextMate\" to insert   
\"`cat ~/Desktop/template.txt`\" as snippet true"


Short explanation:
- in the template file everything between `` backticks is evaluate on  
run-time
- ${x:foo} notation indicates to insert foo as snippet
- double quotes " must be escaped in the template file by \
- Unicode (UTF-8) safe since Leopard


--Hans



More information about the textmate mailing list