Keyboard Maestro Macro: Log It, v5.2—quickly save plain text snippets to one or more log files

NOTE: This entry and macro were inspired by Brian Kammer’s post titled: Quick note taking system.



If you like working in plain text (and Markdown), you might find this useful.


Keyboard Maestro Macro: Log It


PURPOSE

This macro provides a method to quickly save plain text snippets to one or more log files. A user can add snippets quickly because the macro writes directly to the text log files, i.e., the user is not required to interact with a separate macOS application.

In addition, using settings included on the main dialog of the macro, a user can customize the logging behavior:

  1. Define the Content to preload:
    Nothing; Selection; Clipboard;
    SafariURL; SafariTitle SafariURL; Selection SafariURL; Clipboard SafariURL;
    [SafariTitle](SafariURL); [Selection](SafariURL); [Clipboard](SafariURL);
    ChromeURL; ChomeTitle ChromeURL; Selection ChromeURL; Clipboard ChromeURL;
    [ChomeTitle](ChromeURL); [Selection](ChromeURL); [Clipboard](ChromeURL)

  2. Optionally change the Log Filename each day.

  3. Replace, Prepend, or Append to an existing log file.

  4. Optionally add a Timestamp Prefix to every snippet saved.

  5. Optionally apply Markdown syntax: Bold; Italic; Bold Italic; Blockquote; Inline code; Syntax Highlighting

  6. Optionally Shorten a URL.

  7. Specify a Content Suffix which effectively acts as a delimiter between captures snippets.

The main dialog also provides a field that allows the user to change the Log Filename.

Constructed snippets written to log files can be confirmed with: Sound; Dialog; or Sound & Dialog.

If Dialog or Sound & Dialog are chosen, the user can then opt to: Open (the log file using the default text editor), Select (the log file in the Finder), or do nothing.

EXAMPLE APPLICATION

When reading webpages, a user could save several excerpts by simply selecting portions of each webpage and invoking this macro.

USAGE

  1. (Optional) From any macOS, select some text.
  2. Launch this macro. The main dialog will be displayed.
  3. (Optional) Change one or more settings in the main dialog.
  4. Select the one of four buttons: Cancel; Save Settings Only; Write to Clipboard; OK. The default, OK, writes the constructed snippet to a log file. Alternatively, Write to Clipboard, updates the macOS Clipboard, not a log file.
  5. If the confirmation dialog was specified to appear, select one of three buttons: Open; Select; No

WRITING TO CLIPBOARD

The primary purpose of this macro is to write text to log files. However, the main dialog includes a Write to Clipboard button that, when selected, the content will be written to the Clipboard rather than a log file. Moreover, if ⌥(Option key) is down when the Write to Clipboard button is selected, the Timestamp Prefix and Content Suffix will be excluded.

BYPASS MAIN DIALOG

To bypass the Log It main dialog, trigger the macro by adding the ⌥(Option key). This can be particularly useful for logging several text snippets in quick succession.

[ more ]


A demonstration video is available here


Log It was contributed using the Keyboard Maestro Forum and can be download from this page.

Responding to feedback from @Tomas on the Keyboard Maestro forum, I’ve updated Log It to Version 3.0.

Version 3.0

  • Added and option to bypass the main dialog by adding ⌥ (Option) when launching.

  • For loading the default settings, the modifier was changed from ⌥ (Option) to ⌘ (Command).

[ more ]

I’ve updated Log It to Version 4.0.

Version 4.0

  • For Start With added these options: ChromeURL; ChromeTitle ChromeURL; Clipboard ChromeURL; [ChromeTitle](ChromeURL); [Clipboard](ChromeURL);

  • Updated this comment to include the section: MULTIPLE INSTANCES OF LOG IT;

  • Bug fix: With Start With corrected the Clipboard SafariURL option: %Clipboard%, not %SystemClipboard% was mistakenly used.


The Log It demonstration video has not been updated since Version 1.0, but everything within still applies to Version 4.0.


[ more ]

I’ve updated Log It to Version 5.2.

Version 5.0

  • Added button/option: Write to Clipboard.

  • Added Start With options: Selection, Selection SafariURL, [Selection](SafariURL), Selection ChromeURL, [Selection](ChromeURL).

  • Added option: if nothing selected replace Selection with Clipboard.

Version 5.1

No functional changes since v5.0. Fixed the revision date in the macro header comment.

Version 5.2

All persistent values are now saved to a single KM Dictionary named jsLI_dict, where js are my initials and LI refers to the name of this macro. For more information about this approach to saving values, refer to Dialog with Dynamic Popup List. In cases where multiple copies of Log It are required (with independent settings), this macro can be copied and the value of local_DICT can be changed in the copy.


The Log It demonstration video has not been updated since Version 1.0, but everything within still applies to Version 5.2.


[ more ]