Appending/prepending plain-text documents via macOS Service

Thought I would share some automations I developed on macOS for quickly appending and prepending plain-text files. [Inspired by @capcrime post.]

These use Automator, AppleScript and shell scripts. No third-party software required.

They are saved as Services so they can have keyboard shortcuts assigned to them and invoked on the fly, while working in any app.

I built these primarily to capture short text snippets for appending my daily recap journals.

I invoke the keyboard shortcut, a text prompt window appears ready for text entry, I type in my text, then hit Function+Return keys (to click the ‘OK’ button via keyboard).

My main journal log Service is set up to dynamically use the current date as part of the filename, creating a new file if necessary.

I also built a variant of the Prepend automation to display a list of filenames so I can prepend various plain-text files from one Service. I can write up a companion post on that one if there’s any interest.

The blog posts go into detail on everything, and have code that is copy-friendly for pasting into your own automation build.

2 Likes

I would be interested in the proposed companion post!

I thought it might be easier to just share the actual workflow for the time being.

You should be able to deduce what’s going on in there, and how to edit it as you see fit, until I get time to write up a proper post.

1 Like

I understand about not wanting to require a third-party tool for this, but (after a searching for a long time) I have finally found a Unix utility that will do this (although I can never remember what it is called).

The answer is sponge which can be installed via brew install moreutils (sort of like GNU’s coreutils but different :wink: )

You can find out more about it, including its syntax, at https://joeyh.name/code/moreutils/.