Zettelkasten Forum


Alfred workflow for The Archive

Hi all,

I am building an Alfred Workflow for The Archive. This workflow will allow you to do many of the things that you would otherwise use Keyboard Maestro to do.

So far I have:

  • Create new note with an optional Zettel ID
  • Create new note from a template (templates are existing notes that are tagged as such)
  • Search and open a note (by title, but with an option to search by content) in The Archive using Alfred
  • Search all TODOs in notes and toggle them on/off with Alfred
  • Search and open note in the default editor
  • Search and copy note as a markdown link
  • Search and copy note (or paste directly in front most app) as a wiki link

Anything I am missing?

«1

Comments

  • Wow. That will be very welcome. One thing I recently built for myself was a silly little script to select a note at random and open it in The Archive. I use it for random bits of gardening when I have a short break. But of course, that will still be available to me.

  • Would you be willing to share the workflow?

  • Wow! Quite a workflow. I have been using @sai's Alfred workflow, linked to here which includes a search for tags from Alfred launch bar. When the required tag is found it is copied to The Archive (or front most application). I have found that very useful. It also allows the creation of new tags.

  • edited June 13

    @michaelmcdonald said:
    Would you be willing to share the workflow?

    It's not quite finished, but hopefully I'll have something to share this coming week. I'm also adding the ability to create a new note from the text in the clipboard, optionally using a template. This way you can copy (or cut) text from an existing note or other source, and paste the text as a new note using a hotkey.

    @DavidWJ said:
    ...which includes a search for tags from Alfred launch bar. When the required tag is found it is copied to The Archive (or front most application). It also allows the creation of new tags.

    I will see about adding that to it also.

  • Thank you. I look forward to the finished product.

  • edited June 14

    @DavidWJ said:
    It also allows the creation of new tags.

    The workflow does not maintain a TAGS.md file so you cannot create them. However, it searches all existing tags (along with counts) from your notes and you can either paste a tag to the frontmost app, or you can display all notes that use the tag in The Archive.

    @ctietze I noticed that thearchive://match/#mytag does not work but thearchive://match/mytag does. It seems like thearchive:// does not support hash symbols in the query. Is this a bug?

  • @Jeremy said:
    One thing I recently built for myself was a silly little script to select a note at random and open it in The Archive. I use it for random bits of gardening when I have a short break. But of course, that will still be available to me.

  • edited June 14

    @Jeremy @DavidWJ @michaelmcdonald @ctietze

    v1.0.0 is released. There is no documentation at the moment, but it should be fairly self-explanatory once you have installed the workflow in Alfred.

    As you can see, each of the available actions are on the same column in the screenshot above. For example, type ar to search your notes, arrandom to open a random note, arnew to create a note, etc.

    I have included empty Hotkeys for each of the actions, you can use these to set your own if desired.

    Here is an example template:

    ---
    Title: {title}
    Date: {date}
    ID: {zettel_id}
    Keywords: {tags} #template
    ---
    
    {content}
    

    The {content} tag is where the clipboard content goes if you have selected to paste the clipboard into the new note.

    There are a few options that you can set, use the arconfig keyword to change them. Holding down shift will open the Help file in Quickview for each option.

    You won't need to set the path to your notes as the workflow will automatically get the path set in The Archive preferences.

    I have also added a File Action to import images into the media folder of The Archive and copy the markdown link to the clipboard so that you can paste it directly into a note.

    The workflow uses OneUpdater for updates, so you will need to install that workflow to make use of it.

    Hope you all find this workflow useful!

    https://github.com/pryley/alfred-the-archive/releases

  • @pryley Thank you. I look forward to trying out (and learning from) this workflow. Thank you as well for the correction regarding new tags.

  • @pryley Thank you! Could you expand on how to use a template in the workflow? Ideally when creating a new zettel it opens with a some desired structure, and I'm trying to find where to fit that into the workflow.

  • edited June 15

    @johnny

    To use a template, create a note in The Archive and tag it somewhere in the first 5 lines of the note with #template (you can change the tag used for templates in the workflow config).

    Note: You can change the workflow config by typing arconfig in Alfred.

    You may use the following placeholders in your templates:

    • {title} This is the title of your note
    • {zettel_id} This is the Zettel ID of the note (if it exists)
    • {tags} These are the tags (if provided)
    • {date} This is the formatted date (change the default date format in the config)
    • {content} This is the contents of the clipboard (if you have selected to paste it)

    Here is an example Template:

    ---
    Title: [[{zettel_id}]] {title}
    Index: [[200615130000]] Application support
    Keywords: #support {tags} #template
    ---
    
    {content}
    

    Note: if you would like the {title} placeholder to include the Zettel ID, you may change the option in the workflow config. It is not included by default.

    Once you have created a template, it will appear as a selectable entry when creating a new note with Alfred. Also, by holding down one or more modifier keys, you can customise the result:

  • Here is a detailed readme that explains everything the workflow can do.

    Suggestions welcome...

    https://github.com/pryley/alfred-the-archive/blob/master/README.md

  • @pryley This is a great workflow. There is one thing: searching for a note and selecting to add a wiki link to it, the link that is pasted in has an empty space at the end before the closing brackets. If i remove the space, the link works. Think it might be a bug (if not its something with my links).

  • @johnny It works for me, I wonder if your notes have a leading space in the title?

    Regardless, update to v1.3.1 which:

    • strips whitespace characters from wiki and markdown link titles
    • fixes Zettel ID increments (new Zettel IDs (based on current datetime) are incremented by 1 min if an existing ID exists).
  • @pryley This workflow is incredible. Soooo useful. Greatly reduces friction in zettel creation as evidenced by the fact that I've added more notes in the last few days than in the last month combined. Custom templates and add image speeds things up considerably.

    Every question I've had so far has been answered by your very clear documentation. Tried everything and it works great.

    Also, as a young Padawan learner in the ways of Python, it's inspiring to see what's possible. Minimal and elegant. Super cool.

    Much gratitude and look forward to following your work in the future.

  • edited June 23

    I have added a feature in v1.5.0 that allows you to change the heading level of a line in your note using the standard ⌘ + LEVEL hotkeys, similar to the way most Markdown editors allow you do it. And unlike some other solutions, this one will not overwrite your clipboard in the process.

    For example:

    Pressing ⌘ + 1 will turn this: "Note Title" into this: "# Note Title"

    See: https://github.com/pryley/alfred-the-archive/blob/master/README.md#change-heading-levels

  • @pryley When I include a pipe | in the title and attempt to create from a template, it creates a new note but not from template. Additionally, the note title characters after the pipe are truncated. I've recreated it and, as far as I can tell, it's the pipe throwing things off. Possible to be able to create a note with a pipe in the title?

  • @kohled Sure! Please download the latest release from here: https://github.com/pryley/alfred-the-archive/releases

  • Hi @pryley.

    Installed the workflow following instructions but when I input ar no The Archive files are returned. Do I have to specify their location on the mac? (Note: I'm still on Mojave since I've been too lazy to do a clean install of Catalina.)

    ================
    _Research is formalized curiosity. It is poking and prying with a purpose. _ -- Zora Neale Hurston

  • edited June 27

    @MJV The workflow reads the preferences from The Archive in order to determine the notes directory. However, this workflow has only been tested on Catalina so I am unsure whether The Archive manages the preference file on Mojave differently.

    You can quickly perform a test to determine whether or not the preferences are being found like this:

    1. Open Alfred Preferences, go to "Workflows" and select "The Archive" workflow.
    2. Press ⌘ + D to toggle debugging mode (or click the debug icon as shown in the screenshot below)
    3. Open Alfred and type ar + space

    If the workflow is unable to get the preferences, you should see one of the following errors in the debug console:

    "Warning: Cannot get the application setting: ..."

    OR

    "Error: Cannot find the application settings, please verify the_archive_bundle_id."

    Please let me know your results.

    FYI: On Catalina, the preference file for The Archive is found in the Sandboxed Group Container directory here:

    ~/Library/Group Containers/FRMDA3XRGC.de.zettelkasten.TheArchive.prefs/Library/Preferences/FRMDA3XRGC.de.zettelkasten.TheArchive.prefs.plist

  • Thanks for the message @pryley.

    In my mac the preference file is at: ~/Library/Group Containers/FRMDA3XRGC.de.zettelkasten.TheArchive.prefs/Library/Preferences/FRMDA3XRGC.de.zettelkasten.TheArchive.prefs.plist (I did a copy path). So that should not be the problem.

    Re: the debug info. There is indeed an error message, but not any of the ones you mentioned.

    [17:00:21.331] The Archive[Script Filter] Queuing argument ''
    [17:00:21.681] The Archive[Script Filter] Script with argv '' finished
    [17:00:21.686] ERROR: The Archive[Script Filter] Code 1: Traceback (most recent call last):
      File "~/Dropbox/Stuff/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C3278F23-3E35-4FE5-B525-186F96F1A9C4/search_notes.py", line 5, in <module>
        from Notes import Search
      File "~/Dropbox/Stuff/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C3278F23-3E35-4FE5-B525-186F96F1A9C4/Notes.py", line 7, in <module>
        import html
    ImportError: No module named html
    
    

    Does this help tracing the problem?

    ================
    _Research is formalized curiosity. It is poking and prying with a purpose. _ -- Zora Neale Hurston

  • @MJV Please update to the latest release and let me know if that fixes it.

    https://github.com/pryley/alfred-the-archive/releases

  • Perfect! Thank you.

    This workflow is going to be SO useful. :)

    ================
    _Research is formalized curiosity. It is poking and prying with a purpose. _ -- Zora Neale Hurston

  • Hei @pryley
    Would it be possible to configure it to only link to the ZettelID, and not the title? Great job btw...

  • @johnny You mean when pasting/copying a wiki link?

  • @pryley Yes. That would make this workflow perfect.

  • @johnny please update to v1.7.0

  • @pryley Thanks for this! This workflow is a HUGE addition to my system. It singlehandedly kept me using The Archive instead of trying some new tools.

    One question: I read the documentation and I was not able to figure out how to modify the "default" template (for lack of a better term). Is there a way to create a new default, or modify the one that ships with the workflow? Thanks!

Sign In or Register to comment.