Hello,
is there a possibility to create an new file from template using the mate terminal command?
Thanks in advance, Arne
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
On 14.01.2009, at 13:39, Hans-Jörg Bibiko wrote:
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?
mate untitled.html;osascript -e "tell app "TextMate" to insert "`cat ~/Desktop/template.txt`" as snippet true"
Or simply make usage of this tiny shell command:
Examples: (if tmate is saved in a folder found by $PATH) tmate ~/Desktop/My\ template.html tmate "$HOME/Desktop/My template.html"
or just
tmate
Hint: the escaping of double quotes inside of the template file is not necessary anymore. Will be done in the script.
--Hans
On 14.01.2009, at 15:13, Hans-Jörg Bibiko wrote:
Or simply make usage of this tiny shell command:
<tmate>
Examples: (if tmate is saved in a folder found by $PATH) tmate ~/Desktop/My\ template.html tmate "$HOME/Desktop/My template.html"
or just
tmate
Thank you for your great und really nice help.
Arne
A next step would be to use that approach to combine TM's Template and Snippet technology (the easy way):
--Hans
A next step would be to use that approach to combine TM's Template and Snippet technology (the easy way):
E.g. an HTML template: - create a normal template - content: mate "$HOME/untitled.html" osascript -e "tell app "TextMate" to insert "`cat index.html | perl -pe 's/"/\\"/g'`" as snippet true"
- add a new template file - content: <html> <body>
Hello, I'm a "template"
Date: `date +%Y-%m-%d` Name: ${1:$TM_FULLNAME} Organisation: $TM_ORGANIZATION_NAME
Title: ${2:Write here your title}
Text: ${3:Write here your text}
${0:} </body> </html>
here the template:
--Hans