# ed machines snippets add

> Saves a command against a machine, or against every machine.

- Canonical URL: https://getedith.pro/docs/cli/machines/snippets-add
- Updated: 2026-12-02

Saves a command against a machine, or against every machine.

```
ed machines snippets add [--shared] [--json] <machine> <title> <command...>
```

## Arguments

| Name | Type / values | Default | What it does |
| --- | --- | --- | --- |
| `<machine>` | string, required | none | Machine name, ssh alias, id or unambiguous prefix. Still required with `--shared`, and still has to resolve. |
| `<title>` | string, required | none | What to call it. |
| `<command...>` | one or more words, required | none | The command to save, captured verbatim and joined with single spaces. |

## Options

| Name | Type / values | Default | What it does |
| --- | --- | --- | --- |
| `--shared` | flag | off | Offer it on every machine rather than just this one, which is what leaving the machine unset does in the UI. |
| `--json` | flag | off | Emit JSON on stdout instead of the line. |
| `--help`, `-h` | flag | off | Print the help for this command on stdout and exit 0. |

```
$ ed machines snippets add devbox logs journalctl -xe --no-pager
saved logs on Devbox
```

## `--json` shape

```json
{
  "command": "journalctl -xe --no-pager",
  "id": "F8D5CE93-C9B4-4A05-9109-9AEB1BD806BA",
  "index": 0,
  "sharedAcrossMachines": false,
  "title": "logs"
}
```

As with `forwards add`, `index` is `0` rather than the new row's position. List
the snippets afterwards if you need the number.

## Examples

```
ed machines snippets add devbox logs journalctl -xe --no-pager
ed machines snippets add devbox disk df -h
ed machines snippets add --shared devbox uptime uptime
```

## Behaviour notes

Appends to `snippets.json` and posts `machinesChanged`. Everything after the
title is the command, verbatim, so `--shared` and `--json` have to come before
the machine name; written after the title they are saved as part of the command
instead of read as flags.

The words are joined with single spaces, so the saved string is not
byte-identical to what you typed when you used several spaces or quoted an
argument containing them. A command that is empty or only whitespace exits 1
with `a snippet needs a command to run`.

A shared snippet has no machine of its own, so it survives
`ed machines rm` and shows up on every machine's list.

## Where to go next

- [`ed machines`](https://getedith.pro/docs/cli/machines), the rest of this group
- [All `ed` commands](https://getedith.pro/docs/cli)

## Get Edith

Edith is a native Mac app for macOS 14 or later on Apple silicon with 100+ extensions, the `ed` command line and an MCP server. $35 once for one Mac, plus $7 for each additional Mac, with no subscription and a 30-day refund.

- [Buy Edith](https://getedith.pro/pricing): $35 once for one Mac, plus $7 for each additional Mac
- [Download Edith](https://getedith.pro/download): the installer, or Homebrew
