Problem:
Working with hugo (the framework used for this website) you have to create a new
file for each new post, and while there is a convience method provided in the
hugo
command that will create a new content file it’s invocation is not
something I’ve committed to memory. Instead of taking 5 minutes to commit it to
memory or let it happen over time I’ve instead decided to waste an hour of my
limited free time and implement my own way of handling this in a generic way
that can be used for the same sort of idea (template default files).
The program is called touchy
as it is obviously inspired by the coreutil
program touch
available on most unix/linux systems.
hugo new content content/code/touchy.md
would result in the following;
---
title: "touchy"
date: 2024-11-10T17:12:00Z
draft: true
---
Solution:
Introducing touchy.
Instead with the tool you first add the default template to the ~/.touchy
config file;
paths:
/home/tsp/website/*:
- filename: "*.md"
content: |
---
title: "{{filename}}"
date: {{isotimestamp}}
draft: true
---
and voila you can now create the file with touchy content/code/touchy.md
,
saving you a total of 10 characters! What a great use of my limited free time!
Supported replacements in the file:
{{isotimestamp}}
- Replaces with current time in%Y-%m-%dT%H:%M:%SZ
format{{filename}}
- Filename without extension{{dirname}}
- Folder the file is being created in{{filepath}}
- Full filepath to the file{{file_ext}}
- File Extension