ttouch
v2.1.0
Published
Create files easily
Downloads
11
Readme
ttouch
touch with templates
Creating new files is easy, but entering the same boilerplate content into everyone is tedious. When creating a new my_script.sh
file would it not be great if the shebang would already be there?
That is what ttouch does for you and much more.
Installation
$ npm install -g ttouch
What if I do not want to install it
If you do not want to pollute your global namespace then ttouch can be use npx. But more on that in the usage section.
Usage
$ ttouch <filePath> [options]
or if you do not want to install it globally
$ npx ttouch <filePath> [options]
Options
| Short | Long | Description | | --- | --- | --- | | -d | --destination | The destination folder for the desired file(s) | | -g | --gist | The public gist ID to use as the template | | -f | --file | The local file used as the template | | -v | --verbose | Provides additional error information. Does not add additional output statements under normal operation! |
Environment variables
ttouch uses the TTOUCH_HOME
environment variable to determine the default location for file templates. If this environment variable is present then the absolute path to the provided template file will be assumed to the ````$TTTOUCH_HOME/{templateName}```.
Example:
$ ttouch user.js -f js_class
Given that TTOUCH_HOME = /var/ttouch
Then the template used will be assumed to be at /var/ttouch/js_template
Examples
$ ttouch test.sh
Will create an empty file names test.sh in the current directory.
$ ttouch test.sh -g 37bcbb7217d26c2dd3e5f4cee9fd6e37
Will create a test.sh file in the current directory using the public gist 37bcbb7217d26c2dd3e5f4cee9fd6e37
$ ttouch test.sh -f bash
Will create a test.sh file using a file named bash located in the current folder or specified by TTOUCH_HOME.
/home/me $ ttouch /dir1/dir2/test.sh -f bash
Will create a file named test.sh in the directory /home/me/dir1/dir2/test.sh and apply the ttt-bash template to the created file.
NOTE: If and part of the destination path does not exist then the directories will be created
The same could be achieved with:
/home/me $ ttouch test.sh -f bash -d dir1/dir2
Multiple files
Want to create more than just one file? No problem. Just list them and provide an optional template.
$ ttouch student.js teacher.js -t jsclass
Will create two files student.js and teacher.js in the current folder applying the ttt-jsclass template to both!
Templates
ttouch does not come with any templates out of the box. All templates are external to the program, files and gists. So one of the first tasks will be to start a template or two.
Next steps
Try it
Give the thing a try to see if you like it or if there is something missing
Get in touch
If you have any feedback do not hesitate to utter it. Use any of the following channels to do so:
Create a template
There is a list of my template -> HERE
If you would like to create your own -> HERE