Fun with espanso

Thanks so much for sharing! This breadcrumb is really useful for daily notes.

I was able to re-create it using Alfred, in case anyone is interested.

[[{date -1d:yyyy-MM-dd}|<< Yesterday]] | [[{date +1d:yyyy-MM-dd}|Tommorrow >>]]

I tried to the code with breadcrumb (bc) - powershell started, then nothing happens, breadcrumb is not appearing, just blank page. Any ideas why could it happen?

Hey @trickykid, Bash and (Windows) PowerShell are similar in ways but not identical, thus you should use different syntax (?)/functions. The following espanso command works for me on Windows 10:

  # Breadcrumb
  - trigger: ":bc"
    word: true
    replace: "{{output}}"
      - name: output
        type: shell
          cmd: (echo "[[$((Get-Date).AddDays(-1) | Get-Date -UFormat "%Y-%m-%d (%a)")|<< Yesterday]] | [[$((Get-Date).AddDays(+1) | Get-Date -UFormat "%Y-%m-%d (%a)")|Tomorrow >>]]")

Hey guys, is anyone aware of how to achieve this in linux (I’m using manjaro)

Neither the Windows nor Mac version of this seemed to work for me.

I found the following in the espanso documentation

Other possible values for the shell parameter are:
On Windows: cmd, powershell, wsl
On macOS: sh, bash
On Linux: sh, bash

I thought the mac bash set up would work for linux, but after setting it up correctly in espanso, it doesn’t work.

with the original code specified by @mitzimbj
after writing :bc after the text expansion all I get is this symbol |

with the windows code by @psyguy I get [[|<< Yesterday]] | [[|Tomorrow >>]] without the actual dates.

not sure what I’m missing, appreciate any help, or links to documentation to figure this out

Try this for breadcrumbs in Linux:

  - trigger: ":bc"
    replace: "[[{{yesterdaybc}}|<< Yesterday]] | [[{{tomorrowbc}}|Tomorrow >>]]"
      - name: yesterdaybc
        type: shell
          cmd: "bash -c 'date +%Y-%m-%d -d -1day'"
      - name: tomorrowbc
        type: shell
          cmd: "bash -c 'date +%Y-%m-%d -d +1day'"

This is what I get when I press :bc :

[[2020-10-19|<< Yesterday]] | [[2020-10-21|Tomorrow >>]]

My espanso file is pretty big, because I use Windows and Linux, so I need one script for each system.

  • edit: I’m on Linux Mint.

This works perfect! Thank you so much for the help. That’s very simple and elegant code. I Appreciate the help!

1 Like

Or in one line

echo "$(date  --date='1 day ago' '+[[%d-%m-%Y_%a|<< Yesterday']]) | $(date --date='next day' '+[[%d-%m-%Y_%a|Tommorrow >>']])"

Thank you @psyguy !!! I could not get this to work in windows but I used this command and voila! :smiley:

1 Like

Thank you for sharing this, just wanted to share an updated meeting snippet that replaces the 0000 with current time using a variable!

  # Meeting
  - trigger: ":meet"
    word: true
    replace: |
      ## {{meet_time}} Meeting
      - Tags:
      Meeting Link:
      - name: meet_time
        type: date
          format: "%H%M"

Thanks very much for this @mitzimbj. I’m new to espanso (and to YAML and using the Terminal, frankly) but I wanted to implement the breadcrumb for my daily notes like you have. Espanso is now installed and I’ve figured out how to configure the YAML file to include the breadcrumb trail shortcut, which is great.

However, when I cmd+click on the link (produced by the breadcrumb expansion) for the previous or next day’s daily note, I notice that the as-yet-uncreated note gets created in my general vault rather than in the Daily Notes folder. Do you or anyone else know how to adjust settings or the expansion to keep the linked files in the Daily Notes folder automatically when created from the link?

I appreciate any help on this.

@NonAuraticBlue - Check your setting for ‘Default location for new notes’ - you should have ‘Same folder as current file’ selected. I’m guessing you have ‘vault folder’ or something else set there.

It is possible to give a link a file path, but if all your daily notes are in the same place (which is how most are set up, I would think) then the link from one day to the next should be in the same folder.

1 Like

Ah yes, that fixed it. Thanks so much, @Erisred !

1 Like

Is it possible to get Espanso to process pasted text? I tried passive mode but my triggers are too complex.

You can insert text copied on the system’s clipboard. Here’s a simple example:

  - trigger: ";cquote"
    replace: |
        This is text from the clipboard
        > {{clipboard}}
      - name: "clipboard"
        type: "clipboard"

Basically you just define the variable clipboard and call it by putting {{clipboard}} where you want it to be pasted.
Hope that helps.

Is that any different than just pasting text? Will Espanso actually expand on all defined triggers found in the clipboard text?

Hm. So, type out a trigger, copy it, then trigger the clipboard?
No, it doesn’t work like that. It just pastes the text as-is. In any event, I can’t type a trigger without activating it. Perhaps I misunderstand your use case.

Espanso does have global variables you can nest inside a replacement, so you can do some inception style expansions that way. I use it all over for dates, so I don’t have to write the variables over and over.

I got it working with AutoHotkey :slight_smile:

1 Like

aText works as well!

I edited the script with this one but it doesn’t work

cmd: (echo "[[$((Get-Date).AddDays(-1) | Get-Date -UFormat "%Y%m%d_dddd")|<< Yesterday]] | [[$((Get-Date).AddDays(+1) | Get-Date -UFormat "%Y%m%d_dddd")|Tomorrow >>]]")

The result is:
[[20210822_dddd|<< Yesterday]] | [[20210824_dddd|Tomorrow >>]]

Instead of 20210822_Mon

I tried with the “%a” variable:

         cmd: (echo "[[$((Get-Date).AddDays(-1) | Get-Date -UFormat "%Y%m%d_%a")|<< Yesterday]] | [[$((Get-Date).AddDays(+1) | Get-Date -UFormat "%Y%m%d_%a")|Tomorrow >>]]")

And the result is:

[[20210822_dom.|<< Yesterday]] | [[20210824_mar.|Tomorrow >>]]

Because at work I’m in a PC with Spanish configuration.

How can I force a syntax like " 20210822_Mon " (english days with 3 letters and the first one Uppercased?

Guys sorry for the maybe stupid question, but shouldn’t we be able to do this directly with some code within a note that could be run out of the box?

 <button type="button" onclick="javascriptSnippetThatLinksToPrevDay(thisNoteTittle)">Go previous day</button> 

Even if it can’t be done now, maybe its really worthit to make since so many people (including me) would be using a unified coding style vs having to put those in hotkey management systems, right?