Macterm

Extension examples

Each example on this page is a complete palette. Save it at the path in its caption. Put an extension.yaml next to the palettes/ folder (see a first extension). Then press ⌘P and select the palette. For each key, see the palette reference.

Docker containers

~/.config/macterm/extensions/docker/palettes/docker.yaml
name: Docker
description: Running containers, their logs and a shell in them
root: containers
nodes:
  containers:
    list: docker ps --format json
    title: .Names
    subtitle: .Image
    match: [.Names, .Image, .Status]
    export: { CONTAINER: .ID }
    enter: container
  container:
    items:
      - { title: Logs, subtitle: Follow in a split, action: { run: docker logs -f "$CONTAINER", in: split } }
      - { title: Shell, action: { run: docker exec -it "$CONTAINER" sh, in: split } }
      - { title: Stop, action: { run: docker stop "$CONTAINER" } }

SSH

This palette lists the hosts that are named in ~/.ssh/config. It leaves out wildcard patterns. It does not list hosts in an Included file.

~/.config/macterm/extensions/ssh/palettes/ssh.yaml
name: SSH
description: Hosts from ~/.ssh/config
root: hosts
nodes:
  hosts:
    list: awk 'tolower($1) == "host" { for (i = 2; i <= NF; i++) if ($i !~ /[*?!]/) print $i }' ~/.ssh/config
    export: { HOST: . }
    enter: host
  host:
    items:
      - { title: Connect, action: { run: ssh "$HOST" } }
      - { title: Connect in a split, action: { run: ssh "$HOST", in: split } }

The extensions in the repository

Each extension in Settings → Extensions is also an example. Their files are in extensions/ in the Macterm repository. Read them to see the larger parts of the format together: