Fabric icon indicating copy to clipboard operation
Fabric copied to clipboard

helper utility for saving a Markdown file

Open invisiblethreat opened this issue 1 year ago • 3 comments

save can be used to save a Markdown file, with optional frontmatter and additional tags. By default, if set, FABRIC_FRONTMATTER_TAGS will be placed into the file as it is written. These tags and front matter are suppressed from STDOUT, which can be piped into other patterns or programs with no ill effects. This strives to be a version of tee that is enhanced for personal knowledge systems that use frontmatter.

What this Pull Request (PR) does

Adds the save helper

Related issues

None. This is a new helper script.

Screenshots

$ grep FABRIC ~/.config/fabric/.env
FABRIC_OUTPUT_PATH="~/obsidian/Fabric"
FABRIC_FRONTMATTER_TAGS="fabric-extraction"

$ ./save --h
usage: save [-h] [-t, TAG] [-n] [stub]

save: a "tee-like" utility to pipeline saving of content, while keeping the output stream intact. Can optionally generate "frontmatter" for PKM utilities like Obsidian via the
"FABRIC_FRONTMATTER" environment variable

positional arguments:
  stub                stub to describe your content. Use quotes if you have spaces. Resulting format is YYYY-MM-DD-stub.md by default

options:
  -h, --help          show this help message and exit
  -t, TAG, --tag TAG  add an additional frontmatter tag. Use this argument multiple timesfor multiple tags
  -n, --nofabric      don't use the fabric tags, only use tags from --tag

$ echo test | ./save --tag extra-tag stub-for-name
test

$ cat ~/obsidian/Fabric/2024-03-02-stub-for-name.md
---
generation_date: 2024-03-02 10:43
tags: fabric-extraction stub-for-name extra-tag
---
test

invisiblethreat avatar Mar 02 '24 14:03 invisiblethreat

NICE!

Can you update this to update the /helpers/README.md file instructions as well?

danielmiessler avatar Mar 03 '24 19:03 danielmiessler

I delved into the "install a script the Poetry way" and will refactor a bunch of things to keep the same design pattern that in the last merge(this is where I ended up as well).

invisiblethreat avatar Mar 03 '24 19:03 invisiblethreat

Anything else I can do to help get this merged, @danielmiessler ?

invisiblethreat avatar Mar 11 '24 15:03 invisiblethreat

Love this but we're now using pipx to simplify install.

Anything else we should think about given that?

danielmiessler avatar Mar 13 '24 20:03 danielmiessler

@danielmiessler using pipx should get this installed for "free" since it's added in the scripts portion of pyproject.toml

invisiblethreat avatar Mar 13 '24 20:03 invisiblethreat