[go: up one dir, main page]

Skip to content

20221127:19 - Espanso for repetitive typing

Goals

Use GitLab Support's Espanso library to save a lot of repetition in ticket work.

I want to expand that library, which is general in nature, with opinionated matches for the things I always type by hand:

  • "Thanks for contacting GitLab Support. "
  • "I'm Mike, a GitLab Support Engineer in APAC East. "
  • "Kind regards," (and variants)
  • "GitLab" (with the correctly branded capitalization)

Plus whatever else comes up.

Also, I want date and time substitutions in my preferred formats (ISO-8601 date and 24-hour time, also UTC (local time/date - 10 hours), UTC with local daylight savings (-11 hours), and the format I use for log entries: YYYYmmDD:HH(zulu).

Hypotheses

It should be possible to just install Espanso, and then the custom GitLab Support package and any recommended packages.

For my own matches, it is enough to begin with the basics, and only move onto publishing my stuff as an Espanso package at a later time.

Setting up build/test/run apparatus

  • Install Espanso:
    • Using Homebrew
      brew tap espanso/espanso
      brew install espanso
    • Then run it, (⌘-SPACE espanso) and make sure it is enabled at startup
    • Make sure that Espanso is allowed to control your computer in 🍎 System Preferences → Privacy & Security → Accessibility
  • Install Ruby gems required by GitLab Support snippets:
    for PKG in httparty nokogiri
        gem list|rg $PKG; or gem install $PKG
    end
  • Add the GitLab Support external package:
    espanso install gitlab-support --external --git https://gitlab.com/gitlab-com/support/toolbox/espanso \
    --force  # to overwrite/upgrade already installed package
  • Add some suggested packages:
    espanso install wtc
    espanso install mac-symbols
    espanso install shruggie
  • Add Katrin's "effective markdown" and "greetings - English" packages:
    espanso install greetings-english --external --git  https://github.com/katrinleinweber/espanso-greetings-english
    espanso install effetive-markdown --external --git  https://github.com/katrinleinweber/espanso-effective-markdown

Experiment Procedures

  • Experiment with adding simple matches: to $ESPANSO_DIR/match/base.yml
  • Try linking matches.yml and default.yml to my dotfiles project
  • Add my personal GitLab expansions to a new matches/gitlab.yml file (to keep separate from more general ones)
  • Add More matches as they come up this week
  • Add Espanso settings to a new Dotfiles MR
  • Add Espanso into my brewfile

Outcomes

  • Espanso has a file-watch set up for its configuration directory (which is ~/Library/Application Support/espanso on a MacBook). Any changes to config files will be reloaded automatically
  • The file-watch is defeated with symlinks (because the link file itself does not get updated on saves to ~/etc/dotfiles/espanso)
  • Use hardlinks to restore Espanso's automatic config reload function but from the dotfiles location (the config files go to the same inode with a hardlink)

Conclusions

  • I'm enjoying these shortcuts!
  • I also like that these will work on systems other than macOS (so I can keep them with me if I ever move to a Linux workstation)
  • Also, in case I can't remember the triggers, just need to remember to use ⌥-␣ (option-space)

Concerns?

  • I have two matches for each of the UTC date/time replacements, each with hard-coded offset: values. Can I write some kind of shell/ruby function to determine the offset and reduce these down to one each? Or is there some other way? Because the type: must be date, not shell...
  • Some of the GitLab Support snippets don't work for me:
    21:03:48 [worker(66911)] [ERROR] error during rendering: rendering error
    
    Caused by:
        command reported error: '`sh: espanso: command not found
        ruby: No such file or directory -- /gitlab-support/reference.rb (LoadError)

Next steps

  • See if there is advice or existing matches that take daylight savings into account
  • See what to do about runnning espanso from Espanso, on Apple M1

Edited by Mike Lockhart | GitLab