edited August 2019 in Software & Gadgets
- Keyboard Maestro Pc
- Keyboard Maestro Examples
- Keyboard Maestro For Windows 10
- Keyboard Maestro Forum Software
Mac’s Rants & Raves Episode #291. Keyboard Maestro creates macros —sequences of actions that can be saved and then invoked and played back with a single keystroke (or other trigger). The System Clipboard is a complicated entity, and often contains many different flavors of the same data last copied from an app. To better understand how Keyboard Maestro processes the System Clipboard, see this Forum post by @PeterNLewis. In particular, this post deals with getting plain text from the System Clipboard.
Dear Zettelkasten-Community,
I have been wanting to visualise the links between selected notes in my zettelkasten for quite a while, mainly in order to simplify 'tidying up' or organising a network of zettels (adding appropriate links, consolidating similar zettels, adding or removing tags from zettels appropriately, etc.).
I was quite involved in this discussion about visualising zettel-networks and followed and tested @alexchabot's work on zkviz, but still didn't find all my needs met – I had the desire to customise the setup a bit more Last week I then decided to try to create my own visualisation-setup, using Graphviz and Keyboard Maestro, which both had a key role in the above mentioned discussions and projects. I wanted to try not to use Python or similar scripting languages in addition to Graphviz and Keyboard Maestro in order to make it easier to customise things for people who aren't familiar with those languages (me included).
What I came up with is a KM macro that is supposed to be triggered when the desired zettels are selected in The Archive, it will finish by opening a .svg-file with the visualisation in Safari.
As with @alexchabot's zkviz, the macro will assume that all zettel titles will start with the 12-digit UID and then have a verbal title. If your titles look different, the macro won't work. The macro also assumes that all your notes have the extension
.md
.Given all this, the following steps need to be done in order to get it running:
- Graphviz needs to be installed. If you have Homebrew, run
brew install graphviz
in the Terminal. - In order for the graphviz command
dot
to be found by the Keyboard Maestro engine, the folder that Graphviz was installed in needs to be added to the folders that KM searches for shell-commands. This can be done by adding the variableENV_PATH
under Keyboard Maestro's 'Preferences -> Variables' and setting it to/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
(the folder /usr/local/bin was previously not searched). - Download the main KM macro under this link, open it in KM and change the entries that I marked in the following image according to your needs (5 pathnames):
- Download this additional KM macro that generates a list of the notes in your zettelkasten from time to time. This list is needed in order for the main macro to work and can also be used for many other purposes (which is why I keep it separate). Adjust your zettelkasten-folder if necessary.
- If your notes all have the same extension, but not
.md
, you can easily change the extension in the relevant macro (to e.g..txt
). If your notes have several different extensions, it's not straightforward to make it work (at least from my perspective), but it should be possible.
That's pretty much it. The output for a small group of my zettels looks like this:
- If you create your own .svg-files with the macro, the nodes are clickable and will lead to the corresponding note in The Archive (URL-scheme).
- All the selected notes are in the darker blue, non-selected notes that they link to are shown in a light blue (if desired). The colours can easily be changed in the macro.
- You can also try other programs than dot included in the Graphviz package by changing the command
dot
in the 'Execute Shell Script' action (not the file extension .dot which can be used by all the programs!) toneato
,circo
,fdp
,sfdp
orosage
– they will all result in different arrangements of the nodes. Play around and see what you like best. - You can also play around with different node shapes, arrows, nodelines, etc. – look at what the DOT-language has to offer, e.g. here.
Looking forward to feedback and images!
Keyboard Maestro Pc
And thanks to @alexchabot and Tom in the KM-forum for your ideas and help!
Comments
- edited September 2019Thanks @alexchabot! Glad you like it. And again: without you I wouldn't have done itThe only thing I'm not happy with is Safari asking for permission to open the note in The Archive every single time I click on a node. But apparently nothing can be done about except for changing the browser..
- @Vinho great work. Those people on the Keyboard Maestro forum are super!Note:
1. ggrep is not in the default macOS. Installed via brew install grep. (Homebrew also must be installed.)
2. ~/Dropbox/zettelkasten/-visualisation/zkselection.dot is not automatically created.
3. Importance of helper script that generates a list of the notes could be more prominently stressed.Question:
1. I see where 'Safari' is defined as the browser. Changing this to 'Chrome' throws an error. Any idea of the naming convention required?Will Simpson
I'm a Zettelnant.
Research: Rationalism, Zen, Non-fiction Creative Writing
kestrelcreek.com - edited September 2019@Will:Thanks for the feedback!
- Thanks for pointing out the fact about ggrep, I forgot that was in there.
- I think the file zkselection.dot is automatically created (the action 'Write to File' will recreate it if I manually delete it), but presumably the folders mentioned in its path need to exist in order for that to work.
- Hm, I had hoped it was stressed enough (step 4 of the steps I mentioned in my post). Unfortunately, I can't edit the post anymore to change anything..
- I think you have to refer to Chrome as 'Google Chrome'. Does that work? Personally, I don't have it installed, so can't test it.
- @Vinho
Still experimenting with this view of the note relationships. Have you a way to get more than one level deep? It would be interesting to select a single note and see second-order linking. This might lead to something surprising.Yes, referring to Chrome as 'Google Chrome' does that work.When selecting links in the zkselection.svg I got this dialog, once then no more.Will Simpson
I'm a Zettelnant.
Research: Rationalism, Zen, Non-fiction Creative Writing
kestrelcreek.com - @Will: That's sounds similar to what I wanted here. I created a KM Macro to visualise children hierarchies with Graphviz first, but then realised that specifically the outline view in OmniOutliner is much more helpful for me.. Let me know what you think.Did the dialog you posted above appear in Safari or did you use Chrome?
- @Vinho
Sorry to not make it clear about the dialog. It appeared in Chrome. Unlike the one activated in Safari, it allows an 'Aways open these type of links in the associated app'.Will Simpson
I'm a Zettelnant.
Research: Rationalism, Zen, Non-fiction Creative Writing
kestrelcreek.com - @Will: Yes, I thought so. It's a shame that Safari doesn't offer that option.
- This is fantastic script, thanks so much for sharing.I had an issue with ggrep not executing in background mode, and used the solution found here:
https://forum.keyboardmaestro.com/t/execute-shell-script-with-path-of-finder-not-working/12279For me it was just referencing the full path from 'which ggrep':
ls | /usr/local/bin/ggrep -P '[0-9]{12}.+' | cut -d'.' -f1 - edited October 2019@themacmarketer:It's a pleasure – I'm glad you find it useful!
Thanks for letting us know about your problem with ggrep and your solution.
Howdy, Stranger!
It looks like you're new here. Ockham 1 0 – sensitivity analysis tool. If you want to get involved, click one of these buttons!
Quick Links
Categories
In this Discussion
Table of Contents
Keyboard Maestro supports several different types of clipboards
- System Clipboard — the standard Mac OS X Clipboard used by all Mac apps
- The alternate name “Current Clipboard” is used in some Macro Actions
- Named Clipboards — Copy of System Clipboard, or other Named Clipboard, created by user for future use
- There is usually a default Named Clipboard named “Default Clipboard”, do not confuse this with the Mac’s System Clipboard.
- Past Clipboards — Prior Versions of the System Clipboard stored in the Keyboard Maestro Clipboard_History
- Trigger Clipboard — The clipboard referenced by a Clipboard Filter menu selection (or the System Clipboard otherwise).
System Clipboard
The System Clipboard is the clipboard that you will use and work with the most.
Actions That Use The Clipboard
⚠️ Keep in mind that the System Clipboard is involved in all operations (Actions) that transfer data between the user interface (documents, menus, web pages,etc) and Keyboard Maestro.
For example, all of these Actions go through and will change the System Clipboard:
- and many others
Pause Until Clipboard Changes
Sometimes you will need to wait until the app has completed setting the Clipboard. You can use the CLIPBOARDSEED, in a calculation (
CBSeedBefore ≠ CLIPBOARDSEED()
) condition in the Pause Until Action to achieve this. Of course you will need to set the Keyboard Maestro Variable CBSeedBefore
in an Action before the Action to set the Clipboard.Discussion
The System Clipboard is a complicated entity, and often contains many different flavors of the same data last copied from an app. To better understand how Keyboard Maestro processes the System Clipboard, see this Forum post by @PeterNLewis. In particular, this post deals with getting plain text from the System Clipboard.
Clipboard History
Description
The Clipboard History keeps version history of the last two hundred times you have copied something to the System Clipboard. You can then paste any previous system clipboard by triggering the Clipboard History Switcher macro. This is a very powerful and useful feature.
Options
If you enable the Save Clipboard History to Disk preference in the Keyboard Maestro General preferences, the clipboard history will be saved and restored when Keyboard Maestro Engine is quit and relaunched (such as when you restart or upgrade). Otherwise it will be reset each time you quit the Keyboard Maestro Engine.
Display History
The Clipboard History Switcher is a built-in Macro, which you can find in the Keyboard Maestro editor, in the Switcher Group in the Macro Groups.
To trigger the Clipboard History Switcher, press the default hotkey of ⌘⌃⇧V (or a hot key of your choosing).
You can also use the Clipboard_History within the For Each action.
For more info, see Clipboard History Switcher documentation.
Paste from History
There is no one built-in Macro or Action that will paste from the Clipboard History, but you can easily do this by making use of the Set_Clipboard_to_Past_ClipboardAction.
For example, to paste from the 2nd item on the Clipboard History (where the latest, most recent item is #1), you can use these three Actions in a macro:
For more discussion on this, see this Keyboard Maestro Forum post .
Named Clipboards
A Named Clipboard is not a true clipboard like the Mac’s System Clipboard. Rather it is simply a means to permanently store (like a file does) clipboard contents (like images or styled text) that can later be used to place on the System Clipboard.
Purpose
- Store a copy of another Clipboard (System or Named) that will persist, even across your Mac restarts, until you either change it or delete it.
- Make changes to a Named Clipboard using Actions like Apply_Style_to_Clipboard.
- Store styled text, images, etc that cannot be stored in a Keyboard Maestro Variable (which stores only plain text)
Example Use of Named Clipboards
- Storing styled text and/or images for future use, like a styled email signature or logos.
- Saving the current System Clipboard for future use
- To use in other Macros.
⚠️ Note that Keyboard Maestro provides a named clipboard with the name of “Default Clipboard”. It is nothing special, and acts like any other named clipboard. The “Default” in the name means nothing more than that it was provided by default. Do not mistake this for the System Clipboard.
Named Clipboards are located in the Keyboard Maestro Preferences in their own “Clipboards” panel.
Use the [+] button to create a new named clipboard.
The one-line field at the top-right is the name field.
The big field on the lower-right is the content field.
You can add plain text, styled text, and images simply by pasting into the content field, but if you want to add something like a Keyboard Maestro action you need to use a Copy to Named Clipboard action to get it in there.
Trigger Clipboard
The Trigger Clipboard is not a clipboard per se, but a reference to a clipboard, either the System Clipboard, a past clipboard in the Clipboard History, or a Named Clipboard. It is the clipboard referenced by a Clipboard Filter menu selection in the Clipboard Switcher.
Clipboard Actions
There are a variety of actions for accessing or processing the clipboard. These allow you to build macros that operate on the clipboard.
Actions That Directly Use Clipboards
- Delete Current or Past Clipboard in the history of the System Clipboard
- Set Variable to Text Action using CurrentClipboardToken
For more info, see Clipboard Actions documentation.
Clipboard Tokens
In addition to the above Actions that use Clipboards, there are several Clipboard Tokens that can be used in any Action which has a field for Clipboards, Variables, or text.
These Include:
Clipboard Condition
The Clipboard Condition may be used with Macro Actions like IF/THEN to branch control based on criteria concerning the data on the Clipboard. For details see: Clipboard Condition
See Also
Actions
Functions
- CLIPBOARDSEED – used to determine when Clipboard has changed