Skip to content

Bunch

Bunch 是一款 macOS 工作区自动化应用。Protocol Launcher 可以为 Bunch 生成深度链接。

使用方式

提供两种使用方式:

  • 按需加载(通过子路径导入),支持 Tree Shaking,体积更小。
  • 全量导入(从根包导入),使用简单,但会包含所有应用模块。

生产环境建议使用按需加载以减小体积;快速脚本或演示可选择全量导入。

选择安装方式

按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。

URL 方法

以下 helper 在适用时都支持 Bunch 文档中的 x-callback-url 路径格式,以及官方的 x-sourcex-successx-delayx-bunch-beta URL 值。

打开 Bunch

On-Demand
ts
import { open } from 'protocol-launcher/bunch'

const url = open({
  bunch: 'Comms',
})

const shortcutUrl = open({
  bunch: 'Comms',
  syntax: 'shortcut',
})

const pathUrl = open({
  bunch: 'WorkBunch',
  syntax: 'path',
})

使用 Bunch Beta 打开

On-Demand
ts
import { open } from 'protocol-launcher/bunch'

const url = open({
  bunch: 'Comms',
  scheme: 'x-bunch-beta',
})

带 Frontmatter 值打开

On-Demand
ts
import { open } from 'protocol-launcher/bunch'

const url = open({
  bunch: 'Default',
  variables: {
    launch: 'TextEdit',
  },
})

带 Callback 参数打开

On-Demand
ts
import { open } from 'protocol-launcher/bunch'

const callbackUrl = open({
  bunch: 'Comms',
  xCallback: true,
  'x-source': 'com.googlecode.iterm2',
})

const successUrl = open({
  bunch: 'Comms',
  'x-success': 'com.brettterpstra.marked2',
  'x-delay': 15,
})

关闭 Bunch

On-Demand
ts
import { close } from 'protocol-launcher/bunch'

const url = close({
  bunch: 'Comms',
})

const pathUrl = close({
  bunch: 'Comms',
  syntax: 'path',
})

切换 Bunch

On-Demand
ts
import { toggle } from 'protocol-launcher/bunch'

const url = toggle({
  bunch: 'Comms',
})

const pathUrl = toggle({
  bunch: 'Comms',
  syntax: 'path',
})

切换带标签的 Bunch

On-Demand
ts
import { toggle } from 'protocol-launcher/bunch'

const url = toggle({
  tag: 'Tag1+Tag2',
})

编辑 Bunch

On-Demand
ts
import { edit } from 'protocol-launcher/bunch'

const url = edit({
  bunch: 'Example',
})

const pathUrl = edit({
  bunch: 'Example',
  syntax: 'path',
})

运行原始 Bunch 文本或文件

On-Demand
ts
import { raw } from 'protocol-launcher/bunch'

const fileUrl = raw({
  file: '~/MiscBunch.bunch',
})

const textUrl = raw({
  txt: '(dnd on)',
})

刷新 Bunch 文件

On-Demand
ts
import { refresh } from 'protocol-launcher/bunch'

const url = refresh()

在 Finder 中显示 Bunch 文件夹

On-Demand
ts
import { reveal } from 'protocol-launcher/bunch'

const url = reveal()

设置偏好

On-Demand
ts
import { setPref } from 'protocol-launcher/bunch'

const toggleUrl = setPref({
  toggleBunches: 1,
})

const folderUrl = setPref({
  configDir: '~/Dropbox/Sync/Bunches',
})

运行 Snippet

On-Demand
ts
import { snippet } from 'protocol-launcher/bunch'

const url = snippet({
  file: 'useful.snippets',
  fragment: 'Music',
  variables: {
    playlist: 'spotify:playlist:3cSpIL4Q0H3uqdBMbT6c9x',
  },
})

const pathUrl = snippet({
  file: 'useful.snippets',
  fragment: 'Speak',
  syntax: 'path',
  variables: {
    var1: 'foo',
    var2: 'bar baz',
  },
})

打开偏好设置

On-Demand
ts
import { prefs } from 'protocol-launcher/bunch'

const url = prefs()

官方文档