Bunch is a Mac app that allows you to create plaintext files to launch a “bunch” of apps and change system settings. It is great for contextual computing and I use it to automatically rearrange windows with hammerspoon, set a Focus Mode with Shortcuts, open a perspective in Omnifocus, and start a timer with Timery all at the same time when I switch contexts. The only problem is that it is a little bit annoying to edit these plaintext files without any syntax highlighting to see commands and strings and stuff like that.

To fix this, I created a plugin for my favorite text editor, atom (I’m using it right now as I write this), which adds support for .bunch files. It also includes. snippets for common commands.

install the plugin here

contribute to the plugin on github

Creating atom language plugins

I created this plugin as a treesitter language plugin for atom. It has a very simple file structure:

language-bunch
├── LICENSE
├── README.md
├── grammars
│   └── bunch.cson
├── snippets
│   └── bunch.cson
└── package.json

Syntax highlighting

The grammars/bunch.cson file has a patterns field that lets you patch regex patterns, and tell Atom what the text represents, a string, a variable, a command, etc. For example, here is the code to match comments in .bunch files.

{
    name: 'comment.line.bunch'
    match: '#.*$'
}

Snippets

Then, in the snippets/bunch.cson file, you can list a “prefix” and a “body” to show autocomplete suggestions for common commands. For example, here are a few commands I use for bunch files.

'display':
    'prefix': 'di'
    'body': 'display '
'dark mode':
    'prefix': 'da'
    'body': 'dark mode'
'light mode':
    'prefix': 'li'
    'body': 'light mode'
'wallpaper':
    'prefix': 'wal'
    'body': 'wallpaper'