Greed
Greed is a modal text editor. You pick the keys (Helix, Vim or VS Code), and it comes with a shell, terminals, notes and mail, with agents in all of them. It runs in a terminal or a window, locally or over ssh.
I wanted an editor I could bend as far as Emacs, without it ever freezing on me while a plugin thinks. So the core is a small Rust program, and everything else - the keys you edit with, modes, commands, pickers, themes, the agents - is Luau plugins you can read, change or swap out while it runs.
To start, just run greed, answer its few questions, then :tutor - it walks you
through your style’s keys with lines to practise on, then shows you around.
This manual comes with Greed, so it matches the version you run. In Greed:
| Keys | |
|---|---|
space h d | Go to a page or heading (:docs boards goes straight to one) |
space h / | Search the manual |
Pages open as documents: enter follows a link, esc shows the Markdown.
What’s in here
- Using Greed: editing, searching, files, sessions and configuration. The place to start.
- Hoard: your notes and todos, as plain Markdown files.
- Several clients: terminals and windows on one session.
- Sessions, machines and the hub: what runs where, and one key to get there.
- The shell: commands as blocks you keep, search and run again.
- Boards: live shell commands saved as a page of cards.
- Charts: any table as a chart that follows the numbers.
- Mail: your IMAP accounts, searched as you type.
- Chat: Matrix and Mattermost rooms, still experimental.
- Editing styles: the Vim, Helix and VS Code styles, their keys, and making your own.
- Keys: finding out what a key does, and binding your own.
- Highlighting: how code is highlighted and themed.
- Plugins to install: plugins others wrote, like themes.
- Writing plugins and Building interfaces: commands, keys, decorations, panels, tests and types, and drawing your own lists and fields.
- Agents:
greed ctl, MCP, proposals,/ide, and agents inside Greed. - Permissions and sandboxing: what agents and plugins may do, and what asks you.
- How Greed is built: what lives in Rust, what lives in Luau, and why.
Why mail and chat in an editor? Because I wanted what I know in one place: code, notes, mail and conversations, behind keys I picked, with an agent that can search all of it with me. None of it runs until you set it up, though. If you only want an editor, that’s all you get.
It’s really early days, so expect a few things here to change. If something’s wrong or missing, an issue or a pull request is very welcome.
These pages are plain Markdown, readable in a terminal or in Greed itself, and they make the documentation at greed.rs.
Using Greed
Starting and sessions
greed FILE opens a file; one that isn’t there yet opens empty, and :w
writes it there. The editor runs as a session in the background,
and what you see is a client attached to it: the terminal, a window
(greed --gui), or several at once, here or over greed ssh. Closing a
client (or :detach) leaves the session as it was: open files, undo
history, language servers.
Each project gets its own session, named after its folder. greed anywhere
in a project attaches to that session (opening the file you named), or
starts it. A slow plugin or a crash in one project’s session leaves the
others alone. How sessions keep track of each other, here and on other
machines, is in Sessions, machines and the hub.
| Command | What it does |
|---|---|
greed [FILE or FOLDER] | Attach to the project’s session, or start it |
greed --session NAME [PATH] | Attach to or start a session with this name, e.g. a second one for a project |
greed --new [PATH] | Start another session for the project, beside the one running, with this greed: for trying a newer build |
:detach | Leave the session running |
greed attach [NAME] | Attach to a session; the only one if there’s one |
greed ls | List running sessions, their projects and how their agents are doing (◆ 1 waiting for you), marking those running another build than this greed |
greed serve [PATH] | Run a project’s session with no terminal |
:q | Close the pane, as Vim closes a window, when the tab has others; the tab, when it’s the last pane and there are other tabs. Otherwise close the shown project and leave; on the last one, end the session unless something is running in it (see below). In a panel or a float (an agent’s transcript, help) it closes only that |
:quit-session, :qa | End the session, whatever runs in it. With unsaved files it lists them and stops; :wa saves them, :wqa saves them and ends it, :qa! ends it anyway |
greed edit [--wait] FILE... | Open files in the running editor; with --wait, return once each is closed with :q or :wq (:cq fails it), as $EDITOR for git commit. Greed’s own shells set this up already |
greed ctl quit [--force] [NAME] | End a session from a shell, unless it has unsaved changes (--force ends it anyway) |
A session keeps running the greed it started with. greed --version names
the build (greed 0.2.0 (build b5432b407145), a hash of what it was built
from). Attaching to a session of another build, as after rebuilding greed
while it ran, says so on the status line: greed --new starts a session of
your build beside it, and greed ctl quit NAME ends the old one. greed ssh puts your build on the other machine when it runs the same system, and
keeps the last few builds there.
A session of another version of Greed, as after upgrading while it ran,
can’t be shown: the two speak different protocols. Greed shows a page with
the session’s unsaved files and what’s running, in the terminal, the window
or over greed ssh, and offers to:
- end it and start your version in its place,
- open it with the version it runs, to save your work first (when that greed is still on this machine),
- start your version beside it.
A number picks, esc leaves it as it is. From a shell, greed ctl state NAME prints what’s unsaved and running in a session of any version, and
greed ctl quit NAME ends it; the next greed then starts a new one.
Several terminals can show one session: run greed or greed attach in
another terminal, or greed ssh from another machine. They share buffers
and undo history; each has its own cursors, focus and mode, and :detach
lets only that one go. A terminal coming back from the same machine gets
its cursors, focus and mode back; a new one starts where the one used last
is. Copies go to the clipboard of the terminal that copied, desktop
notifications to the one used last.
Attached terminals follow each other: same project, tab and panes, each
with its own focus and pane zoom. :client-independent lays one out on its
own, :client-follow has it follow again. Pickers, prompts and the command
line show only on the terminal that opened them, and a program in a
terminal pane is sized for the client that last typed into it. Several
clients has the details.
greed commands lists every command line command, including the ones
plugins add (greed ls, greed new and greed bring are plugins too).
Switching to another session (space P, :session) moves your terminal
there and leaves the session you were in running. Over greed ssh it
reconnects through a new ssh connection, which is close to instant with
ssh connection sharing (ControlMaster).
What goes over greed ssh is compressed with zstd, by Greed itself: typing
and moving around send some 50 times less, whatever ssh is set up to do.
In one of Greed’s own terminals, greed FILE opens the file in that session
and returns, rather than starting an editor inside the editor, and
greed ctl talks to that session. Programs there can tell from
$GREED_TERMINAL, which names the session; $GREED_TERMINAL_ID says which
terminal and $GREED_BIN which greed runs the session.
If a session can’t start in the background, GREED_NO_SESSION=1 greed FILE
runs the editor directly in the terminal.
A session remembers its projects, their open files and cursors, and the
tabs of the project you were in: panes, what each showed, and their
terminals, which run what they ran again (one that ran something risky,
like rm -rf or kubectl delete, comes back as a plain shell). When it
ends without being quit, as in a crash, a reboot or a logout, the next
start opens all that again. A session you quit (:quit-session, :qa)
starts clean next time. Ending one to start it again with a newer greed,
from the page that asks about the other version, restores it. This is
written when the session starts, quits, and opens, closes or saves a
file, in the cache folder (~/.cache/greed/sessions). Starting with a
file keeps that file shown.
| To | |
|---|---|
| Start one session fresh | greed --fresh (or greed ssh HOST --fresh); quit a running one first, or start another with --new |
| The same on a Mac | Hold Shift while Greed opens |
| Bring back a session you quit | greed --restore, as the next start after quitting it |
| Restore after quitting too, always | greed.option.set("restore-after-quit", true) |
| Turn restoring off | greed.option.set("restore-session", false) |
Quitting or keeping a session
:q and :wq in a pane with others beside it close that pane, as Vim
closes a window; in a tab’s last pane they close the tab while there are
others. The file stays open, so this never asks about unsaved changes.
ctrl-q in the vscode style asks to save, quit without saving or cancel,
as VS Code does.
:q on the last project ends the session, unless that would stop a
command in one of its terminals, a program like a task, or an agent at
work. Then it detaches and the session keeps going, so greed comes back
to it. A shell waiting at its prompt doesn’t count. Over greed ssh, :q
keeps the session by default, since reattaching is quicker than starting
again over the network.
:quit-session (or :qa) ends it whatever runs in it. Unsaved files stop
it: it lists them, :wa saves them and :qa! ends the session anyway.
Terminals, shells, agents’ panes and other scratch buffers never count as
unsaved.
Set what :q does, here and over greed ssh:
local greed = require("@greed")
-- "auto": end it unless something runs; "end": always end it;
-- "keep": always leave it running
greed.option.set("on-quit", "auto")
greed.option.set("on-quit-remote", "keep")
A session with nothing attached, nothing running and nothing unsaved ends
by itself after a day, so sessions don’t pile up on machines you visit;
session-idle-hours changes how long, and 0 keeps them for good. Plugins
can say what of theirs is running with require("@core").file.running.
The first time
Started without a config (~/.config/greed/init.luau), Greed shows a setup
page that asks:
- how you like to edit, and which theme (both switch at once, to try them),
- whether your font has icons (in a terminal, which needs a Nerd Font; the window has them built in and doesn’t ask),
- whether to add Greed’s tools to the agents installed here (Claude Code, Codex, Gemini CLI),
- which language model Greed’s agent and other features use (Anthropic, OpenAI, Berget, Mistral, Ollama on this machine, or none for now).
The page is a questionnaire and works the same in every
editing style: tab and shift-tab move between choices, enter,
space or a click picks one or presses a button. Under the models, a
button sets the API key (kept in the system keyring) or signs you in; for
Ollama the page says whether it answers, and if not, to run ollama serve
and ollama pull llama3.2.
Save writes an init.luau from your answers and opens it, and points
the fast and reasoning roles at the provider you picked (:models
changes them later). Below your answers it lists more settings, commented
out: remove the -- and save, and one applies at once. space h o
describes an option, and :set NAME VALUE tries one for the session.
Save never replaces an existing config; it shows what to add instead, and
esc closes that.
Not now, esc, q or closing the page writes nothing. Either way the
page doesn’t come back by itself; :setup opens it again, or goes to it if
it’s open.
:tutor teaches the keys of the style you picked, with lines to practise
on in each lesson (each says done once you get it right), then shows the
leader, finding files, panes, the shell and sessions. Picking another style
on the page switches the lessons too. Nothing on the page is saved;
:tutor gives a fresh one.
In a window
greed --gui [FILE] shows the session in a window, drawn on the GPU. It’s
the same session a terminal attaches to, and greed ssh HOST --gui shows a
session on another machine in a window here. Closing the window detaches,
as :detach does. Going to another session (space P, :session)
shows it in the same window, as a terminal would; alt-w in space P
opens one in another window instead.
ctrl-shift-n (cmd-n on macOS, or File, New Window) opens another
window on the same session, laid out on its own from what this one shows,
the way a terminal’s new window starts where you are. space P in it
takes it to another project.
The window draws with your system’s monospaced font, ligatures included when the font has them (Fira Code, JetBrains Mono, Cascadia Code), and draws box lines itself so borders join cleanly. Images show as they do in a terminal with kitty graphics, PDFs included. Dead keys and input methods type as they do elsewhere, and the window opens at the size it last had. On Linux it needs Wayland or X11 and a Vulkan or GL driver.
On macOS the menu bar holds Greed’s menus (File, Edit, View, Pane, Help),
each item a command, after the Greed menu with Hide and Quit Greed (⌘Q).
Elsewhere there’s no menu bar, and the command palette (space ?, or
ctrl-P in the vscode style) lists every command. Plugins and your
config add items:
require("@core").menus.add("Tools", "Run tests", "test-run").
Dropping a file on the window pastes its path, as a terminal does, so a
screenshot dropped on a terminal pane running Claude Code hands it the
picture. With the session on another machine (greed ssh), the file is
copied there first, into the cache folder’s dropped, and that path is
pasted; files over 50 MB stay behind with a message. In a terminal,
dropping a file pastes its path too; over greed ssh a paste of nothing
but paths to files on your machine sends the files along, so the session
gets paths it can read.
Copies in Greed go to the system clipboard, and what another program
copied becomes Greed’s clipboard when the window gets focus, so p (or
ctrl-v in the vscode style) pastes it. ctrl-shift-v and shift-insert
(cmd-v on macOS) paste the system clipboard at the cursors in any mode,
as a terminal’s paste does.
Lines copied whole (y y in the Vim style, x y in Helix’s, ctrl-c with
nothing selected in the vscode style) paste above or below the line in all
three styles. Text copied in another program pastes at the cursor.
ctrl-= and ctrl-- zoom in and out, ctrl-0 puts the size back; each
window zooms on its own. Font and size go in your init.luau, and windows follow as
soon as they change:
local greed = require("@greed")
greed.option.set("gui-font", "JetBrains Mono")
greed.option.set("gui-font-size", 14) -- pixels, before the screen's scale
greed.option.set("gui-font-prose", "Inter") -- prose, like Markdown's text
Prose (Markdown’s text, and any style with font = "prose") is set in a
proportional font, the system’s sans-serif unless gui-font-prose names
one, at its own width; code stays in the grid’s font. The cursor,
selections and clicks follow the text where it’s drawn.
Scrolling glides, whether you scroll or a streaming reply keeps the view at its end. To jump instead:
greed.option.set("gui-smooth-scroll", false)
Buttons, fields and choices light up as the mouse goes over them. With an input method (for Japanese, Chinese or Korean, say), what you’re composing shows underlined at the cursor until it’s typed.
In the window, floats (pickers, prompts, hover info) have rounded corners
and a shadow (lighter on a light background) unless the theme turns them
off; terminals draw square box lines. The window draws the round ends of the
status line’s pills itself, so they need no Powerline font. Square floats
without shadows, or rounded ones in the terminal too (╭╮╰╯, if its font
joins them well):
greed.theme.set({ ["ui.float"] = { gui = { rounded = false, shadow = false } } })
greed.theme.set({ ["ui.float"] = { tui = { rounded = true } } })
Projects
A project is the nearest folder above a file that holds .jj or .git,
or the folder itself if none does. A session can hold several projects:
each has its own files, main view and panels (file tree, search results),
and the file picker, project search and tree work within the shown one.
| Keys | |
|---|---|
:project PATH | Open the project PATH is in here, in this session, or switch to it |
space P | Go to a project: one open here, another running session, a recent one, or one your sources find; each says what enter does with it. Type a folder path (~/src/) to list the folders in it, tab to go into one |
alt-o in space P | Open the project here, in this session, beside what’s open |
alt-enter in space P | Open the project in a new session, even if one is running for it |
alt-w in space P | In a window, open the project in another window and keep this one; in a terminal, go to it as enter does |
space C or :connect HOST | Show a session on another machine here, as greed ssh does: pick from the hosts you connected to lately and those in ~/.ssh/config, or type one |
:session NAME or :session PATH | Go to a running session, or to the session for a project (starting it) |
space B or :session-back | Go back to the session you were in before, on whichever machine; again to return |
:session-home | Go back to this machine from another: the session here you were in last |
:project-close | Close the shown project |
:q | In the last pane of the last tab, close the shown project and leave; on the last project, end the session unless something runs in it |
:qa | End the session and every project in it |
A project gets a session of its own by default. enter in space P goes
to a project open here, or to the session running for it, and starts a
session for a recent project or a folder you typed, like greed FOLDER
from a terminal. Each entry says which: (open here), (goes to session greed), (recent, starts a session). To work across projects in one
session, like a library and the app using it with one buffer list and one
grep, open the second one here with alt-o in space P or :project PATH. Like every space key here, space P is on the leader: in the
vscode style, where space types, it’s ctrl-space P.
To find projects you haven’t opened yet, give space P sources in your
init.luau: folders to look in, and commands that print one path per line.
require("@projects").sources({
-- every folder one level under these
{ dirs = { "~/Development", "~/Work" } },
-- deeper, but only folders that look like projects
{ dirs = { "~/src" }, depth = 3, markers = { ".jj", ".git" } },
-- any command that prints paths
{ command = { "zoxide", "query", "-l" } },
{ name = "ghq", command = { "ghq", "list", "-p" } },
})
The picker shows what they found the last time it looked, so it opens at once, and looks again in the background each time it opens and when the editor starts. Each entry says where it came from.
Editing on another machine
greed ssh build-box src/main.rs
greed ssh HOST [--session NAME | --new] [FILE] shows a session running on
another machine, starting one if none is running; --new starts another
beside it. Files, language servers, search and agents run on that machine;
only keys and screen updates cross the network. After :detach the session
keeps running, and greed ssh HOST comes back to it.
If the connection drops (the network goes, the laptop sleeps), greed ssh
says so and reconnects to the same session by itself: every second for the
first twenty tries, then waiting a little longer each time (ctrl-c stops
it). The two ends check in every few seconds, so a quiet connection is
noticed within about fifteen seconds, and the session lets that client go
then too. Waking from a longer sleep, Greed knows straight away and
reconnects. The window keeps showing the last screen with reconnecting…
over it until the session’s screen is back.
From inside Greed, space C (:connect, or Connect to Host… in the
window’s File menu) does the same without a terminal: pick from the hosts
you connected to lately and those in ~/.ssh/config, and the window or
terminal you’re in moves to that machine’s session. space B goes back,
and again returns, so sessions on two machines are a key apart. On another
machine space C lists home first (:session-home): the session on your
own machine you were in last.
| Command | |
|---|---|
greed ssh HOST --terminal | Show the session and open a terminal on that machine in a new tab; it runs in the session, so it survives a disconnect. greed --terminal does the same here |
greed ssh HOST --shell | Show the project’s greed shell, opening one if there’s none (see The shell); greed --shell here |
What runs where
Everything in the session runs on the other machine, with its programs, folders and variables: your config and plugins, files and saving, shells and terminals, language servers, search and agents. The Greed in front of you draws the screen and sends keys, mouse and clipboard, and needs nothing of the project.
Your config, both ways
Each greed ssh copies your ~/.config/greed (init.luau and your
plugins) to the other machine first, into
~/.cache/greed/config-from-<this machine>, replacing the copy from last
time, and a session it starts runs that copy.
-
Changed your config here? Connect again and it’s copied over. A session that was already running keeps the config it loaded; run
:config-reloadin it to run the fresh copy. -
Something different on that machine? Its own
~/.config/greedruns after the copy and wins, andgreed sshnever touches it. Put what’s for that machine alone there: a setting in itsinit.luau, or a plugin with the same name as one of yours, which replaces yours there.-- ~/.config/greed/init.luau on build-box: only there. local greed = require("@greed") greed.option.set("line-numbers", "relative") -
Changed something over there? It stays there, across connections: edits to that machine’s own config, and plugins you or an agent made or installed there. Nothing is copied back by itself. A plugin comes home with
greed bring(below); a setting you want everywhere, copy into your owninit.luauhere.
GREED_SSH_CONFIG=0 leaves your config at home.
greed bring HOST lists the plugins in the other machine’s own config and
data folders, and greed bring HOST PLUGIN copies one into your config’s
plugins folder. A running Greed loads it at once, after asking you to
approve what it uses.
$ greed bring build-box
build-box has these; greed bring build-box PLUGIN copies one here:
/home/me/.config/greed/plugins/todo-sync
$ greed bring build-box todo-sync
What the other machine needs
Your login shell on the other machine can be anything (bash, fish,
nushell): greed ssh only asks it to start sh, and needs a POSIX sh
and tar there. Where commands over ssh come without XDG_RUNTIME_DIR,
a session it starts uses /run/user/<uid> like a login would, and so do
the programs in its terminals.
Greed doesn’t have to be installed there. The first time you connect with
a version, greed ssh puts the same version in
~/.local/share/greed/server and uses it from then on: a copy of the greed
you run when it runs there, otherwise (NixOS, or an arm machine) that
version’s static build from the releases, checked against the release’s
checksums. A greed of the same version already on that machine’s PATH is
used as it is. Where there’s no greed on its PATH, a session puts its own at the end of
its programs’ PATH, so greed FILE in its terminal opens the file there.
The programs that come beside greed, like greed-mail for greed mail,
go along with it, built for that machine too; a machine that got its greed
before they did gets them the next time you connect. The first time takes
a while, it’s some 150 MB; with --gui the window says how far it got.
GREED_REMOTE sets the path of greed on the other machine, and nothing
is copied (the two ends check they speak the same protocol, and say so if
they don’t); GREED_REMOTE_BINARY names a greed built for it to copy (like
nix build .#static’s, between releases). GREED_SSH sets the ssh
program to use. It’s run as one program, so for options like a port use
~/.ssh/config or a small wrapper script.
Your ssh agent
For a host your ~/.ssh/config forwards the agent to (ForwardAgent yes, as ssh -G HOST shows it), Greed forwards your ssh agent itself.
The session there has its own agent socket, which its shells and
terminals get as SSH_AUTH_SOCK; each request on it goes to the agent on
the machine you’re attached from. The socket stays the same across
reconnects, so git push in a shell open for a week reaches your keys
after you come back, from this machine or another. With nobody attached, a
request fails at once. Greed turns ssh’s own forwarding off for its
connection, so the session has one way to your keys.
The agent used is the one SSH_AUTH_SOCK names where you run greed ssh,
if it answers; otherwise (a shell can keep a stale one, say from a closed
terminal window) the IdentityAgent your ssh config names for the host.
When neither answers, the status line says so and why, instead of only
“agent refused operation” in the program that asked.
Before a program there signs with one of your keys, Greed asks on your
screen, and y allows it. Listing your keys doesn’t ask. The
ssh-agent-confirm option says when to ask: first (the default) once
each time you attach, always every time, never not at all.
greed.option.set("ssh-agent-confirm", "always")
-- Some machines their own way, by the name of the machine the session
-- runs on: ask every time on the bastion, never on your own box.
greed.option.set("ssh-agent-confirm-hosts", "bastion=always devbox=never")
A zellij or tmux on that machine runs outside the session, with the agent socket of whichever connection started it. Its shells can use the session’s socket instead, from their rc file:
export SSH_AUTH_SOCK=$(greed ctl agent-socket)
With several sessions there, greed ctl agent-socket SESSION names one.
While you’re attached, anyone with root on that machine can use your keys
through the socket, as with ssh -A. Asking before each use (always)
means nothing signs without you pressing y.
Editing
Greed has three editing styles: Helix’s (select, then act), Vim’s (act,
then where) and modeless, as in VS Code. Greed asks which the first time it
starts, :style vim switches at any time, and Editing
styles has each one’s keys and how to make one your
own.
Keys typed while a command is still working (say, on a slow program) wait
for it, up to half a second, and then run in order. esc and ctrl-c
reach a working command at once, unless keys typed before them are still
waiting.
Long lines wrap after a space where they can, and wrapped rows start at the line’s indent (unless that would take more than half the view).
Messages show on the status line, one line each; a longer one, like an
error with its stack trace, ends in …. :messages shows the last ones
in full.
This page shows the Helix style, Greed’s default: select text, then say what to do with it. There is always a selection; a cursor is a selection one character wide.
Moving and selecting (normal mode)
| Keys | |
|---|---|
h j k l, arrows | Move |
w b e | Select to the next word, previous word, word end |
W B E | The same for WORDs, which include punctuation (a.b) |
f t + a character | Select to the next one, or up to it; F T go back |
x | Select the line; again, the next one too |
g g g e | Start of the file, start of its last line |
G, 5 G | The last line, or line 5 |
g h g l g s | Start and end of the line, first character that isn’t a space |
m m | The matching bracket |
g w | Label every word on screen; type a label to jump there (jump-label-alphabet sets the letters, easiest first) |
; alt-; | Collapse the selection to the cursor, swap its ends |
ctrl-h ctrl-k | Back to the selection before the last command, and forward again |
% | Select the whole file |
ctrl-f ctrl-b | A screen down or up (also pagedown pageup) |
ctrl-d ctrl-u | Half a screen down or up |
z z z c, z t, z b | Put the cursor’s line in the middle, at the top or at the bottom of the screen |
z j z k | Scroll a line down or up; Z keeps the view keys going until esc |
g t g c g b | The top, middle or bottom line on the screen |
g n g p, g a, g m | The next or previous open file, the one you were in before, the one you changed last. A pane goes back to a file with the cursor and scroll where it left them, however you switch |
g . g |, g f | Where the file last changed, column N (8 g |), the file named under the cursor |
alt-. | Do the last f or t again |
ctrl-o ctrl-i | Back to where the last jump (a search, g g, g d, a file you opened from anywhere, the shell included) started, and forward again, like a browser’s back and forward. Each pane has its own, and going back puts the cursor and scroll where they were (ctrl-i needs a terminal that tells it from tab, as most do now) |
:set line-numbers relative numbers lines by distance from the cursor’s
line, so the line marked 5 below is 5 j away. hybrid also shows the
cursor’s line’s own number, like Helix’s relative, and absolute goes
back.
The view keeps 5 lines in sight above and below the cursor as it follows
it, so you see what’s coming. Paging, g t g b, z j z k and the
mouse wheel keep the cursor out of those lines too. It’s Vim’s and
Helix’s scrolloff, here scroll-margin; 0 lets the cursor go to the
edge, and a big number keeps it in the middle:
greed.option.set("scroll-margin", 0)
Changing
| Keys | |
|---|---|
i a | Insert before or after the selection |
o O | Open a line below or above |
I A | Insert at the start or end of the line |
d c | Delete, or delete and insert, copying what was deleted |
alt-d alt-c | The same without copying |
r + a character | Replace every selected character with it |
R | Replace the selections with what was copied |
~ ` alt-` | Switch case, lowercase, uppercase |
:snake-case :camel-case :pascal-case :kebab-case :title-case :sentence-case | Change the selected words to that case, each line on its own: fooBar to foo_bar, fooBar, FooBar, foo-bar, Foo Bar or Foo bar |
> < | Indent or dedent the lines by one level of the language’s indent |
J | Join lines with one space |
:reflow [WIDTH] | Rewrap the selected lines to the text-width option (80), or WIDTH |
| | Pipe each selection through a shell command, a Luau filter or a model (below) |
space c, ctrl-c | Comment the lines, or uncomment them |
= | Format the file |
] space [ space | Add an empty line below or above, staying put |
y p P | Copy, paste after, paste before; copied lines paste above or below the line |
" + a letter | Use that register for the next copy, paste, delete or macro, instead of the clipboard |
Q q | Start or stop recording a macro, play it (3 q three times) |
:macro-save NAME [REGISTER] | Keep the last macro as a command, in a macros plugin in your config that opens to edit |
u U | Undo, redo |
alt-u alt-U | Back or on through every state the text has been in, in the order it was made, including what an undo followed by an edit left on another branch |
space u t | The undo tree: every state and branch; moving takes the text there, enter keeps it, esc goes back |
. | Repeat the last change at the selections, with what it typed (3 . with a new count) |
esc | Back to normal mode |
Undo lasts across restarts: each time you save a file, its undo history
is kept in Greed’s cache folder, and when you open the file again, as it
was saved, undo goes on past where it was opened. A file something else
changed in between starts afresh. Since undo keeps deleted text, files the
project ignores and files named like secrets (.env*, *.pem, *.key,
id_*) aren’t kept; the rest are readable only by you, go after 30 days
without a save, and a history over 10 MB isn’t kept. :set undo-files false turns it off.
In insert mode, tab types a level of indent, ctrl-w (or
alt-backspace) and alt-d delete a word back or forward, ctrl-u and
ctrl-k delete to the start or end of the line, ctrl-x asks for
completions, and ctrl-r + a register inserts what it holds.
A number before a motion repeats it: 3 j, 2 w. It also counts for x
(lines), p and P, u and U, > and < (levels), C and alt-C,
and picks brackets further out with m i ( and the like.
Some registers aren’t storage: "_ throws a copy away, "+ and "* are
the clipboard, "% is the file’s path, ". what each selection holds,
"# each selection’s number and "/ the last search.
| asks what to pipe the selections through, and puts back what comes out,
each selection its own:
| Type | What it does |
|---|---|
sort -u | Runs a shell command, with the selection as its input |
luau: snake_case | Runs a Luau filter: upper, lower, trim, snake_case, kebab_case, camel_case, pascal_case, sort, reverse, or one you add with require("@pipe").define |
model: add doc comments | Asks a language model (the fast role, or :set pipe-model-role reasoning) |
Helix’s other shell keys work too: ! puts what a command prints before
each selection and alt-! after it, alt-| gives each selection to a
command without changing it, and $ keeps the selections a command
succeeds on ($ grep -q TODO).
All the selections change in one step, so u takes them back. A model’s
changes are also an operation you can review with space u o, and if you
edit while the model works, the answers still land where the selections
were. See Models to set one up.
New lines from enter, o and O start at the indent the code calls
for: a level in inside a block, bracket or let, and lined up with the
block’s first line before its } or end. Between a pair of brackets,
enter puts the closing one on its own line. A line holding only a closer
like end, else or } lines up with its block when you press enter on
it, and a closing bracket does as you type it at a line’s start.
Languages without a grammar, and code that doesn’t parse yet (a Ruby def
before its end), keep the line’s indent, one level more after an opening
bracket (or a : in Python and YAML), going by the language’s keywords
(indent_after and outdent_before in its entry).
Each language has its own indent, like two spaces in Nix or a tab in Go;
the indent option is for files in no language. Tabs show 4 columns wide;
a language’s tab_width changes that for its files, and :set tab-width 8
for the rest:
require("@languages").set("nix", { indent = 4 })
require("@languages").set("go", { tab_width = 8 })
Brackets and quotes come in pairs as you type them in the helix and
vscode styles: ( brings its ) with the cursor between, typing ) next
to one steps over it, and backspace between an empty pair deletes both. A
pair only opens before a space, a closer or the line’s end, and a quote not
after a letter or digit, so don't stays as typed. In the vscode style, an
opener typed over a selection goes around it. Vim’s style leaves them alone,
since . and macros replay what was typed. :set auto-pairs on (or off)
says otherwise for any style, and style goes back to the style’s way.
Each language can have its own pairs; Rust’s leave ' out, for lifetimes:
require("@languages").set("lua", { pairs = { ["("] = ")", ["{"] = "}", ['"'] = '"' } })
A file gets its language from its name; :language NAME gives a buffer
another one (:setf too, as in Vim), and :language alone says which it
has. :reindent-lines indents the selected lines again, for code pasted in
at the wrong indent.
Many selections
| Keys | |
|---|---|
s | Select every regex match inside the selections |
S | Split the selections at a regex |
alt-s | Split the selections into lines |
K alt-K | Keep or drop the selections that match a regex |
C alt-C | Add a selection on the line below or above |
, alt-, | Keep only the primary selection, or drop it |
( ) | Make the previous or next selection primary |
X alt-x | Extend each selection to whole lines, or shrink it to the whole lines inside |
alt-_ | Merge selections that touch (:merge-selections merges them all) |
_ & | Trim spaces off the selections, line them up at one column |
alt-( alt-) | Rotate what the selections hold, back or forward |
ctrl-a ctrl-x | Add to or subtract from the number at each cursor (5 ctrl-a) |
v | Select mode: moves extend the selection, n N add the next match as another selection; it lasts until you change or copy the text |
With several selections, everything you type or delete happens at each one.
%, then s foo, then c bar replaces every foo in the file. s with
nothing typed uses the last search, so * on a word, then % s enter,
selects every place it appears.
Text objects and surround
| Keys | |
|---|---|
m i w m a w | The word, or the word and the space after it (W for WORDs) |
m i ( m a ( | Inside or around the brackets; also [ { < |
m i " m a " | Inside or around the quotes; also ' and ` |
m i m m a m | Inside or around the nearest brackets or quotes, whichever they are |
m i x m a x | Inside or around the XML or HTML element |
m i n ( m i l ( | Inside the next or last pair after or before the cursor (m a for around); any bracket or quote |
m i i m a i | The lines indented as far as this one, or with the line above too |
m i d m a d | The number at or after the cursor, or with its sign |
m i g m a g | The change since the last commit under the cursor, or its whole lines |
m s ( | Wrap each selection in brackets, quotes, or any character |
m d ( | Take away the brackets or quotes around each selection |
m r ( [ | Swap them for others |
By syntax, in languages Greed has a grammar for (:health lists them):
| Keys | |
|---|---|
m i f m a f | Inside or around the function |
m i t m a t | Inside or around the type: a struct, enum, impl or table |
m i a m a a | An argument or parameter, around with its comma |
m a c | The comment |
m i T m a T | Inside or around the test (Rust, Python, Go, JavaScript and TypeScript) |
m a e | An entry in a table, map or struct |
] f [ f | The next or previous function; also t, a, c, T and e |
] m [ m | The next or previous item where a buffer is made of them: a message in a chat room or a mail thread, a row of the mail list; a count goes that many |
alt-o alt-i | Grow the selection to the syntax node around it, or shrink it back |
] n [ n | The next or previous node beside it (Helix has these on alt-n alt-p, which are pane keys here) |
alt-a alt-I | Every node beside it, or every node inside it |
alt-shift-right alt-shift-left | Move the selected node past the next or previous one: swap arguments, list items, statements |
alt-b alt-e | The start or end of the node around it |
space s | Jump to a function or type in the file |
In Vim’s style the same objects are if af, ia aa and ic ac, as in
daf or cia, and the next/last, indent and number objects are in(
il(, ii ai and id ad, as in cin( or dii.
Folding
| Keys | |
|---|---|
tab or z a | Fold the block the cursor is in under its first line, or unfold it |
shift-tab | Unfold everything when anything is folded, or else fold every outermost block |
z C z o | Fold it, or unfold the folds the cursor is in (z c in the Vim style) |
z R | Unfold everything |
A block is the smallest function, body, table or similar around the cursor’s line, from the language’s grammar. Without a grammar, it’s the lines indented under the nearest line indented less. In Markdown it’s the innermost fenced code block, list item with lines under it (a todo and its subtasks) or section under a heading.
Vim’s style folds with tab, z a, z o, z R and z c (no z C or
shift-tab), plus z M to fold every outermost block, z f + a motion to
fold those lines, z j z k for the next or previous fold, and z d z E
to unfold.
:style vim and :style vscode switch styles; Editing
styles explains each.
Prose: m i p, m i s and m i h select a paragraph, sentence or
Markdown section (m a ... includes the space around it), and ] p [ p,
] s [ s move between them.
Searching
| Keys | |
|---|---|
/ ? | Search forward or back as you type |
n N | Next and previous match |
* | Search for the selected text, exactly as written; a whole word only matches whole words |
alt-* | The same, also inside longer words |
space / | Search the whole project as you type |
space L | List the lines of this buffer that match, as you type (search-buffer) |
Patterns are regexes. The search-case option sets how searches mind
case: "smart" (the default) ignores case unless what you type has a
capital letter; "ignore" and "match" always do one or the other. It
covers searching a file, the project search, :g and the pickers’ fuzzy
matching. A few searches have their own option and default; "default"
hands them back to search-case:
| Option | Default | |
|---|---|---|
notes-search-case | "ignore" | Searching notes (space n /) |
substitute-search-case | "match" | :s, as in Vim; its i and I flags still say otherwise for one run |
shell-filter-search-case | "ignore" | / on a shell block’s output |
local option = require("@greed").option
option.set("search-case", "ignore") -- every search ignores case...
option.set("substitute-search-case", "default") -- ...:s too
In the project search, enter opens a match and ctrl-e puts the results
in a panel a third of the screen wide: a multibuffer, each matching line
under its file’s name and beside its line number. Edit those lines with
the usual keys (s to select the matches, then c to change them all)
and the files change as you type; :w saves them, enter goes to the
line and q closes the panel. A file that changed on disk since the
search is left alone and reported. :grep PATTERN fills the panel
directly.
space L is the same search in the buffer you’re in: every matching line
in a list with a preview, where / only jumps from match to match. It
searches the text as it is, unsaved changes included, and works in
buffers without a file too. ctrl-e puts a file’s matches in the panel,
the same way.
Your notes, mail and chat at once
space n s (:search-everywhere) searches what’s yours wherever it’s
kept: your notes and todos, your mail and your chat messages, newest
first, as you type. It takes the same query language as each of them, and
in:mail, in:chat or in:notes picks some. Like this:
lunch from:bea in:chat in:mail
invoice date:2w..
Any other in: goes on to the sources (a room in chat, a folder in mail).
Project files and shell history stay out, they have searches of their own,
and each app’s own search box still searches only that app.
What mentions a ticket, an MR or a commit
ref: finds what mentions something that lives elsewhere: a Jira ticket,
a GitLab or GitHub issue or merge request, a commit, any link. It works in
every search, so in space n s it pulls the chat thread, the mail and the
note about one ticket together. Like this:
ref:PLAT-1234
ref:api!42 OR ref:api#7
ref:"grafana.example.com/d/abc"
Links say what they are: …/browse/PLAT-1234 is PLAT-1234,
…/team/api/-/merge_requests/42 is team/api!42 and api!42 (# for
issues), a commit link its hash, by its first 7 too, and any link its
address without https://. Once a link has shown that PLAT is a Jira
project or team/api a repository, a bare PLAT-99 or api#3 counts
as well, from then on. A bare key nothing linked stays a word, so
UTF-8 isn’t a ticket. Bare commit hashes aren’t recognized yet, only
commit links.
On anything that mentions one or is one (a message, a mail, a link, a
commit in git log), space . has mentioned-elsewhere, which opens
space n s with those references. Agents use ref: in
search_everywhere the same way.
Files and buffers
| Keys | |
|---|---|
space f | Find a file in the project; in your home folder, not under Library, Music, Movies, Pictures, Applications or Public |
space F | Find a file under the folder Greed was started in |
space ' | Open the last picker again |
space . | What you can do with what’s under the cursor (a file, link, symbol, problem, change or the selection), to pick one; alt-. in the vscode style |
space b | Switch to an open file |
space space | Switch to anything: files, shells, terminals and other buffers, and your other sessions and the agents in them on every machine you reach, each saying what it is. @shell (or @sh) keeps one kind, @modified those with unsaved changes, @shown those in a pane, @agent or @session those, @waiting the agents waiting for you and a machine’s name (@eris, @here) what’s there; the preview shows a shell or terminal at its end. enter goes there, ctrl-a lists what can be done to it (answer or stop an agent where it runs), and for a buffer ctrl-v opens it beside, ctrl-s below and ctrl-f in a float |
space j | Pick a place from the jumplist |
space y space p space R | Copy, paste and replace, as in Helix (copies always go to the clipboard here) |
space e | File tree in a side panel |
space - | This file’s folder as text to edit: rename, make, move and delete files (see the file tree, below) |
:w :w PATH | Save, or save as; an untitled buffer asks where to save it. Into a folder that isn’t there it refuses; :w! makes the folder and saves |
:wa (:write-all) | Save every file with unsaved changes; :wa! makes missing folders too |
:e PATH | Open a file |
ctrl-s | Save, in every style |
:b NAME | Switch to the open file whose path is NAME or has it in it; :b# (or ctrl-^ in normal mode) goes back to the one before |
:ls (:buffers) | Pick an open file, like space b |
:bn :bp | Next and previous open file |
:bc (:bd) | Close the file; the one you were in before takes its place. :bc! closes it with unsaved changes |
:bco | Close every other file |
:close | Close the pane (the file stays open), like alt-p x; :only closes the others |
:sp :vs :new :vnew :tabnew | Split the pane, or open a new pane or tab, as in Vim |
:reload (:rl), :rla | Load the file again from disk, or every open file |
:noh | Take away search highlights |
:set NAME VALUE | Set an option. Yes-or-no ones also take Vim’s :set NAME, :set noNAME and :set NAME!, :set NAME? (or :get NAME) shows one, and :set nu, nonu, rnu and nornu show and hide line numbers. Vim’s tw, ic and scs work too. :toggle NAME flips one, as in Helix. A name that isn’t an option gets the names like it |
:stalls | The times plugin code held the editor up, with the plugin and what it was doing |
:errors | Errors from plugin code that nothing caught, newest first: the plugin, what it was doing, the message and where in its code it failed |
:profile | Start counting where the editor’s time goes; again, stop and show it by plugin and what it did |
:debug TOPICS | Turn debug topics on (:debug keys frames) or off (:debug -keys, :debug off); alone, says which are on. See Debugging |
:debug-log | What the debug topics on have said, in a pane below that follows new lines |
:secret-set NAME | Keep a secret, like an API key, in the system keyring (or Greed’s own secrets file where it can’t be reached); what you type shows as dots |
:login PROVIDER, :logout PROVIDER | Sign in to a model provider: with an account for plans that come with one, like Berget Code or Mistral’s Vibe, or else with its API key (see Models) |
Closing a terminal’s buffer ends its program.
Saving writes a new copy beside the file and moves it into place, so a
crash or a full disk never leaves a file half written. The file keeps its
permissions, and saving through a symlink writes the file it points to. A
file that isn’t UTF-8 opens read-only, with unreadable bytes shown as �;
:w refuses to write over it, since that would replace those bytes, and
:w PATH saves what you see to another file.
greed bench [FILE] measures how quickly keys show. It starts a session
with your plugins and config on the file (a large generated Rust file
without one), types and moves around, and prints per kind of key the time
from leaving the client to the frame showing it, the slowest named, and
where the time went (as :profile shows it). It also types into a
terminal, timing each character until its echo shows. --draw also draws
each frame in your terminal, as greed does, and reports how long that
took, how many bytes went out, and how long the terminal took to take
them in.
greed shot [FILE] saves the editor as the window would show it, with your
plugins and config, as a picture, for a bug report or to show a setup:
greed shot --keys ":" --type "board ops" --keys enter --size 1280x800 --out ops.png
Steps run in order: --keys "space e", --type TEXT, --run COMMAND,
--wait SECONDS and --wait-for TEXT (until the screen shows it). Then
--size 1280x800 and --out PATH (default greed-shot.png). --run
takes a command’s name alone; for one with arguments, type it at : as
above. It needs no window, but a GPU or software Vulkan to draw with.
greed --record SCRIPT [FILE] records the editor the same way, every frame
a picture, for a video or screenshots. One step a line, # starts a
comment:
size 1280 800 the pictures' size, before any step
scale 2 pixels per point, for sharper pictures
fps 30 frames a second
typing 0.04 seconds between the keys `type` presses
output media/shell where the frames and screenshots go (beside the script)
show-keys show the keys each `keys` step presses, for a moment
hide stop keeping frames, while setting things up
show keep them again
caption Selections a line over the screen until the next; `caption` alone takes it away
keys space f press keys, named as in keymaps
type kubectl get pods type text, a key at a time
run shell run a command
wait 1.5 let seconds pass
wait-for Running wait until the screen shows the text (10 seconds at most)
shot pods save the screen as pods.png
The frames go in frames under the output folder, numbered, to make a
video of with ffmpeg: ffmpeg -framerate 30 -i frames/%05d.png -pix_fmt yuv420p demo.mp4.
In the file tree:
| Keys | |
|---|---|
enter l, a click | Open a file or fold a folder |
h | Fold the folder you’re in |
a | Make a file in the folder under the cursor (end the name with / for a folder) |
R | Rename or move what’s under the cursor, taking files you have open along |
d | Delete it, once you press y |
e | Show the folder under the cursor as a buffer to edit (below) |
r | Read the disk again |
q | Close the tree |
Without the tree, :file-rename NAME renames the file you’re in (a path
moves it, from the project’s root), and :file-delete deletes it once you
press y. :set tree-icons nerd shows an icon by each name (see
Icons). Deleting moves things to the trash where there is one on
the same disk (~/.Trash on macOS, ~/.local/share/Trash elsewhere), and
deletes them for good otherwise; :set trash false always deletes.
space - (or :folder) shows the folder of the file you’re in as text, a
line per file and folder, to change many at once with the keys you edit
with: Helix’s s and c rename every match, say. Edit a name to rename
it; add a line to make a file, ending it in / for a folder (a/b.txt
makes the folder too); delete a line to delete it. Cut a line in one
folder’s buffer and paste it in another’s to move the file, or paste it
while it’s still in the first to copy it. :w lists what it will do and
does it once you press y, for every folder buffer at once, and
:folder-undo takes it all back. In a folder’s buffer, enter opens the
file or folder on the line and - goes up; opening a folder from the
file picker or :open shows it this way too.
When a file changes on disk, from another program or an agent, its buffer
loads the change as an edit you can undo with u. A buffer with unsaved
changes is left alone and Greed tells you; :reload loads the file into it
anyway. :set auto-reload false turns this off.
:set auto-save true saves a file a second after you stop editing it, so
a burst of typing is one save; :set auto-save-delay 3000 waits three
seconds. It saves quietly and skips formatting, as Helix does: formatting
while you pause would change the line you’re typing, like a trailing
space gone just before your next word. To keep it, in your init.luau:
require("@greed").option.set("auto-save", true).
Icons
The file tree’s icons and the status line’s rounded ends come from
Nerd Fonts. The window (greed --gui) has
them built in, whatever font you draw in, even when another installed font
claims the same characters. A terminal shows them only if its font has
them: install a Nerd Font, or one of its icon-only “Symbols” fonts, and
set your terminal to use it. Without one you see boxes.
In the window, emoji come from your system’s emoji font; one it can’t draw in color, like the newest Noto Color Emoji, is passed over for another, or the plain Noto Emoji.
Two options use them. By default tree-icons is "none", and the rounded
ends show only once statusline-pills is on (see The status
line).
local option = require("@greed").option
option.set("tree-icons", "nerd") -- "none" for no icons
option.set("statusline-caps", "round") -- "none" for square ends
Setup turns icons on when run in the window, or when you say the terminal
shows them. The window and terminals share one config, so if you set
Greed up in the window and later use a terminal without a Nerd Font, set
both options back to "none".
Debugging
Debug topics log what happens inside, for keys going missing or a pause;
:debug-log shows the log as it comes. Turn a topic on, do the thing
again, and read the log:
| Topic | What it says |
|---|---|
keys | Each key from each client, what it ran (or that it isn’t bound), and how long it waited behind a command at work |
runs | Every run of plugin code: the plugin, what it ran, how long it took |
frames | Each frame built for a client, how long that took, and whether all of it was sent or what changed |
rpc | Messages to and from language servers and other JSON-RPC programs |
jobs | Programs plugins ran, how long they took and how they ended |
client | The terminal’s or window’s side: keys and input method events as the system gave them, focus, and how long drawing each frame took |
plugins | What plugins say with greed.debug.log; plugin:NAME for one |
| Command | |
|---|---|
:debug keys client | Turn two topics on |
:debug -client | Turn one off |
:debug off, :debug all | Turn all off, or all on |
greed.debug.switch("keys frames") | In init.luau, to catch what happens at start |
GREED_DEBUG=keys,frames greed | The same from the shell; a session started in the background gets it too |
greed ctl debug_log | Read the lines from an agent or script (set=keys turns topics on, after=ID reads only newer lines) |
A topic that’s off costs next to nothing, so they stay in release builds; one that’s on keeps its last 10 000 lines in memory.
Language servers
Greed knows some 340 languages (files, comments, indentation, servers),
most from Helix’s list, and starts a language
server when a file needs one and it’s installed. :health shows each
language’s server, whether it was found, and the servers running. Without
a server nothing complains until you ask for something only a server can
answer, like g d; then it says which program to install.
Each project gets its own servers, so two projects (or two jj workspaces
of one) are checked separately. A server runs in the topmost folder of the
project that has one of the language’s root files (Cargo.toml for Rust,
package.json for TypeScript), so one server covers a whole Cargo or npm
workspace; without one, it runs in the project’s root. A crashed server
starts again, up to three times in a row; :lsp-restart restarts this
file’s server (:lsp-restart all every one).
When a server won’t come up, the status line says so: marksman failed
when it kept dying, marksman not answering when it’s been starting for
30 seconds. :health shows the last lines it printed, which usually say
why, like a missing runtime. :debug rpc and :debug-log show what goes
back and forth with it.
Servers that support it get
only what changed with each edit, and those that ask hear when a file is
saved: that’s when rust-analyzer runs cargo check and its compiler
warnings come in.
A server’s own settings go on its language, named as its documentation
names them: settings for those it asks for as it runs, under the
section it asks for (often its own name), and init_options for what
it’s started with. Which one a server reads is up to the server, and its
documentation says.
rust-analyzer only takes what it’s started with, so its settings go in
init_options, without the rust-analyzer around them. Like this, so
project symbols (space S) find functions too, not only types:
require("@languages").set("rust", {
init_options = { workspace = { symbol = { search = { kind = "all_symbols" } } } },
})
A running server keeps the settings it started with; :lsp-restart gives
it the new ones.
Several servers for one file
A language can have servers that run beside its main one, like a linter
beside the TypeScript server. JavaScript and TypeScript come with eslint
and Biome, CSS with Stylelint, and Markdown with harper’s grammar checks
beside marksman. Each only starts in a project set up for it (an
eslint.config.js, a biome.json) and when it’s installed; :health
lists them, and the status line names the ones running, like
typescript-language-server · eslint.
Like this, to add one of your own:
require("@languages").set("python", {
servers = {
{ "basedpyright-langserver", "--stdio" },
{ name = "ruff", command = { "ruff", "server" }, when = { "ruff.toml", "pyproject.toml" } },
},
})
Entries without a name are the main server’s commands, tried in order as
before. One with a name runs beside it, in the nearest folder that has
one of its when files (everywhere, without when). settings,
init_options and reads_only go on it, as on a language. A server that
wants that folder in its settings rather than only from the start, as
eslint’s does, gets it with folder_setting = "workspaceFolder", the
name of the setting it reads.
Problems, completions and code actions come from all of them together.
Hover, going to a definition, references, rename, signature help and
formatting go to the first that does it: the main one, then the others in
order. To change who does what, only and except take the features
hover, definition, references, rename, code-action,
completion, signature-help, format and symbols:
{ name = "biome", command = { "biome", "lsp-proxy" }, when = { "biome.json" }, only = { "format", "code-action" } }
A language’s formatter program, when installed, still formats before any
server does.
| Keys | |
|---|---|
space k | What’s under the cursor, with any problems there, drawn as Markdown: code in its language’s colors, links to follow |
g d | Go to the definition |
g D g y g i | Go to the declaration, the type’s definition, an implementation |
g r | Pick a place it’s used, with a preview |
space H | Select every place in this file it’s used (Helix’s space h, which is help here) |
space S | Pick a symbol anywhere in the project: what the server lists first shows as it opens, and what you type asks it again (rust-analyzer lists only types unless the query has a #) |
:rename | Rename it everywhere it’s used (space r; also g r n in the Vim style, f2 in the vscode style) |
space a | Pick a fix or refactor for the cursor or selection, or what a plugin offers there, like linking a note the line mentions |
space d | Pick a problem in this file |
space D | Pick a problem in any file the server checked, open or not |
] d [ d | Next and previous problem; ] D [ D the last and first |
:pick-workspace-symbol function lists only functions and methods, and
type, module, constant and variable work the same way; it asks
rust-analyzer for every kind, so no # is needed. A key for it is a
command of your own, here on space V, which is free:
local greed = require("@greed")
greed.command({ name = "pick-functions", run = function()
greed.run("pick-workspace-symbol", { args = { "function" } })
end })
greed.keymap.bind({ layer = "leader" }, { V = "pick-functions" })
Problems are underlined, and their lines get a sign and a colored line
number. Each line’s worst problem also shows after the line’s end; :set diagnostic-messages false hides those. They move with your edits until
the server checks the file again. The signs are E, W, I and H;
require("@lsp").signs.error = "●" changes one (warning, info and
hint for the others), from the server’s next check.
In the g r and space D lists, ctrl-e puts the places in a panel like
the project search’s, to edit the same way: each reference with a line
around it, or each problem’s line with its message beside the file name
(two on one line get a line each; one too long for the panel ends in …).
A rename or code action that changes other files opens them in the
background, unsaved, so you can look the change over (space b) and undo
it before saving.
Completions show in a menu at the cursor once typing pauses after a letter,
a . or a /. The menu narrows as you type: what starts with what you
typed first, then what holds it, then looser matches. What the language
server offers comes first, then words from your open files once you’ve
typed two letters, so a file with no server still completes names you’ve
used. A path you’re typing, starting ./, ../, ~/ or /, completes
from its folder instead (from the file’s folder for ./), and a / after
a folder lists what’s in it.
| Keys | |
|---|---|
tab ctrl-n down | Next completion |
shift-tab ctrl-p up | Previous completion |
enter | Put the current one in |
esc | Close the menu (and leave insert mode) |
ctrl-space | Ask for completions now (in the vscode style it opens the leader instead) |
These apply to every completion menu, the shell’s included:
completion-delay(150) is how many milliseconds typing pauses before a menu opens by itself;:set completion-delay 300waits longer, and0opens it only when you ask, withctrl-space(ortabin the shell). Asking always shows it at once.completion-entersays whatenterdoes in a menu:firstputs in the first item,selectedonly an item you moved to withtabor the arrows, and otherwiseenterdoes its usual job, like starting a new line or running a shell’s line.auto, the default, lets each menu say: a language server’s takes the first, the shell’s only one you chose.
In Vim’s style, ctrl-n and ctrl-p in insert mode complete from the
words in open files.
Some completions are snippets, with places to fill in, like a function’s
arguments. Taking one selects its first place: typing replaces what’s
there, tab goes to the next place and shift-tab back, and a place used
twice fills in both at once. A place with choices, ${1|let,const|},
starts with the first and offers the others in the completion menu. The
snippet ends at its last place, or when you leave insert mode.
Snippets use VS Code’s format, so VS Code snippet files and sets like
friendly-snippets work as they are: choices, variables and transforms
included. Your own go in one file per
language in the snippets folder of your config, like
~/.config/greed/snippets/rust.json, and a project’s in
.greed/snippets/. all.json is for every language, and a
.code-snippets file may give each snippet a scope, like "rust,go".
{
"test": {
"prefix": "test",
"body": ["#[test]", "fn ${1:name}() {", "\t$0", "}"],
"description": "A test function"
}
}
A snippet comes up in the completion menu as you type its prefix, after
what the language server offers. :snippet picks one by name, and
:snippets-edit opens the file for the language you’re in, making it if
it isn’t there; saving it takes effect at once. In a body, \t is a level
of the file’s indent, and $TM_FILENAME, $CURRENT_DATE and VS Code’s
other variables work, with VS Code’s transforms: in user_profile.rs,
${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/} is UserProfile.
Typing ( or , in a call shows the function’s parameters above the
cursor, the one you’re on picked out, until the call closes or you leave
insert mode. To ask for it with a key, bind signature-help in insert
mode:
greed.keymap.bind({ role = "typing" }, { ["ctrl-k"] = "signature-help" })
Version control
In a jj or git repository, lines added (+), changed (~) and removed
(-) get a sign beside them. With jj that’s against the working copy’s
parent, so the signs show what your current change does. With git it’s
against what’s staged, so a change loses its sign once you stage it.
| Keys | |
|---|---|
] g [ g | Next and previous change; ] G [ G the last and first |
space g r | Put the change under the cursor back the way it was |
space g a | Stage the change under the cursor (git) |
space g b | Who last changed this line, and when |
space g w | Why the selected lines are as they are: each change that made them, with its description and diff |
space g g | Pick a file changed since the last commit |
space g s (:changes) | Every change in the project, in one buffer |
space g S (:staged) | What’s staged, to unstage hunks and commit (git) |
space g l (:change-stack) | The change stack: describe, split, squash, move and abandon changes |
:set vcs-signs false hides the signs.
space g s shows each change in every file under the file’s name, with a
couple of lines around it: added lines in green, removed ones in red where
they were. With git it shows what’s not staged yet. It’s a multibuffer like
the project search’s results: edit the changes and :w saves the files,
space g r on a change puts it back, space g a stages that change, and
enter goes to it in its file. New files show whole; deleted ones are left
out.
space g S shows what’s staged as a diff: u on a hunk unstages it, c
commits with a message you type, r reads it again and q closes it.
jj has no staging area; split a change in the change stack instead.
space g l lists your changes with jj, newest first: from the working
copy (@) down to the last immutable change (◆), with their bookmarks
and descriptions. On the change under the cursor:
| Keys | |
|---|---|
enter | Show its diff; q goes back |
d | Describe it |
n | Start a new change on top of it |
e | Make it the working copy, to edit it |
s | Squash it into its parent, keeping the parent’s description |
S | Split it: pick the hunks for a new change before it |
a | Abandon it, after asking |
alt-k alt-j | Move it up or down the stack |
u | Undo the last jj operation |
r | Read the stack again |
q | Close it |
? | A menu of these keys |
In a git repository it lists the last 30 commits, and enter shows one.
Operations
An operation is a piece of work across files, kept as one: a rename an agent did in 14 files, a plugin’s refactor, the changes you accepted from a proposal. Its edits in every file undo together, and you can review it in one buffer.
| Keys | What it does |
|---|---|
space u o (:operations) | Pick a recent operation to review |
space u u (:operation-undo) | Undo the latest operation, in every file at once |
space u c (:operation-commit) | Save the latest operation’s files and commit only them, named after it |
The review is a multibuffer of the operation’s changes, with the programs
it ran (a test run, a formatter) and how they exited at the top. Edit it
like any multibuffer, space g r puts a change back, and space u u in it
undoes that operation.
If you’ve edited its files since, undo keeps your edits: it puts back the operation’s changes you haven’t touched, leaves the ones you have, and says how many it left. Operations are kept across restarts (in the cache folder), so yesterday’s agent work can still be reviewed and undone.
space u c saves the operation’s files and commits only them (a jj
change, or a git commit) with the operation’s name as the message; your
other changes stay where they were. In a review it commits the operation
shown.
Every edit also records who made it (you, a plugin, an agent, or a change
on disk) and the command it came from. Agents can ask with the
history_recent tool, and plugins with buffer:history().
Models
Features that use a language model ask for a role, and you choose which model plays it. Out of the box:
| Role | Model |
|---|---|
fast | Claude Haiku 4.5, at Anthropic |
reasoning | Claude Opus 5.5, at Anthropic |
local | Llama 3.2, on Ollama on this machine |
The model question in :setup moves the roles to another provider at
once (OpenAI, Berget, Mistral or Ollama, each with models it suggests), and
in :models any role can use any provider’s model.
Other roles fall back to these until you set them:
| Role | Used for | Until set |
|---|---|---|
agent | Greed’s own agent | reasoning |
review | Reviewing code an agent wants to run | reasoning |
compact | Compacting a long conversation of Greed’s agent | agent |
decision | Auto mode: whether an agent may run a command it can’t tell is safe | fast |
A small model made for yes-or-no answers, like the decision models Berget
offers, suits decision (see Auto mode).
:models shows every role, its model and whether its provider’s key is
found, and lets you change them:
| Key | |
|---|---|
enter | Pick the provider and model for the role under the cursor, from the models the provider lists; asks for the key if it needs one |
e | Pick how hard the role’s model thinks before it answers: none, low, medium, high, or unset |
k | Set the API key of the role’s provider: it goes in the system keyring, or Greed’s secrets file where it can’t be reached |
l | Sign in to the role’s provider, for those with an account instead of a key, like Berget or Mistral (with Vibe) |
q | Close |
The model picker lists what the provider offers (for Ollama, the models it
has pulled), the role’s current or the provider’s suggested model first;
type to narrow it down. enter on a name that matches nothing takes it as
typed, and “type a name…” asks for one. When there’s no list, say without
a key yet or with the server down, Greed says why and asks for the name.
Lists are kept for ten minutes.
What you pick is kept in Greed’s data folder. Your init.luau is read
after it, so a role set there wins, and :models says “(set in your
config)” beside it. Instead of a key in :models, set the variable it
names, like ANTHROPIC_API_KEY, or run :secret-set anthropic. Anything
that needs a model and has no key says which variable sets it, and that
:models adds one.
Keys and sign-ins go in the system keyring through secret-tool on Linux
(security on macOS). When Greed can’t reach it (secret-tool isn’t
installed, or there’s no D-Bus session), a key kept there looks missing,
and the message says the keyring couldn’t be reached and why. New keys and
sign-ins then go to Greed’s own secrets file, and Greed says so; keys there
are found whether the keyring answers or not.
:usage shows the tokens the models were sent and wrote, as the providers
reported them for Greed’s agent and the features with tools: today, by
model, and each day of the last week. Tokens read from the provider’s cache
show apart, as “(52.1k cached)”; they cost a fraction of the rest, so a low
share means caching isn’t working. Under each model it shows how many of
Greed’s agent’s edits worked, by the way it made them. It’s kept a file a
day in Greed’s data folder (usage/2026-10-09.json), by hour and model.
Ollama needs no key, but it has to run: ollama serve starts it, and
ollama pull llama3.2 fetches a model. Greed says so when it can’t reach
it or the model isn’t there.
You can also set any of it in your init.luau, with OpenAI, Ollama or any
server that speaks OpenAI’s chat completions API:
local models = require("@models")
models.roles.fast = { provider = "ollama", model = "qwen2.5-coder" }
models.roles.reasoning = { provider = "openai", model = "gpt-5" }
models.providers.work = { kind = "openai", url = "https://llm.example.com/v1", secret = "work" }
models.roles.review = { provider = "work", model = "reviewer-1" }
A role or provider can also say how many tokens its model has room for,
as context = 128000. Greed knows that for well-known models by name and
assumes 32k for others; Greed’s own agent uses it to compact long
conversations (see Agents).
A role’s effort says how hard its model thinks before it answers:
"none", "low", "medium", "high" or "max". Unset, nothing is sent
and the model uses its default. A provider’s effort is the default for
its roles.
models.roles.agent = { provider = "mistral", model = "mistral-large-4", effort = "high" }
models.providers.work = { kind = "openai", url = "https://llm.example.com/v1", effort = "low" }
e in :models picks it and keeps it with the role, whose line shows it.
In Greed’s agent, /effort changes it for one session (see
Agents). How it’s sent:
- Servers with OpenAI’s API get it as
reasoning_effort, up tohigh(maxis sent ashigh). - A provider that takes only some sets
efforts, and the nearest is sent: themistralprovider takesnoneandhigh, solowis sent asnoneandmediumashigh, and:modelssays so (“effort low (sent as none)”). - Some models take their own whoever serves them: GLM 5 always thinks and
takes
low,highandmax, sononeis sent aslowandmediumashigh. - Claude models get it as their effort, with their thinking summarised so
Greed’s agent can show it; models before Claude 4.6, like Haiku 4.5,
think within a budget instead (2k, 8k or 24k tokens,
maxthe same ashigh).
Greed’s agent sends the whole conversation each turn, and providers charge
far less for the part they’ve cached. Some, like Mistral, only cache a
request that names its conversation: cache_key = true on a provider has
Greed’s agent send its session’s id as prompt_cache_key. The mistral
provider has it on. :usage shows how much was cached.
Mistral’s reasoning models work better when they get back what they
thought before each answer: thinking_back = true on a provider sends it
back with what the model said, and the mistral provider has it on. It
takes room in the conversation, so it’s compacted a little sooner.
To see which requests missed the cache, :debug plugin:models logs a line
for each in :debug-log:
- the provider, model and session id, and how many messages it sent;
- a short hash of all of it but the newest message, and what it changed of the session’s last request (nothing, when it’s that one with more on the end);
- the tokens sent, read from the cache and written;
- the time until the first bytes came back, the total time, and tokens a second while it streamed.
A request that starts with all of the last one and still shows little cached was missed by the provider. A long wait for the first bytes is the provider (queueing, or reading a long uncached conversation); a low pace is the model writing slowly, or thinking.
A model’s answer that goes quiet for 90 seconds counts as failed; the
first bytes get three times as long, since a long uncached conversation or
hidden thinking can take minutes. :set models-idle-timeout 180 changes it
for all of them, idle = 180 on a role or provider for its models (a slow
local one, say), and 0 waits for ever. The mistral, ollama,
berget and evroc providers wait ten minutes: they send a tool call whole once the
model has written it, so a long file is a long quiet.
models.providers.ollama.idle = 600
A request that timed out, lost its connection, or was turned away as too
busy (429, 502, 503 or 504) is sent once more after a moment, or as long as
the server’s Retry-After says, up to 30 seconds. It isn’t sent again once
some of the answer was shown, as the second answer would repeat it.
A provider with a secret reads its key with :secret-set NAME, or from
GREED_SECRET_NAME. The built-in providers send their keys only to their
own servers. The first time any other key would go to an address, Greed
asks (y yes, n no) and keeps your answer, so a plugin can’t add a
provider that sends your key somewhere you didn’t choose.
Some plans come with an account instead of a key, like Berget Code.
:login berget shows a link and a code; approve it in a browser on any
device, and the berget provider uses that sign-in from then on, renewing
it as needed. :models says “signed in (Berget Code)”; :logout berget
forgets it, and the provider goes back to its key.
models.roles.agent = { provider = "berget", model = "the model you want" }
With a Le Chat Pro or Team plan, sign in to Mistral with Vibe, as Mistral’s
vibe command does: :login vibe (or :login mistral and pick Vibe)
shows a link; sign in and pick a workspace there, and Mistral makes an API
key for Vibe, kept as your mistral key. Requests with it count against
your plan’s allowance instead of API credits; past that, your plan’s
pay-as-you-go applies, at API prices. :models says “signed in (Vibe)”,
and :logout vibe forgets the key (unless you’ve set a key of your own
since). It’s an ordinary API key with nothing to renew; Mistral’s console
shows it and can revoke it.
For a key you already have, :login mistral and picking an API key keeps
it (or set MISTRAL_API_KEY). Either way, the mistral provider uses
Mistral Large 4 for reasoning and Mistral Small for fast when picked in
:models, and Mistral’s mistral-vibe-cli-latest is the model Vibe itself
uses:
models.roles.agent = { provider = "mistral", model = "mistral-large-4" }
The evroc provider is evroc’s Think models, hosted in the EU. Make a key
with evroc’s CLI, evroc think apikey create greed, and keep it with
:secret-set evroc (or k in :models, or set EVROC_API_KEY). Picked
in :models, it uses GLM-5.3 for reasoning and Qwen3.6-35B-A3B for
fast; alt-M in an agent session lists the rest, like Kimi-K2.6:
models.roles.agent = { provider = "evroc", model = "moonshotai/Kimi-K2.6" }
Mistral also serves Z.ai’s GLM 5.3 as zai-glm-5-3: a million tokens of
room, text only, and it always thinks, at low, high or max (see
efforts above). Its thinking goes back to it each turn like Mistral’s own
models’.
models.roles.agent = { provider = "mistral", model = "zai-glm-5-3", effort = "high" }
| Keys | |
|---|---|
space i e | Explain the selection (or the line) in a panel, as the answer arrives |
space i a | Ask something about the selection |
space i f | Fix the problem the language server reports on this line, as proposed changes to review |
space i c | Draft a description of the changes in progress; a uses it (jj describe, or a git commit of what’s staged) |
Fixes come like an agent’s proposals: space o A or space o R accepts or
rejects the whole fix (] o and space o a go change by change), and what
you accept undoes as one operation. These use the fast role; :set assist-role reasoning asks another.
The context
Pin what a model or an agent should see, and it goes with every question:
| Keys | |
|---|---|
space i p | Pin the selection, or the whole file when nothing is selected; outside a file, what’s under the cursor (a shell row, a block) |
space i i | Show what’s pinned, one item a line with its size in tokens; d drops the items on the lines selected (x d) |
:context-add-problems | Pin this file’s problems from the language server |
:context-add-diff | Pin the changes in progress |
:context-clear | Drop everything |
Anything you can inspect pins too: pin to context is among every
object’s actions (space ., or the inspector), so a pod, a shell block or
a terminal goes with your messages, in its state at the time of each one.
Items are read fresh each time they’re sent: a pinned selection follows the
text as you edit, the diff is the current diff, and a pinned pod is its
row from the newest block that lists it. The assist commands send the
context with each question. The agent pane sends it with a message when it
changed since the last one, so a pinned file goes again only after an
edit; other agents read it with the context_get tool. Each project keeps
its context across restarts, except pinned objects, which belong to the
session.
Formatting
Saving a file formats it; :format formats without saving. Greed uses the
language’s formatter when it’s installed (gofmt, ruff, stylua,
prettier, shfmt, …), otherwise the language server (Rust gets
rustfmt through rust-analyzer). Only what the formatter changed is
replaced, so the cursor stays put. If you type while a slow formatter
runs, its result is left out rather than undoing what you typed.
Auto-save doesn’t format; the next :w does.
-- A different formatter for a language
require("@languages").set("python", { formatter = { "black", "-q", "-" } })
-- No formatting on save
require("@greed").option.set("format-on-save", false)
A formatter gets the text on its input and prints it formatted; {path} in
its command stands for the file’s path.
Markdown
Markdown files show as documents. The file stays plain Markdown.
- Headings show without their hashes, a top-level one twice the size,
and each level in a color of its own (
markdown.heading.1to.6in a theme). **bold**,*italic*,~~struck~~and`code`show without their markers, links as their underlined text.- Fenced code gets a background of its own and keeps its markup: a
# commentthere stays code. - Quotes get a bar,
---a line, list bullets (-,*or+) dots, and tables aligned columns with borders. - Obsidian’s callouts, a quote starting
> [!warning] Mind the step, show their sign and title (or their kind,Warning, without one), the bar in their kind’s colour: note and info, tip, success, question, warning, danger and error, example and quote.
While you type on a line (insert mode) it shows as written; otherwise
markup shows as written once the cursor steps inside it. A field, a box or
a button stays drawn while the cursor is on its first character, so
enter presses it; one step further in (l) opens it to edit with the
usual keys. Table borders open only while typing. :set markup-reveal never keeps markup drawn outside insert mode.
The window draws big headings big and sets text in a proportional font (code and tables stay monospaced). Terminals other than kitty show headings at the normal size.
:set markdown-look false | Turn the look off everywhere |
space m l (alt-V in the vscode style, :markdown-look-toggle) | Toggle it for this file: as written, or as a document while the option is off |
The status line shows markdown · plain while a file shows as written.
Reading view
space m v (alt-v in the vscode style, or :markdown-read) shows the file for
reading: read-only, without line numbers, and with no markup showing
anywhere, even on the cursor’s line. Images on a line of their own show in
place (in the window, and in terminals that show images; elsewhere you see
their description), and links show as their text. esc, q or the same
key again goes back to editing, at the same place.
| Keys | |
|---|---|
j k h l, arrows | Move |
pagedown pageup, ctrl-f ctrl-b, ctrl-d ctrl-u | Page and half page |
/, n, N | Search |
enter or a click on a link | Follow it |
esc, q | Back to editing |
Following a link:
#a-headinggoes to that heading.- Another Markdown file opens in the reading view too, at its heading with
other.md#a-heading. - A web or mail link opens in your browser or mail program (the
link-openeroption says which). - A
file://link opens the file in Greed.
Links of other kinds don’t open, since any file you read could hold them.
Tables
A table is edited as it’s drawn, from normal mode. h and l step over
the pipes and padding, j and k keep to the column you see, and
alt-h and alt-l go a whole cell back or on, row after row (outside a
table they still move between panes). enter on a cell asks for its text;
in a column a formula fills, it asks for the formula. The
rest is on the leader:
| Keys | |
|---|---|
space m t o, space m t O | Add a row below or above |
space m t d | Delete the row |
space m t j, space m t k | Move the row down or up |
space m t c, space m t C | Add a column right or left |
space m t D | Delete the column |
space m t l, space m t h | Move the column right or left |
space m t s, space m t S | Sort the rows by the column, smallest or largest first |
space m t = | Line up the pipes |
space m t e | Edit the cell, as enter does |
Each change writes the table back with its pipes lined up and is one step
to undo. When you type in a table yourself, leaving insert mode lines it up
again and fills out a row you typed short of cells, so its formula columns
show. The keys are in
require("@markdown").table_edit.keys, to rebind like any others.
Choices
A list whose items start with ( ), one of them (x), is a set of
choices. They show as ◯ and ◉ (round buttons in the window), and pressing
one (a click, or enter on it) picks it and unpicks the others. The answer
is the text itself, so it reads the same anywhere:
How do you like to edit?
- (x) Helix: select first, then act
- ( ) Vim: say what, then where
Picking only changes the text. Plugins read the answers and act on them (see Writing plugins), and so can code blocks in the file (below).
Questionnaires
Choices and runnable blocks make a page of questions that acts on the answers and still reads as plain Markdown. HTML comments, which GitHub and the like don’t show, hold the rest:
Which theme? <!-- id=theme -->
```luau output=choices
return require("@theme").list()
```
```luau when=theme
require("@theme").use(answer)
```
Will you use agents? <!-- id=agents -->
- (x) Yes
- ( ) No
<!-- if agents=yes -->
Which language model? <!-- id=provider -->
- ( ) Anthropic
- ( ) Ollama: on this machine <!-- value=ollama -->
<!-- end -->
```luau button="Save"
require("@greed").echo(`theme {answers.theme}, model {answers.provider}`)
```
<!-- id=NAME -->on a question names it. Its answer is the picked option’s value: its text up to the first:(“Ollama”), or a<!-- value=... -->on the option.- A block with
output=choiceswrites the choices it returns (a list, or one per line;(x)in front picks one) under itself, and running it again keeps your pick. In a file you trust, these run as it opens. - A block with
when=NAMEruns each time that question’s answer changes, withanswerset to it. - A block with
button="Label"shows as a button, and runs when pressed. - Every block gets
answers, each named question’s answer (programs get them as JSON inANSWERS, andANSWER), andvalues, all the page’s live values: fields,lets, answers, and named tables as lists of their rows. Programs get those as JSON inVALUES, and each number or text by its name too, so ashblock canecho $bill. For a button whose output stays in the file, a block withbutton="Label"is the way; arun:link’s shows in a float. <!-- if NAME=VALUE -->to<!-- end -->is a part that shows only for that answer (!=for any other), or for any of several, as in<!-- if style=vim,helix -->. Its questions don’t count otherwise. A hidden part leaves itsifline, which says when it shows (▸ shows if trip is abroad); with the cursor on that line the part opens, dimmed, to read and edit without changing the answer.
Blocks that make choices or hear picks are hidden, and buttons show as
buttons: put the cursor there to see their code. They run as any block
does: in a file you haven’t trusted, the first asks whether to. A Luau
block can’t wait, so one that asks for something, like a prompt or a
secret, does it in greed.spawn. Greed’s own setup page, setup.md in
the setup plugin, is a questionnaire like this.
Live values
Formulas in Luau’s syntax work values out as you change the file:
Bill: [840](field:bill) kr, we're [3](field:people) people.
<!-- let tip = bill * 0.1 -->
Tip: {{ fixed(tip) }} kr. Each pays {{ fixed((bill + tip) / people) }} kr.
<!-- id=items -->
| Dish | Price |
|-------|-------|
| Pasta | 240 |
| Wine | 210 |
{{ count(items.dish) }} dishes, {{ sum(items.price) }} kr in all.
{{ formula }}shows what the formula works out to. With the cursor on its line you see the formula, to edit it.[840](field:bill)is a field: its value is the text between the brackets, shown as a box.enteron it, or a click, asks for a new one and writes it in the file, and every value from it follows.space m fmakes the number or word at the cursor (or what’s selected) a field, asking for its name, and on a field renames it.<!-- let name = formula -->names a value for formulas anywhere in the file.- A table with
<!-- id=name -->right above it is a value too:items[1]is its first row,items[1].pricea cell anditems.pricethe column, by the header’s words in lowercase with spaces as_. - A named question’s answer is a value by its name.
A table’s column can be worked out too, row by row, with a formula line right under the table:
<!-- id=costs -->
| Item | Amount | Per year | So far |
|------|-------:|---------:|-------:|
| Rent | 900 | | |
| Food | 350 | | |
<!-- formula: per_year = amount * 12 -->
<!-- formula: so_far = (if prev then prev.so_far else 0) + amount -->
A formula names its row’s cells by their column, prev for the row
above, and anything else in the file. Its column’s cells can stay empty:
they show what it works out, and whatever they say in the file gives way.
Formulas go in order, so a later one can use an earlier one’s column, and
the table’s value has them too (sum(costs.per_year)).
A chart line under a table, after any formula lines, draws it:
<!-- chart: bar per_year -->
What follows chart: is what follows | chart in the shell (bar,
line, area, scatter, a column to chart, --height, …), and its
columns are named as formulas name them. The chart follows the table as
you change it and the values it uses; on GitHub only the table shows.
A command button runs a command in the project’s shell and shows its output
in a float as it comes (esc closes it, ctrl-c stops it). It runs with
sh whatever shell you use, so it works the same for anyone you share the
file with:
Crate: [greed-core](field:crate)
[Run its tests](run:cargo test -p {{ crate }})
A {{ formula }} in the command goes in as one quoted argument, so a
field can’t add to the command whatever it holds. For output that stays in
the file under the button, use a code block with a button; it gets the
page’s values as variables:
```sh button="Run its tests"
cargo test -p "$crate"
```
The label hides the command, so the first press shows it and asks: y
runs it this time, a always. A command changed since (in the file, by a
pull or an agent) asks again.
Formulas are expressions only: arithmetic, comparisons, and/or/not,
.. to join text, if a then b else c, and functions: sum, avg,
count, min, max, round(x, digits), floor, ceil, abs,
fixed(x, digits) (a number with that many decimals, 2 unless said),
upper, lower and empty, plus any a plugin adds. They can’t run
anything or loop, so they work in any file without asking, and one that
goes wrong shows why where its value would be. On GitHub and the like, a
field shows as a link and a value as its formula.
Data blocks
A fenced block named after a data source shows the table it reads, live, under it:
City: [oslo](field:city)
```sqlite db=shop.db rows=10 id=customers
SELECT name, total FROM customers WHERE city = @city ORDER BY total DESC
```
<!-- chart: bar total -->
The best customer: {{ customers[1].name }}.
Its first line says what it reads and how it went (▦ sqlite · shop.db · 10 rows), and the query folds under it: with the cursor on that line it shows,
dimmed, to edit. The table is read again a moment after what it asks
changes, and when the file it reads changes. Reading runs in the
background, so typing never waits for it.
| Source | Reads |
|---|---|
csv | a CSV file with a header (path=sales.csv, from the document’s folder), or the block’s own lines |
sqlite | a query over the SQLite database db=FILE, by the sqlite3 program |
psql | a query over PostgreSQL by psql, db= a connection (else psql’s own settings) |
@namein a query is the document’s value of that name (a field, alet, an answer), passed to the database as a parameter, never pasted into the query: a field holding'; drop table customers; --is only text. Change the field and the table is read again.rows=Nshows N rows at a time;space m nandspace m pturn the page.- The table is drawn, so the cursor goes past it.
enteron it, orspace m o, opens it in a float as text, a page at a time, to search and copy;enteron a row shows the whole record andqcloses it. id=NAMEmakes the table a value for formulas, as a named Markdown table is (customers[1].name,sum(customers.total)), and a<!-- chart: ... -->line under the block charts it.sqliteandpsqlopen the database read-only unless the block sayswrite=true. They run programs, so a block waits, as a code block does, until you let it:enteron its first line asks,alets the file’s data blocks run from then on.enterthere later reads it again.- The programs are
sqlite3andpsqlunless:set data-sqlite3or:set data-psqlnames others.
In the shell, data SOURCE ... reads the same sources into a block’s table, so a
board’s cards can show them too (see the shell’s “Databases and files”).
Plugins add sources with require("@core").data.source({ name, read, ... });
see core.data for what a source gives.
Runnable code blocks
A fenced block in a language Greed can run runs when you ask, and its
output is saved in a result block right under it, so it shows wherever
the file is read and a diff shows what changed. Running a block again
replaces its result.
```sh id=files
ls *.md
```
```result
README.md
using.md
```
| Keys | |
|---|---|
space m r, or enter on the fence once it shows ▶ run | Run the block under the cursor |
space m R | Run every block in the file, in order, asking before each one not marked safe=true |
space m c | Clear the block’s result (:blocks-results-clear clears them all) |
space m s | Stop the block running under the cursor |
space m k | Run the blocks marked safe=true again, to see what changed |
↳ shell on the fence (:block-shell) | Put the block at the project shell’s prompt, in a float, to look over and run from there |
Shell blocks go to the prompt as they are. A python, node or ruby
block is written to a temporary file, and the prompt gets the line that
runs it, like python3 /tmp/greed-blocks/3-12.py.
Blocks run as shell, sh, bash, zsh, fish, python, node,
ruby, luau and http:
- A
shellblock runs in the Greed shell, a line at a time, stopping at one that fails, so table stages and| chartwork as they do there. A chart shows in colour, and as an image in the window and terminals that draw one. Withevery=SECONDSits line runs again that often and the result keeps up, without filling undo, untilspace m sstops it; the fence shows● livemeanwhile. - A program gets the code to run, and prints the result. When it fails,
the result block says how it exited (
result exit=1). - A
luaublock runs in the editor, with the whole API: its result is what it prints and what it returns. A one-line expression like6 * 7is its own result. - An
httpblock is a request: the method and URL on its first line (or a URL alone, for GET), then header lines, then after a blank line the body. The result is the status and the body;headers=trueadds the response’s headers.
Options go after the language:
id=NAMEnames a block, andinput=NAMEgives another block that block’s result: on stdin for a program, asinputin Luau, and into the first line of ashellblock, sowhere STATUS != Runningalone works on it. The named block runs first if it has no result yet, so a page of blocks works like a small pipeline; unless it’ssafe=true, Greed asks first (below). Withrerun=trueon the block taking the input, its input runs again every time, so it never reads a stale result.safe=truesays running the block changes nothing, likelsorkubectl get pods, so it may run without you pressing it (below).drift-ignore=REGEXleaves out what differs every run when showing what changed since the last run (below).dir=PATHruns a program in another folder than the file’s.timeout=SECONDSstops it after that long.every=SECONDS, on ashellblock, keeps it live (above).run=terminaltypes the block into a terminal and runs it there (▶ run in terminal), opening a floating one when there’s none, and keeps no result: for showing commands to people, as in a talk. Withterminal=NAMEit goes to the terminal block withid=NAMEinstead (below).stream=falseshows its output only once it’s done (below).
A terminal block is a terminal of its own, right under the block, with
your shell in it. Its lines are commands to type, one each time you press
it, so a talk can go through them a step at a time:
```terminal rows=8
ls
cargo test
```
enter on the fence starts it, then types the next line and runs it; the
button says which. Once they’re all typed, or for an empty block, enter
types into it yourself, and ctrl-\ stops. ⤓ keep saves what it shows
as the block’s result, which the file keeps; nothing else of it is saved,
and it stops when the file closes. ■ stop (space m s) ends it, leaving
its last screen; ✕ close (space m s again) takes that away.
It runs the shell terminals do (terminal-shell, or your $SHELL);
shell=fish or shell="zsh -l" picks another for that block.
rows=N sets its height, 12 by default. It’s as wide as the pane and
follows it as that changes; cols=N gives it a width of its own, as far
as the pane has room. In a narrower pane it fits the pane and says how
many of its columns do.
A block runs when you run it. When it would run without you pressing it,
as the input of the block you ran or in space m R, it runs right away
only with safe=true. Any other asks first, showing its first line, so a
kubectl delete or a migration never runs again by accident:
- An input that has a result is read as it is, without asking, unless
the block taking it says
rerun=true. Once it has run, by you or after ay, later runs just read its result. - An input with no result asks:
yruns it,nstops, saying it isn’t marked safe. Withrerun=trueit asks to run again:yruns it,nuses its last result. - An agent’s run, or a pick’s, never asks: an input that isn’t safe and
has no result stops it, saying so, and with
rerun=trueits last result is used. space m Rasks before each block that isn’t safe:yruns it,nskips it,aruns it and the rest without asking,escstops.
Like this:
```sh id=pods safe=true
kubectl get pods -n shop
```
```sh input=pods rerun=true
grep -c Running
```
Choices made as a file opens (output=choices), a pick’s when= blocks,
buttons and every= run as they say they do, since that’s what they’re
written for.
When a block’s output comes out different from the result it had, the
result shows how: ≠ changed since the last run after the fence, a +
by each new line, and the lines that went struck out where they were.
It stays until the block runs again or you edit its result. Handy on a
runbook or a setup page you go through again later: the step that went
differently stands out.
space m k checks a whole file that way. It runs only the blocks marked
safe=true, and says how many it checked, how many changed, and how many
it left alone because they aren’t safe. A block whose input isn’t safe and
has no result is left alone too.
Output that differs every run, like a timestamp or an id, would always
count as changed. drift-ignore=REGEX leaves out what the regex matches
on each line:
```sh safe=true drift-ignore=[0-9]+[smhd]
kubectl get pods -n shop
```
Here the pods’ ages can change and the block still counts as unchanged; a pod that’s gone, new or not ready does show.
While a block runs, its fence shows ■ running; click that or press
space m s to stop it, along with anything it started, like a server. A
result keeps at most blocks-max-lines lines of output (1000).
Output shows under the block as it comes, in a ```result running
block with the latest lines, and becomes the result once the block is
done: one change for u to take back, and auto-save waits for it. A line
a program draws again over itself, like a progress bar, shows as it ended
up. stream=false on a block, or :set blocks-stream false, shows the
result only once it’s done.
Nothing runs when a file opens. The first time you run a block in a file, Greed asks whether to:
yruns it this time;aalways trusts that file (:blocks-untrusttakes it back).- Trusted files, and files whose front matter says
greed: run, show a▶ runbutton after each block’s fence. Front matter only shows the buttons; running still asks. The status line showsmarkdown · blockswhen they’re on. - Agents can list and run blocks too (
blocks_list,blocks_run), only in files you trust, and only blocks as they were when you last ran them yourself or trusted the file (a, or:blocks-trust). A block an agent changed, in the buffer or on disk, doesn’t run for an agent until you’ve run it, and neither does a block taking its input from one.
Trust covers what a file holds when you trust it. What runs by itself
(choices made as the file opens, a block a pick runs, a board’s cards)
runs only as you last let it run. When the file changes from outside, as
after a git pull or an agent’s edit, a changed block waits until you run
it yourself (space m r), and a changed card on a board shows the command
it would run and waits for enter. What you write or change yourself and
save may run as it is.
Add a language from Luau:
local blocks = require("@blocks")
blocks.runner("lua", blocks.program({ "lua", "-e" }))
Slides
Any Markdown file is a slide deck: a --- line, with a blank line above
it, starts the next slide. :slides (space m P) shows the slide the
cursor is on, over the whole screen, without the status line, so with
the window or terminal full screen there’s only the slide. Like this:
# Runbooks that run
Notes, commands and their output in one file.
---
## A block runs where it is
```sh safe=true
echo "orders today: $((40 + 2))"
```
```speaker
Press r here; the result shows on the slide.
```
The slides are a view of the file itself, so a block runs right there and its result lands on the slide, saved in the file like any other.
| Keys | |
|---|---|
right, space, l, pagedown | The next slide |
left, backspace, h, pageup | The slide before |
home, g / end, G | The first / the last slide |
r | Run the block the cursor is on; on a new slide it starts on the first |
q, esc | Back to the file |
A speaker block at the end of a slide is what you want to say there; it
isn’t shown on the slide. Front matter at the top isn’t a slide either,
and a --- right under a line of text underlines a heading, as Markdown
has it. Headings show big in the window and in kitty.
A picture on a line of its own, , shows on
the slide, made smaller when it doesn’t fit beside the slide’s other
lines, never bigger than it is. That’s in the window and in terminals
that show images; elsewhere its description shows instead.
To present, show the slides on one screen and the notes on another.
:slides-presenter shows the slide with what you need beside it: the
slide number and how long you’ve been going, the slide’s notes, and the
start of the next slide. Run it in a terminal attached to the same
session, then :slides in the window on the projector:
greed --gui talk.md # on the projector: :slides
greed attach # on your laptop's screen: :slides-presenter
Every screen showing the slides is on the same slide: right on any of
them moves them all, so the presenter screen works as the clicker. q
closes one screen, and the others go on. Each screen lays the slide out
for its own size, big in the window and plain in the terminal.
A deck says how its slides look in its front matter, or your config does
for every deck with greed.option.set:
---
slides-center: true
slides-scale: 2
slides-margin: 4
---
| Setting | Default | |
|---|---|---|
slides-center | false | Center each slide across and down: each heading on its own, the rest as one block, so code and lists keep their indents |
slides-scale | 1 | Draw the text that many times bigger (up to 4), in the window and in kitty; a # heading is twice that. fit draws each slide as big as it fits, so a title slide comes out huge and a slide of code stays readable |
slides-margin | 2 | Cells left empty above and left of a slide |
A terminal that can’t draw text bigger shows slides at their usual size,
whatever slides-scale says, centered and with margins all the same; so
does kitty run inside tmux or zellij, which drop what draws it bigger.
On a slide with a block the cursor sits on it, ready for r; on the
others there’s no cursor at all.
Notes
Hoard (greed notes) shows your notes and todos on a home page
for anyone to use; this section is about notes in the editor.
Notes are Markdown files in a folder (~/notes unless you set
notes-folder), so git or Syncthing can carry them between machines and to
your phone. Link one to another with [[name]], or [[name|other words]]
to show other words.
| Keys | |
|---|---|
space n h | Go to Hoard, your notes and today’s things to do, in its own session (started if needed; space B comes back); space n H opens it in a window of its own (Hoard) |
space n d | Today’s note, in daily/ |
space n c | Add a todo to the inbox, from wherever you are: the project’s when it keeps notes, otherwise yours (:notes-capture-mine always yours). It can say when in plain words, like call the bank tomorrow 18:00 or water plants every monday (more) |
space n a | The agenda: open todos from every note, soonest due first |
space n f | Find a note; a name that isn’t one yet makes it |
space n / | Search every note as you type |
space n x | Tick a todo or untick it; a plain line becomes one |
space n t | Jot a thought or an idea down in the inbox, with today’s date: for things that aren’t todos |
space n r | Dismiss the reminders notice (below) |
space k | On a due date or a reminder, say when it is in words (“tomorrow, 18:00, in 25 hours”) |
space n l | Have Greed’s agent connect the inbox (or the note you’re in) to your other notes (below) |
space n k | Link to a heading, a list item or a block in any note, picked from all of them (more) |
space n n | Make a note from a template: pick the kind, then name it (more) |
space n y | Give the note you’re in a template’s fields it doesn’t have yet |
space n j | Pick a job for Greed’s agent on your notes: connect, pull out todos, ask, sum up the week |
g d | Follow the link under the cursor, to the heading or block it names, making the note if it’s new; in Markdown outside your notes, [[name]] is name.md beside the file |
z a | Fold the section under the cursor, or unfold it (any Markdown) |
alt-up alt-down | Move the list item (with the items under it) or section the cursor is in past the one beside it (any Markdown; the vscode style’s keys, move-lines-up and move-lines-down in others) |
space z, space Z | Zoom in to the list item or section the cursor is in, showing only it; zoom out again |
A todo is a list item with a box, - [ ] call the bank, and
due:2026-10-03 anywhere in it gives it a date for the agenda. Notes and
todos are objects too: space h i on one shows its note, due date and
reminders, and space . opens or ticks it, for agents as well. In a note,
links show without their brackets (except while typing on their line) and the
notes linking to it are listed at its end. Other Markdown files, like a
project’s README, look as they always do; :set notes-everywhere true
treats every Markdown file as a note, and :set notes-conceal false shows
the brackets and the markup below as written.
require("@greed").option.set("notes-folder", "~/Documents/notes")
Reminders
Put remind:2026-10-06 18:00 on a todo, or on any line of a note, and
Greed reminds you then. A date alone, remind:2026-10-06, goes off at
09:00 (:set notes-remind-time 08:30 to change it). Times are your
computer’s local time. Ticked todos don’t remind you. A line can have as
many reminders as you like, each going off at its own time:
- [ ] pay the invoice due:2026-10-07 remind:2026-10-06 19:00 remind:2026-10-07 12:00
A time alone, remind:10:30, goes off on the line’s own days: a todo’s
due date, each day a repeating line (every:weekday) comes up, or every
day. Repeats, habits and from:/until: are in
Hoard.
When a reminder comes due:
- A notice opens at the top right and stays until you dismiss it with
space n r. Click a reminder in it to open its note at that line. - Your desktop shows a notification, with
notify-sendon Linux orosascripton macOS, when they’re installed.:set notes-remind-desktop falseturns this off. - In a terminal that isn’t focused, Greed also sends the terminal’s
notification escape and a bell, so the terminal can tell you even over
greed ssh. Terminals that understand it (kitty, WezTerm, Ghostty, iTerm2, foot and others) show a notification of their own. Inside tmux only the bell gets through, and only with tmux’sfocus-eventson. When the terminal andnotify-sendboth show one,:set notes-remind-desktop falseleaves only the terminal’s.
Reminders that came due while Greed wasn’t running show the next time it starts. Greed remembers which ones went off in its cache folder, so each goes off once. When several on one line went off while it wasn’t running, the line shows once. The reminders in your own notes go off in Hoard’s session, which starts with Greed when you have notes, and a project’s in that project’s session, so none goes off twice; the hub tells you of them wherever you are.
The status line says how many todos are due today, like 2 due today, in a
warning color when some are overdue (1 overdue, 2 due today). Click it to
open the agenda.
Agents can set reminders too: ask Greed’s agent to “remind me this evening to call the bank” (see Agents).
Connecting your notes
space n l has Greed’s agent go through your inbox (filled by space n t
and space n c), or the note you’re in, find the notes each item relates
to, link them with [[name]] and add a line of context. Changes to
existing notes come as proposed edits you accept or reject one by one. It
makes new notes for items that belong together and ends with a summary. It
uses the model playing the agent role. space n j has other jobs for it:
pulling the todos out of a note, answering a question from your notes, and
summing up the week (more).
Any agent can work with your notes the same way through the notes tool
group (see Agents); :set agent-tool-groups "plan notes" gives it to every agent from the start. Agents reach only the notes
in your note folders, by name: ../x and other names leading out of them
are refused. Rewriting a note that’s there comes to you as a proposal,
adding a line or a todo goes straight in, and decisions can only be
proposed with decision_propose.
Notes in a project, and other places
A project can keep notes of its own in .greed/notes/ (or wherever
notes-project-folder says, inside the project). Once the folder exists,
its notes are found, searched and linked with yours, their todos are in
the agenda, and capture puts todos in the project’s inbox. Their names
start with project:, like project:plan; a link in a project note goes
to a note beside it first, so [[design]] there means project:design
when there is one. The plan and decisions you share with
agents (see Agents) are notes
there too. Commit the folder to share it, or leave it out of the
repository to keep it yours.
More folders of your own, each with a name for its notes:
require("@notes").add_place("work", "~/work/notes") -- notes named work:NAME
How notes look
A note’s markup shows as symbols: todo boxes as ☐ and ☑ (real checkboxes in
the window; done ones dimmed and struck through), headings as a symbol for
their level, list bullets as dots, due:2026-10-03 as 📅 3 Oct (red
once it’s past, yellow on the day and in the three days before), and
remind:2026-10-06 18:00 as ⏰ 6 Oct 18:00. Code blocks keep their
markup, and the agenda leaves out todos in them. The file stays plain
Markdown: while you type on a line (insert mode), it shows as written; in
the vscode style, markup shows once the cursor is inside it. Click a box
or press enter on it to tick it; a heading’s symbol folds its section.
The symbols, rules of your own and how they all look are set from your config:
local notes = require("@notes")
-- other symbols, e.g. from a Nerd Font
notes.symbols({ todo = "", done = "", bullet = "-" })
-- tags in their own colour, and !! shown as a flame
notes.rule({ pattern = "#[%w_-]+", style = "notes.tag" })
notes.rule({ pattern = "!!", show = "🔥", style = "notes.urgent" })
-- how a style looks is the theme's, like everything else
require("@greed").theme.set({ ["notes.tag"] = { fg = "magenta" } })
A rule’s pattern is a Luau pattern; with show the match is replaced by
that text, and with action (a command name) clicking it or pressing
enter on it runs the command. The styles notes use are notes.todo,
notes.done, notes.done.box, notes.heading, notes.bullet,
notes.due, notes.due.soon, notes.due.today, notes.overdue and
notes.remind.
Agents can read and write your notes and todos too; see Agents.
Terminals
:terminal opens your shell in the project’s folder, and :terminal COMMAND runs a program instead, e.g. :terminal cargo test. Every key
goes to the program, including ones the editor would otherwise take, like
ctrl-q.
| Keys | |
|---|---|
space t | Switch to a terminal, or open a new one |
space T (in a file) | Send the selection, the Markdown code block the cursor is in, or the cursor’s line, to the terminal you used last and run it: for a REPL or a shell beside your code. For a code block with no terminal open, a floating one opens for it |
ctrl-\, esc esc | Stop typing into the program, to move around its output; one esc still goes to the program. For a program on the normal screen, like Claude Code, the first esc waits a moment, so esc esc reaches it not at all; full screen programs like editors get it at once (:set terminal-esc-wait false sends it at once everywhere) |
ctrl-space | The same, then open the leader: ctrl-space f finds a file from inside a terminal |
alt-p and the other alt pane keys | Work as in any pane: alt-p x (or :q) closes the terminal’s pane or float, ending its program unless another view shows it |
f1 | The keys that work while typing into it |
i, a, enter | Type into it again |
p | Paste the latest copy into the program |
g x, ctrl-click | Open the link under the cursor (or the mouse), or the file a path there names, at its line |
[ p ] p | The command before or after the cursor, where your shell marks them (below) |
g o | Select the output of the command at the cursor, to copy or search it |
] e [ e | The next or previous file and line the output names, like a compiler’s error at src/main.rs:12:5; g x opens it |
space d | Pick from every file and line the output names, with what it says there, to open one |
:terminal-close | End the program and close the terminal |
Out of the terminal, its output is text like any other: select it, search
it, copy it. Lines that scroll off the top stay above the screen, up to
terminal-scrollback lines (10000). When the program ends well its
terminal closes; when it fails, the output stays with how it ended, so you
can read what went wrong. A terminal keeps running while you look at other
files, and while you’re detached. :set terminal-shell "fish -l" changes
what new terminals run. A terminal is called by what it runs and the
folder its shell is in, like nu ~/src or cargo test ~/src: on a
floating terminal’s border, in the dock, the tab line and the status line.
Programs that ask for the kitty keyboard protocol (Helix, Neovim, fish,
recent shells) get it, so they can tell tab from ctrl-i or enter from
shift-enter. For those keys to reach Greed in the first place your own
terminal needs the protocol too (kitty, WezTerm, foot, Ghostty, Alacritty
and iTerm2 have it); Greed asks for it when it starts. GREED_KEYS=legacy
turns that off.
Links programs print (as ls --hyperlink and gcc do) are underlined, and
URLs written in the output open too. They open with xdg-open (open on
macOS), or whatever :set link-opener firefox names. Attached over
greed ssh, they open on the machine you’re at, in your own browser. A
link that can’t open anywhere, as with a terminal on a server with no
browser, shows in a float instead, and y copies it to open in yours.
A program can tell you something, as long builds and agents do with the
notification escapes (OSC 9, or OSC 777;notify with a title). Greed
passes it on to your desktop the way it sends its own, so you see it
while you’re in another window; looking at the terminal, it shows in the
status line instead, and a terminal out of sight is marked as wanting a
look. At most one a second reaches the desktop from each terminal, and
:set terminal-notifications false keeps them in Greed. A program that
says how far it got (OSC 9;4, as Windows Terminal reads it) has that
shown after the terminal’s name, wherever the name shows: cargo build ~/src 42%, or failed, paused and busy.
Tasks
space o t picks a task to run: a command you run again and again, like
building or testing. It runs in a terminal below the file, which stays
open when it’s done so you can read it, and running it again replaces the
last run. ] e and space d in its output go to the files and lines it
names, like a compiler’s errors. The last task you ran comes first, so
space o t enter runs it again; :task test runs one by name.
Greed finds tasks in the project: Cargo’s build, test, run and
clippy, a package.json’s scripts, and a Makefile’s targets. Add your
own in init.luau; they win over found ones with the same name:
local terminal = require("@terminal")
terminal.tasks.lint = { command = "ruff check ." }
terminal.tasks.serve = { command = { "python", "-m", "http.server" }, cwd = "~/site" }
Commands your shell marks
Greed knows the commands you run in a terminal: [ p and ] p go
between them, g o selects one’s output, and a command that failed shows
its exit code at the end of its line. It also knows the folder your shell
is in, so a terminal you open from a terminal starts in the same folder,
and g x (or ctrl-click) on a path in the output, like src/main.rs:12:5
from a compiler, opens that file at that line, found from that folder.
There’s nothing to set up for bash, zsh, fish or nushell. nushell and fish
4 tell Greed all of it themselves. For bash, zsh and older fish, Greed
starts the shell pointed at a few lines of its own, through the
environment, and those read your config as the shell would (your
.bashrc or profile files, your .zshenv and .zshrc, your fish config)
before adding what Greed reads. Your files aren’t touched, so it works the
same on NixOS and other read-only or immutable systems, and on machines
you reach with greed ssh. Your prompt stays yours. A
shell you start with a command (:terminal bash -c 'make') runs as it is,
and so does macOS’s own /bin/bash, which is too old for this.
:set terminal-shell-integration false starts shells without it.
Another shell can say the same with the escape sequences kitty, WezTerm,
Ghostty and iTerm2 read too: OSC 133;A where a prompt starts, B where
the command starts, C where its output starts and D;CODE where it
ended, and OSC 7;file://HOST/PATH for the folder.
Shells
A shell is a buffer with a prompt at the bottom; enter runs the command
typed there. Each command becomes a block above the prompt (the command,
what it printed and how it ended) that you can search, fold, copy, run
again and send to the next command or to a buffer:
$3 | sort
cargo test > buf:tests
:shell | Open a shell |
space o s | Switch to one |
space o w | What’s running in every shell: enter opens one in a float, ctrl-o goes to it, ctrl-x stops it |
Agents run their commands there too. Programs a shell runs that want an
editor, like git commit, open the file in Greed ($EDITOR is greed edit --wait there; :set shell-editor false turns that off).
The shell has the rest: keys, builtins, which shell runs a
line, terminals, and limits.
Panes and tabs
Split the screen between files and terminals, the way a terminal
multiplexer does, and keep tabs of layouts. Everything stays running in the
session, so after :detach and greed attach (or over greed ssh) the
panes, tabs and terminals are where you left them.
| Keys | |
|---|---|
alt-h alt-j alt-k alt-l | Move to the pane or panel (the file tree, an agent) on that side; from a pane at the left or right edge, on to the tab before or after, stopping at the first and last. In a zoomed tab it shows every pane again |
alt-n | A terminal in a new pane, or a floating one while floating views are shown |
alt-f | Hide the tab’s floating views or show them again; with none, open a floating terminal |
alt-F | This file in a new floating view |
alt-w | Lay the tab’s floats out with the next float layout |
alt-{ alt-} | Bring the floating view before or after to the front |
alt-W | Pick a floating view from the dock |
alt-= alt-- | More room for the pane (or floating view), or less |
alt-< alt->, alt-1… | The tab before or after (round the ends), or tab N. alt-[ and alt-] do the same in terminals with the kitty keyboard protocol; in others they start an escape code, so they can’t be keys |
alt-p, alt-t | The pane and tab modes, for everything else |
alt-r | The resize mode: h j k l make the pane, panel or floating view bigger toward that side, H J K L smaller from it (at the screen’s edge, the other edge moves), the arrows move a floating view |
ctrl-w v, ctrl-w s, ctrl-w q | Split and close, as in Vim and Helix; ctrl-w H J K L swap with the pane on that side, ctrl-w f the file under the cursor in a split, ctrl-w n s an empty one |
The alt keys work everywhere, including inside terminals. Moving to a
terminal pane types into it; moving to a file goes back to normal mode.
Entering the pane or tab mode shows its most used keys at the bottom, as
many as fit; f1 there lists them all. Keys in these modes that open
something (a terminal, a new tab, a prompt to name the tab, a picker of
layouts) leave the mode, so what they open goes back to where you were.
All the keys, and how to change them, are in
Keys.
On a Mac, alt is Option, which also types characters of its own (π,
or [ and { on a Swedish keyboard):
- In the window, Option with a key is the
altkey where that’s bound, and types its character otherwise. Characters like[ ] { } | @ $ \are always typed. With Shift, letters work asaltkeys (alt-F), other keys type their character. - In a terminal, the terminal decides (iTerm2, kitty, Ghostty and others can treat Option as Alt).
- Command with a key is for the Mac and the menus (⌘V pastes, ⌘Q quits); the editor leaves it alone.
- A keyboard in Windows layout may send Command from the key labelled Alt: switch it to its Windows mode, or swap the two in System Settings > Keyboard > Modifier Keys.
To act on a pane without moving to it first, alt-p g puts a number over
each pane; type one to go there, and you’re still in the pane mode, so
alt-p g 3 f zooms the third pane and alt-p g 3 x closes it; esc
leaves the pane mode. ctrl-w g and space w g label them too. While a
pane is zoomed the status line says “zoomed”.
Floating views belong to the tab they opened in: switching tabs hides them
and closing the tab closes them. Floats alt-f hid come back where they
were, and hidden terminals keep running. :float-file PATH opens another
file as a floating view, as alt-F does this one. alt-p e takes the
pane or panel you’re in out to float over the tab, or puts a floating view
back in as a pane; floating the tab’s last pane leaves that pane showing
another open file. Drag a float by its top border to move it or by an edge
to resize it, or use the resize mode (alt-r). The tab’s
float layout decides where floats go.
To move what a pane shows somewhere else, alt-p b takes it to a new tab,
alt-p t to a tab you pick (or a new one), and alt-p P into a panel on
the right; its cursor goes with it and a terminal keeps running. They work
on a floating view too, and t and b on a panel. :pane-to-new-tab,
:pane-to-tab and :pane-to-panel do the same.
To put a new pane somewhere particular, alt-p p shows a frame where it
would go, on the right of the pane you’re in. h j k l move the frame to
either side of any pane, or along a whole edge of the tab; enter opens a
pane there showing this file, t a terminal, and esc leaves things as
they were.
Layouts
Each tab has a layout that arranges its panes as they open and close:
manual: panes go where you split them. The default.main-stack: one main pane, the rest stacked beside it. A new pane takes the main place and the old main joins the stack.columns: all side by side.spiral: each pane takes half of what’s left, winding inward.
alt-space goes to the next layout and alt-p y picks one; either says
which at the bottom, and the status line shows it while it isn’t manual. A
tab’s panes keep an order, and that’s what you change:
alt-m swaps the pane into main, alt-p o moves them all one place
along, and alt-p [ and ] give main less room or more. Resizing a pane
by hand switches the tab to manual, keeping the shape it had.
:layout-save NAME saves the tab as it is: its panes, their sizes, and what
each shows, a file (relative to the project) or a terminal and what it runs.
It goes in the project, in .greed/layouts/, so it can be shared with the
rest of the repository; :layout-save-mine NAME keeps it in your config,
for any project. :layout-open picks one and opens it as a new tab. A
project can open one by itself from its .greed/init.luau:
require("@panes").saved.open("dev", { here = true })
:set pane-layout main-stack sets the layout new tabs start with. A layout
is a Luau function from the panes, in order, to how they’re arranged, so
you can write your own:
-- every pane in a row of its own, one above another
require("@panes").layouts.define("rows", function(panes)
return if #panes == 1 then panes[1] else { split = "column", children = panes }
end)
Float layouts
With several floats open (agent sessions, terminals), the tab’s float
layout says where they go and which of them show. alt-w goes to the next
one:
free: they stay where you put them. The default. Coming back tofreefrom another layout puts each float back where it was.one: one at a time, like tabs. Every float takes the same place at the same size and only the one in front shows;alt-}andalt-{bring the next one or the one before to the front, round the ends, without anything moving. The others keep running out of sight. Moving or resizing the one in front moves them all.tiled: side by side in a grid over the panes, laid out again as floats open and close and as the window changes size.cascade: overlapping, each a step down and right of the one before, so every title shows.
In one the float in front shows where it is on its border:
‹ 2/5 ›at the right of the top, with the names of the floats either side when it’s wide (‹ nu ~/src · 2/5 · claude ›; of two, the other on its side:‹ 1/2 · claude ›). Click‹or a name before it for the float before,›or a name after it for the next.- A dot for each float along the bottom, the one in front filled. Click a
dot for that float (
:float-go Ndoes the same). - A dock along the bottom of the tab lists them all by number and name.
Click a name to bring that float to the front, or press
alt-Wand then its number (or move with the arrows and pressenter).:float-dockshows or hides the dock in any layout.
A float that needs you gets a colored dot, in its place along the border and in the dock: an agent session waiting for your answer, or a terminal whose command finished while it was hidden (until you look at it).
alt-p O, T and C pick one, tiled and cascade
directly, alt-p Y picks from a list (:float-layout-pick), and
:set float-layout one sets the layout new tabs start with.
A layout of your own is a function from the tab’s floats to where each one goes, its border included, and whether it shows:
require("@panes").floats.define("left-half", function(a)
local places = {}
for i in a.floats do
local box = { x = a.room.x, y = a.room.y, width = a.room.width // 2, height = a.room.height }
places[i] = { box = box, hidden = i ~= a.current }
end
return places
end)
a.floats are the tab’s floats in the order they opened, a.current the
one in front, a.room the room the panes take and a.boxes where each
float is now. Plugins that show things in floats use
require("@panes").floats.show(buffer), which opens the buffer in a float
of the tab (or finds the one it has) and brings it to the front,
floats.focus(view) for a float they have, and
core.attention.set(key, { label = ..., reason = ..., buffer = buffer })
to give it the dot.
Clipboard
What you copy goes on your system clipboard too, through your terminal
(OSC 52), so it works over greed ssh and in tmux with set-clipboard on.
Most terminals allow it; some ask first or need it turned on (iTerm2:
“Applications in terminal may access clipboard”). GREED_CLIPBOARD=off
keeps copies inside Greed. A program in a Greed terminal that copies the same
way puts the text on Greed’s clipboard, so p pastes it.
Mouse
| Mouse | |
|---|---|
| Click | Put the cursor there and focus that pane |
| Drag | Select |
| Wheel | Scroll whatever’s under it |
| Double click, triple click | Select the word, the line |
shift-click | Extend the selection to there |
alt-click | Add a cursor there |
ctrl-click (cmd-click in the window on a Mac) | Go to where what’s there is defined, as g d does; in a terminal, open the link or file there |
| Click a tab in the tab line | Show it |
| Drag a floating view’s top border (the title) | Move it |
| Drag a floating view’s other edge or a corner | Resize it |
| Drag the line between two panes, or beside a panel | Give one more room |
Clicking a button (a proposal’s accept and reject, a todo’s box) presses
it. So does enter in normal mode with the cursor on it; where several
buttons share a spot, enter lists them to pick from.
In a terminal, a program that asks for the mouse (vim, htop, less with
--mouse) gets it. Otherwise the wheel scrolls back through the output,
which stops typing into the program, and scrolling back down to the bottom
types into it again; in a full screen program the wheel sends arrow keys. A
click types into the program, and a drag selects output to copy with y.
Most terminals still select text their own way while you hold shift.
GREED_MOUSE=off leaves the mouse to your terminal.
Images
Greed shows images in terminals that speak the kitty graphics protocol:
kitty, Ghostty, WezTerm and Konsole. It finds out from the variables those
terminals set; GREED_IMAGES=kitty turns images on in another that speaks
the protocol, and GREED_IMAGES=none turns them off. Elsewhere, the text
under an image shows instead.
Programs in Greed’s terminals can show images too, with the same kitty
protocol or iTerm2’s: kitten icat picture.png, imgcat, chafa’s and
yazi’s previews. They scroll with the output, and text written over them
takes their place, as in any terminal.
Bigger text, like a heading a plugin scales up, is drawn big in the window
and in kitty, which can size text, though not in tmux, zellij or screen
running in kitty. Other terminals show it at the normal size on the rows
it takes. GREED_TEXT_SIZING=on or off decides it for another terminal
that can size text, or turns it off in kitty.
Image files
Opening a PNG, JPEG or GIF shows the image, as wide as the pane at most,
under a line with its name, its size in pixels and the zoom. + and -
draw it bigger and smaller, = fits it to the pane again and 0 draws it
at its own size; space . on it offers the same. It shows in the window
and in terminals that show images. A picture in a chat room opens this way
with enter, or open on space ., and q or esc takes you back to
wherever you opened it from (it’s ctrl-o, really).
PDFs
Opening a PDF shows its first page, as wide as the pane. ] and [ go to
the next and previous page (with a count, that many), + and - draw it
bigger and smaller, and = as wide as the pane again. t switches to the
text of every page, which reads in any terminal and searches with /; t
again shows the page the cursor is on. q or esc goes back, as on a
picture.
Other files
Files Greed can’t show open with the program your system opens them with
(xdg-open, open on macOS, or what the link-opener option names):
office documents (Word, Excel, PowerPoint, OpenDocument, Pages, Numbers,
Keynote), e-books, sound and video. Anything else that isn’t text, like a
zip file, doesn’t open, and Greed says so; space . on it offers
open-outside.
Your config says how a kind of file opens, by its extension:
local file = require("@core").file
file.open_with("docx", { "libreoffice" }) -- with this program
file.open_with("zip", "outside") -- with the system's opener
file.open_with("rtf", "greed") -- in Greed, as its text
Programs and scripts are never handed to another program, whatever the
config says, so opening a file can’t run something: a .exe, .app or
.desktop file, or one that starts like a program does whatever it’s
called. A script opens as its text.
The command line
: (or alt-x in the vscode style) runs any command by name, with
completion.
| Keys | |
|---|---|
space ? | List every command |
space h c | Describe a command |
space h k | What a key does |
space h h | Describe anything the editor is made of: commands, options with their values, events and who listens to them, the plugin API, plugins, modes and editing styles. enter in the help window goes to where it’s defined |
space h i | Inspect what’s under the cursor (a buffer, a shell block or a row of its table, a terminal, a file), or with nothing there the editor itself |
history on space . | What was done to anything |
f1 | The keys of the mode you’re in, in every mode |
space h i shows a thing’s state, the objects it relates to (enter goes
to one, backspace or ctrl-o comes back, ctrl-i goes forward again),
what was done to it, by you or an agent, and what it can do (enter runs
that). After a key like space, a hint at the bottom right shows what can
follow, with groups of keys named (w panes…). A message on the status
line goes away with the next key.
:lua CODE runs a line of Luau with the whole plugin API, and := EXPR
shows what an expression is (:= #greed.buffers()).
The short names Vim and Helix users type work too: :w :wa :q :qa
:wq :wqa :x :e :b :bn :bp :bc :ls :sp :vs :only
:tabnew :noh :rl :rla :set :toggle, :colo (:colorscheme)
for :theme, :setf for :language, Neovim’s :checkhealth for
:health, and Helix’s long ones like :write-all and :buffer-close.
Arguments go after a space (:w notes.md); only Vim’s line commands and
:b take one right after the name (:m0, :t$, :b#). A command that
refuses, like :q with unsaved changes, says why; an error from a bug in
a plugin also names the plugin, and :errors has the details.
Vim’s line commands work in every style. A range in front picks the lines
a command works on; without one, it’s the lines the selection touches
(:g and :v take the whole file).
| Command | |
|---|---|
:42, :$ | Go to line 42, or the last line |
:s/regex/text/flags | Replace on the lines: g every match on a line, i ignore case, I match case, n only count, c ask about each (y yes, n no, a this and the rest, l this and stop, q quit); \1 and & put back what matched. Undo puts the cursor back on the first line changed |
:g/regex/command, :v/regex/command | Run a command on each line that matches, or doesn’t; with no command, select those lines |
:d :y | Delete or copy the lines |
:m 0 :t $ | Move or copy the lines below a line (0 is the top) |
:norm keys | Type the keys in normal mode on each line |
:j :> :< | Join, indent or dedent the lines |
:sort | Sort the lines (the whole file without a range): :sort! backwards, and u one of each, i ignoring case, n by the first number |
:%!sort | Put the lines through a program, as the pipe key does with a selection |
:!cargo test | Without a range, run it in this project’s shell, where its output stays |
:e! | Load the file again from disk (an undo takes it back) |
Ranges are line numbers, . (the cursor’s line), $ (the last),
/regex/ (the next line matching), '< and '> (the selection’s first
and last line) and % (every line), with +n or -n after any of them:
:%s/old/new/g, :.,+3d, :/^fn/,$norm A;. Patterns are regexes, as in
search. In Vim’s style, : in visual mode starts with '<,'> and 3 :
with .,.+2.
While you type :s, the lines on screen show what it will do: the
pattern’s matches, then, once you start the replacement, each match struck
through with its replacement next to it. Nothing changes until you press
enter, and esc leaves the file as it was.
:set substitute-preview false turns it off.
Configuration
Your config is ~/.config/greed/init.luau, plain Luau with the full plugin
API. :config-open (or :config) opens it, making the folder if it isn’t
there yet. Your own plugins go in ~/.config/greed/plugins/NAME/. A plugin
that appears there, or whose files change, loads by itself, asking you
first if it wants something you haven’t approved; :plugin-reload NAME
loads one again by hand. Writing plugins has more.
Plugins others share in git are named in your config, in init.luau or a
file you require from it:
local plugins = require("@git-plugins")
plugins.use("https://github.com/someone/greed-jump")
plugins.use("https://github.com/someone/greed-todo", { ref = "v2", name = "todo" })
Naming one only records it, so starting never waits on the network: once
Greed is up, what’s missing is fetched in the background into the data
folder (or now, with :plugins-sync) and loads like your own, asking for
your approval if it wants capabilities. Each is pinned to a commit in
plugins.lock next to your config, so another machine with the same
config and lock file gets the same ones; commit it with your config.
:plugins-update (or :plugins-update NAME) moves them to the latest of
the branch or tag they follow, asking again if an update wants more.
To stop using one, take its line out of your config and run
:plugins-sync: the plugin goes to the trash and its pin goes from the
lock file. Starting Greed never removes plugins on its own.
Plugins to install lists some to try.
Where Greed keeps things, and profiles
Greed keeps four folders: your config (~/.config/greed), data like saved
agent sessions (~/.local/share/greed), a cache (~/.cache/greed) and
state like the plugins you approved and kept secrets
(~/.local/state/greed). The XDG_CONFIG_HOME, XDG_DATA_HOME,
XDG_CACHE_HOME and XDG_STATE_HOME variables move them as usual.
A profile keeps everything in one folder of your choosing, with sessions of its own that never meet your usual ones:
greed --profile ~/greed-work # a setup of its own
greed --profile "$(mktemp -d)" # Greed as on its first run
The profile holds config, data, cache, state and run (its
sessions’ sockets).
| Flag | Variable |
|---|---|
--profile | GREED_PROFILE |
--config-dir | GREED_CONFIG_DIR |
--data-dir | GREED_DATA_DIR |
--cache-dir | GREED_CACHE_DIR |
--state-dir | GREED_STATE_DIR |
A folder’s own setting wins over the profile, which wins over the XDG
variables. Sessions’ sockets go in GREED_RUN_DIR when it’s set, for when
a profile’s path is too long for a socket (about a hundred characters at
most). Sessions, terminals, shells and agents Greed starts get the same
folders, so greed ctl inside one of its terminals finds its session.
HOME stays yours, so git, kubectl and your keys work as usual.
Saving your config, in Greed or anywhere else, runs it again within a
second: what it registered (commands, keys, theme entries, event handlers)
is taken away and set up anew, and the status line says “config reloaded”
or what went wrong. Options it set keep their values until it sets them
again. :config-reload does the same by hand.
For luau-lsp to check your config and complete it, it has to know what
require("@greed"), require("@theme") and the other plugins are. Greed
writes a .luaurc that tells it, beside the config folder
(~/.config/.luaurc, since luau-lsp looks for an init.luau’s settings
in the folder above), when it starts and when you save your config, and
keeps it pointing at the Greed you run. It only writes over a .luaurc it
wrote itself: if you had one there or change it, it’s yours, and
:config-types says so.
Config runs in layers, each after the one before, so later ones win:
- The default plugins.
- The config
greed sshbrought from your machine, in a session on another one. - This machine’s own config,
~/.config/greed. - The project’s own config,
.greed/init.luauin the project, once you trust it.
A project’s config is code from whoever wrote the repository, so it doesn’t
run until you say so: opening a project that has one tells you, and
:trust runs it, now and whenever the project opens again. Trusting a
project also lets its language servers start and its files format on
save, which run its code too; Greed asks the first time a file of an
untrusted project opens (see
Trusting a project). Trusted projects
are listed in ~/.cache/greed/trusted-projects; take a line out to stop
trusting one.
local greed = require("@greed")
-- Keys
greed.keymap.bind({ layer = "leader" }, { W = "save-all" })
-- Options (`:set` changes them while running)
greed.option.set("flash-duration", 150)
-- The theme: change a few names, or all of them
greed.theme.set({
["ui.selection"] = { bg = "#3b3f51" },
["keyword"] = { fg = "magenta", bold = true },
})
-- A language
require("@languages").set("python", { servers = { { "pylsp" } } })
-- Turn off a default plugin
greed.plugin.unload("hints")
Keys covers key names, modes and taking keys away.
The status line
The status line shows the mode, the tab, the tab’s layout when it isn’t
manual and zoomed while one pane fills it, the file and whether a
macro is recording on the left. The file is the one you’re in: a focused
panel or floating view (a floating terminal) counts, a picker or the
command line doesn’t. Buffers without a file show by name, like
terminal: nu ~/src, or untitled for a new file. While you type a
command after : the mode says COMMAND, and in a prompt like search’s
PROMPT. The file gets [+] while it has unsaved changes; undoing back
to what was saved takes it away. After the file come the function and
type the cursor is in, like Server › listen, in languages with a
grammar; require("@statusline").remove("symbol") hides them. On the
right it shows:
- the branch and the lines added, changed and removed in the file, like
main +3 ~1 -2(with jj the nearest bookmark and the change you’re on, likemain · nwpr) - todos due today, like
2 due today(see Reminders) - problems
- the language and the features on for the file, like
markdown · notes - the language server: its name, what it’s working on
(
rust-analyzer: indexing 40%), or that it’s starting, stopped or not installed - the editing style, dim, like
helix; click it to pick another - anything unusual about the file, and only then:
CRLFline breaks,tabs(orspaces) where its language indents the other way, orread-only - how many selections there are, once there’s more than one
- agents at work or waiting for you, in sessions and in terminals, like
◆ 1 working · 1 waiting for you - the cursor’s line and column (the character the cursor is drawn on, at the end of a selection too), the machine and the session
Two options, both off by default, add color and motion:
local option = require("@greed").option
-- The mode, tab, machine and session as pills in their theme colors, with
-- rounded ends (they need a Nerd Font; statusline-caps "none" makes them square)
option.set("statusline-pills", true)
-- A wave of light through the letters of the tab or the file when you go
-- to another, a glow from the middle of the mode when it changes, and in
-- an agent's pane, spinning tools and a status that moves while it works
option.set("effects", true)
The wave’s letters glow towards the theme’s ui.glow color: brighter text
in a dark theme, the accent in a light one. Effects need a theme with
#rrggbb colors, so the default 16-color theme has none.
Highlights that show what changed
These highlights are on by default (except effects-dim), each with an
option of its own:
effects-changes: text someone other than you changes (an agent, a formatter, a language server’s rename or fix, a plugin, the file changing on disk) gets a faint background in the views showing it for a second, then fades out over a second and a half. What you type, paste, undo or pick from a completion menu doesn’t.effects-jumps: the line a jump lands on lights up for a moment: a search hit, going to a definition, back and forward through the jumplist (ctrl-o,ctrl-i), a picker opening a file at a line, and any move of more than a screen. Ordinary moves don’t.effects-dim, off by default: the panes you’re not in are dimmed, their text blended towards the background in the window, and in a terminal drawn with its dim attribute.
local option = require("@greed").option
option.set("effects-changes", false)
option.set("effects-dim", true)
The colors are the theme’s ui.changed and ui.jumped backgrounds. With
#rrggbb colors they fade in a few steps, in the terminal too; with the
terminal’s 16 colors changed text is underlined for a moment and the
line a jump lands on gets a gray background, then both go. In a
repository, the gutter’s +, ~ and - signs also mark the lines that
changed, without relying on color, and the cursor is on the line a jump
lands on.
Add pieces of your own, or take some away:
local statusline = require("@statusline")
statusline.add("right", "clock", function()
return os.date("%H:%M")
end)
-- A pill in a theme style
statusline.add("left", "env", function()
return { text = "staging", style = "ui.statusline.tab" }
end)
statusline.remove("host")
A piece gets the main view, its buffer, the mode and the message, and
returns text, a pill ({ text, style }), a list of pills shown joined, or
nil to show nothing. The pills’ colors are the theme’s
ui.statusline.mode, .tab, .tab.number, .host and .session;
.dim is the editing style’s.
A piece is drawn with every frame, so it has to be quick and can’t run
programs. For anything that takes time, like a repository’s state in a big
monorepo, add an async piece: its refresh runs in the background and can
run programs, and the status line shows what it last found, never waiting
for it.
A plain piece that turns out slow (more than 10 ms to draw, three times in
a row) is moved to the background the same way: from then on it’s drawn at
most once a second and the status line shows what it last made.
:debug plugin:statusline says which pieces were moved.
A status line of your own (greed.statusline) that takes too long is
stopped, and the last one stays up for a second before it’s built again.
Typing never waits for either.
statusline.add_async("right", "change", {
refresh = function()
local done = require("@greed").process.run({
"jj", "log", "-r", "@", "--no-graph", "-T", "change_id.short()",
})
return done and done.code == 0 and done.stdout or nil
end,
every = 5000, -- milliseconds
on = { "buffer.saved" }, -- and whenever these happen
})
Indent guides, colors and TODO comments
Files show a few things that aren’t in the text, each with an option to turn it off:
indent-guides: a thin line at each level of indent, through blank lines in a block too (styleui.indent.guide).color-swatches: a square in its color in front of a color like#ff8800,#fa0or#ff880080. A three-digit one needs a letter in it, so an issue number like#123stays plain.todo-comments: TODO, HACK and XXX picked out in comments in one color (comment.todo), FIXME and BUG in another (comment.fixme), NOTE in a third (comment.note). Only in comments, so a string saying “TODO” stays as it is.:todo-commentslists them across the project.
Rulers are off until you name their columns: :set rulers 80,100 draws a
┊ at columns 80 and 100 wherever nothing is written there (style
ui.ruler). They don’t reach the empty rows below the end of the file.
require("@greed").option.set("rulers", "80,100")
require("@greed").option.set("indent-guides", false)
require("@todo-comments").words.PERF = "comment.note"
Themes
:theme lists the themes and tries each one as you move through the list.
enter keeps it, esc goes back to the one you had, and :theme nord
switches straight away. Tab through the matches after :theme tries each
one the same way. The theme you pick is remembered for next time, unless
your init.luau sets one with theme.use, which runs later and wins.
Greed comes with default (your terminal’s 16 colors, so it follows your
terminal’s palette), nord, nord-light, dracula, catppuccin-mocha,
catppuccin-macchiato, catppuccin-frappe, catppuccin-latte, gruvbox,
gruvbox-light, onedark, tokyonight, tokyonight-storm,
solarized-dark, solarized-light, rose-pine, rose-pine-dawn,
kanagawa, everforest and monokai.
Themes are Luau. Set one, or make your own, in init.luau:
local theme = require("@theme")
theme.use("nord")
-- A built-in theme with changes
theme.define("my-nord", {
inherits = "nord",
styles = { comment = { fg = "#7b88a1", italic = false } },
})
-- A theme from a palette: backgrounds, text and hues, and optionally
-- fg_alt, accent, and colors for syntax: keyword, func, string, type,
-- constant and operator
theme.define("mine", {
palette = {
bg = "#101418", bg_alt = "#181e24", bg_high = "#232b33", selection = "#2c3640",
fg = "#d0d6dc", comment = "#5c6773", gutter = "#3a444e",
red = "#e06c75", orange = "#d19a66", yellow = "#e5c07b", green = "#98c379",
cyan = "#56b6c2", blue = "#61afef", purple = "#c678dd",
keyword = "#c678dd",
},
})
A theme can come from a plugin too, like
zenbones. theme.use and the
theme you picked last wait for it: the one in use stays until the plugin
adds it, as on the first start, while it’s still being fetched.
greed.theme.set changes single names on top of whichever theme is in use,
and those changes stay when you switch themes. Each changes only the fields
it gives: greed.theme.set({ comment = { italic = false } }) keeps the
theme’s comment color. A theme’s own styles work the same way on what it
inherits. Names fall back to their parent, so keyword.control uses
keyword unless it has its own entry; Highlighting lists
them.
With several terminals attached to a session, each shows the others’
cursors and selections in their own color: client color N (1 to 6) uses
ui.cursor.peer.N and ui.selection.peer.N, which fall back to
ui.cursor and ui.selection. The built-in themes give each a color of
their palette, with selections underlined.
One theme serves the terminal and the window. Where they should differ, an
entry’s tui and gui parts change it for one of them, like
["ui.float"] = { bg = "black", gui = { bg = "#25282c", rounded = true } }.
rounded gives floats rounded corners in both: drawn smooth in the window,
as ╭╮╰╯ in the terminal. These fields are for the window only:
| Field | |
|---|---|
shadow | Floats with a soft shadow |
badge | The style’s background as a small box with rounded corners, like a key cap (motion hints and buttons use it) |
hover | Light up what’s under the mouse (buttons, fields, choices, tabs) |
checkbox = "empty" or "checked" | A checkbox over the text (todo boxes use it) |
checkbox = "choice" or "chosen" | A round button (Markdown choices use it) |
font = "prose" | Text in the proportional font |
font = "Monaspace Radon" | Text in that family, in the grid’s cells; the grid’s font when it isn’t installed |
Naming a family works best with ones made to share a grid, like the Monaspace families: comments in Radon, which looks handwritten, beside code in Neon, like this:
greed.theme.set({ comment = { italic = true, gui = { font = "Monaspace Radon" } } })
The terminal keeps the italic and draws the rest as usual.
#rrggbb colors go out as they are when the terminal says it shows 24-bit
color (COLORTERM=truecolor, as most do), and as the nearest of 256 colors
when it doesn’t, like tmux without its RGB feature. GREED_COLORS=truecolor
or GREED_COLORS=256 decides for a terminal that says the wrong thing.
Highlighting and syntax queries
Greed has grammars built in for Rust, Nix, Bash, Python, Go, JavaScript,
TypeScript, C, Luau, JSON, TOML, YAML and Markdown. For C++, C#, Java,
Ruby, Scala, Haskell, OCaml, Julia, HTML, CSS and HCL (Terraform and
OpenTofu, whose language servers terraform-ls and tofu-ls start when
installed) it downloads the grammar the first time you open a file in that
language, checks it against a checksum Greed knows, and keeps it in
~/.cache/greed/grammars.
Some languages borrow another’s grammar: Starlark (Bazel’s BUILD and
.bzl files) and Tiltfiles are highlighted as Python, JSONC as JSON,
Docker Compose files as YAML, .env files and PKGBUILDs as Bash. XML
(and MSBuild projects), ERB and EJS templates, requirements.txt, CodeQL
and tree-sitter queries download theirs the same way as the languages
above.
So do Protobuf, Common Lisp, Scheme (and Racket, Dune and Hy), Janet,
QML, Jinja and Nunjucks, Go templates and Helm charts, INI and systemd
units, .gitignore and .gitattributes, robots.txt, and Glimmer’s
.gjs and .gts. Their grammars don’t publish WebAssembly builds, so
Greed builds them at the versions Helix uses and downloads them from its
own releases, with Helix’s queries.
A language of your own can borrow a grammar too, and uses the other language’s queries until it has its own:
require("@languages").set("cue", { extensions = { "cue" }, grammar = "go" })
:health | Which languages are built in, which download, and which have no grammar |
:grammar-fetch ruby | Download one ahead of time, say before going offline |
greed.option.set("grammar-download", false) | Turn downloading off |
Adding a grammar Greed doesn’t have
If the grammar publishes a WebAssembly build in its GitHub releases (a
tree-sitter-NAME.wasm file), tell Greed where it is in your config and it
downloads it like the ones above. Odin’s, for example:
require("@languages").grammars.sources.odin = {
repo = "tree-sitter-grammars/tree-sitter-odin",
version = "v1.3.0",
sha256 = "4a3c9f50ac2356d2284d26e92322c554b276ad6bf6bce87a8594cff95d2ed6f1",
}
version is the release tag, and sha256 is the checksum of the .wasm
file (sha256sum tree-sitter-odin.wasm after downloading it once). The
queries come from the repository’s queries folder at that tag, with their
capture names changed to Greed’s. Add symbol = "..." when the grammar’s
own name isn’t the language’s with - as _.
The key is the language’s name, or its grammar if it borrows one. Most
languages are already known, with their file extensions and language
servers. For one that isn’t, add it too:
require("@languages").set("odin", { extensions = { "odin" }, comment = "//" })
No WebAssembly build? Build it yourself with the tree-sitter CLI and point the entry at your files:
git clone https://github.com/tree-sitter-grammars/tree-sitter-odin
cd tree-sitter-odin
mkdir -p ~/grammars
tree-sitter build --wasm -o ~/grammars/odin.wasm
cp queries/*.scm ~/grammars/
sha256sum ~/grammars/odin.wasm
require("@languages").grammars.sources.odin = {
repo = "tree-sitter-grammars/tree-sitter-odin",
version = "local-1",
sha256 = "the checksum from sha256sum",
url = "file:///home/you/grammars/odin.wasm",
queries = "file:///home/you/grammars/{kind}.scm",
}
Greed copies the files into its cache the first time a file in the language
opens, so after rebuilding, change version (and the checksum) to have it
copy them again. queries works with an https:// URL too, for queries
kept somewhere other than the grammar’s repository.
When it doesn’t work, :health says whether the language has a grammar,
and Greed’s messages say why a download or a query failed. Queries written
for other editors sometimes use things Greed doesn’t support; fix those
with your own file in ~/.config/greed/queries/odin/, described below.
What gets highlighted, and what counts as a function for m i f, comes
from tree-sitter queries: files named queries/LANGUAGE/KIND.scm, where
KIND is highlights, injections (languages inside others, like the code
blocks in Markdown, which are highlighted in their own language),
textobjects, folds (the blocks z a folds, captured as @fold) or
indents (nodes whose lines go a level in, @indent, and closing tokens
that line up with their block’s first line, @outdent).
Greed reads them from every plugin and from ~/.config/greed/queries, so a
file there replaces Greed’s own. To add to it instead, start the file with
; extends:
; extends
; ~/.config/greed/queries/rust/highlights.scm: TODO in comments stands out
((line_comment) @comment.todo (#match? @comment.todo "TODO"))
Highlighting lists the names highlights queries use and the theme styles.
A query with a mistake in it says so when Greed starts, and the one before
it stays in use. require("@languages").load_queries() reads the files
again after you change them.
Hoard: notes and todos
Hoard is where your notes, todos and today’s plans live. It opens on a home page with what’s due, what you wrote today and a search over everything, and you don’t need to know an editor to use it.
greed notes # in this terminal
greed --gui notes # in a window
Running it again comes back to the same Hoard, with everything as you
left it. The first time, the home starts with where your notes are kept
and how to add to them, until you press Got it.
Your notes are plain Markdown files in a folder, ~/notes unless you
set another in your config (~/.config/greed/init.luau). An Obsidian
vault works as it is: its links, tags, front matter, daily notes and
templates are read the way Obsidian reads them.
greed.option.set("notes-folder", "~/Documents/My vault")
This page starts with the everyday parts: the home page, writing notes, saying when things are due and repeats. Further down are links and Obsidian, queries, templates and having Greed’s agent help.
From Greed itself, :hoard (space n h) takes the window you’re in to
Hoard, starting it if needed, and space B brings you back.
:hoard-window (space n H) opens Hoard in a window of its own instead,
leaving this one as it is.
Hoard has no modes, so : types; ctrl-g opens the command line and
ctrl-shift-p the list of commands.
Hoard Sunday 18 October
╭─ Agenda ─────────────────────────────────────╮
│ Overdue │
│ ☐ fix the fence 10 Oct │
│ Today │
│ ☐ buy seeds │
╰──────────────────────────────────────────────╯
Inbox: 2 todos All todos
Recent notes
Garden plans garden
╭─ Today ──────────────────────────────────────╮
│ met Anna about the garden │
│ Open today's note │
╰──────────────────────────────────────────────╯
╭─ Write a thought, or search ─────────────────╮
│ [] call the bank tomorrow 18:00 │
│ the shed needs paint before winter │
╰─ [] makes a todo ── Add to today, alt-enter ─╯
On the home page
The box at the bottom is where you write; the cursor is in it when Hoard
opens. Write as much as you like (enter starts a new line), then
alt-enter or ctrl-enter (or a click on Add to today) adds it to
today’s note:
- A line starting
[]becomes a todo, and understands plain words for when (below):[] call the bank tomorrow 18:00. - Anything else goes in as you wrote it; a single line becomes a list item.
/and[[work as they do in notes (below).- Starting with
?asks your notes a question instead (see “Having the agent help” below).
While what you write is one line, what matches it shows above the box:
notes with those words anywhere in them, headings and todos, the last
word matching as you type it. It takes a query too, like is:overdue or
tag:garden is:todo (see “Lists that keep themselves” below). Above
that:
- Agenda lists what’s overdue, due today and due in the next week.
Today’s part also has the todos you wrote today without a date. The
box ticks a todo off; the words open its note; when (or
alt-don the line) moves it to today, tomorrow, the weekend, next week or no date, or to a day you type in plain words, likefridayorin 3 days. - From before brings back what you’d otherwise forget (see “Looking back” below).
- Inbox opens the note todos are captured to from elsewhere, Agenda note opens a note of queries for what’s due (made the first time, then yours to change; see “Lists that keep themselves” below), and All todos lists every open todo, soonest first.
- Recent notes are the ones changed last.
- Today shows what you wrote in today’s note, its todos being in the agenda. Each day gets a note of its own, made the first time you write in it.
To move about with the keyboard, up from the top of the box goes to the
nearest thing above it, the best match while you search. up and down
(or tab and shift-tab) then go from one thing to the next, the one
you’re on lit up, and enter opens or presses it. down past the last
one, or esc, comes back to the box, and typing goes to the box from
anywhere. With the mouse, click what you want.
From a note, esc goes back to the home (when something is selected,
the first esc lets go of it). The status line at the bottom starts
with ‹ Hoard, which does the same when clicked. alt-left goes back to
where you were before, as in a browser, and alt-right forward again.
Writing notes
A note is a page of text. A line starting with # is a heading, - makes
a list, and - [ ] a todo:
# Garden plans
- [ ] buy seeds due:2026-10-20
- [ ] fix the fence remind:2026-10-19 18:00
- the shed needs paint
due:gives a todo a date, for the agenda, andevery:mondaymakes it repeat (below).remind:gives anything a reminder, with a time or for the morning, as many as you like. It shows in Greed and on your desktop when it’s due.[[Garden plans]]links to another note;F12on it opens it, making it if it’s new (g dwith Vim’s or Helix’s keys). Each note lists the notes that link to it at its end.- You don’t have to link while you write. When a line names another note
(its name, title or another name it goes by), like “talked to Anna
about the garden plans” with a note called Garden plans, the line says
so at its end:
↗ Garden plans.ctrl-.(space awith Vim’s or Helix’s keys), or a click on it, makes those words a link, kept as you wrote them. Each note also lists the notes mentioning it without a link, under “Mentioned in”. #gardentags a note, and a todo or line in it.#garden/seedsis a tag under it.:notes-tag-rename garden yardrenames a tag in every note, the tags under it and front matter’stags:too./at the start of a word opens a menu of these: todo, today’s or tomorrow’s date, due, remind, every, link, heading, table and tag. Pick one and fill in its places,tabgoing from one to the next.
Lists and sections as an outline
A list item takes the items under it along, and a heading its section:
tabon an item’s first line puts it under the item before, andshift-tabtakes it back out, with what’s under it.alt-upandalt-downmove the item past the one beside it, or a section past the one beside it, keeping the blank lines between.ctrl-space zzooms in to the item or section the cursor is in and shows only it, following it as you add to it;ctrl-space Zoresczooms out again. (space zandspace Zwith Vim’s or Helix’s keys.)ctrl-k ctrl-lfolds an item or a section under its first line, or unfolds it (taborz awith Vim’s or Helix’s keys).
Hoard types as you’d expect: keys type, notes save on their own a moment
after you stop typing, and ctrl-z undoes. That holds even if you use
Vim’s or Helix’s keys in the rest of Greed; to have them in Hoard too:
greed.option.set("hoard-editing-style", "same")
Notes have no line numbers, and Markdown’s language servers don’t run on
them: harper-ls, for one, checks spelling and grammar as English, whatever
language you write in. greed.option.set("hoard-language-servers", true)
turns them on.
Links, embeds and Obsidian
Links can go to a place in a note as well as the note itself:
See [[Garden plans#Seeds]] for the list, and [[Garden plans#^fence|the fence]].
![[Garden plans#Seeds]]
[[note#Heading]]goes to a heading, and[[note#^id]]to a line ending in^id.[[#Heading]]is a heading in the same note.[[note|other words]]shows the other words in its place.![[note]]shows the note right there, under the line, and keeps it current as the note changes.![[note#Heading]]shows that section and![[note#^id]]that line, with what’s under it in a list. Long ones are cut short.![[beach.png]]shows the picture in the window (and in terminals that show pictures), found as Obsidian finds it: beside the note, in Obsidian’s attachments folder or anywhere in your notes by its name.![[beach.png|300]]makes it 300 pixels wide at most.- Typing
[[lists your notes, and their other names, as you type, and the closing]]comes along. After a note’s name,#lists its headings and#^its list items and lines. You don’t write ids: a line you link to gets one at its end, like^3fa2c1, when you pick it. ctrl-space n k(space n kwith Vim’s or Helix’s keys) does the same from all your notes at once: pick a heading, a list item or a line and the link goes where you are.- Renaming a note, or moving a folder of them (
:file-rename, or from the file list), changes the links to them in your other notes. [mail](mail:ID), whichTin mail writes in a todo, opens that message’s thread in Greed.
A folder Obsidian writes works as it is. Links find notes as Obsidian
finds them: [[Cards view]] goes to Bases/Cards view.md wherever it
is, in any case and with or without .md, and [[Layouts/Cards view]]
the note whose path ends that way; when several notes have that name, the
one in the linking note’s folder wins, then the one nearest the top. In a
table, [[note\|words]] is a link with other words. Links in
front matter (categories: ["[[Movies]]"]) count as links too.
aliases: in a note’s front matter (aliases: [w42, this week]) are
other names links can use, in any case; #tags, key:: value fields and
the Tasks plugin’s dates (📅 2026-10-20 is a due date) are read too.
Canvas and Bases files aren’t. Today’s note goes where Obsidian’s daily
notes are set to keep it (their folder, name and template, in
.obsidian/daily-notes.json), and its templates folder is the one
Obsidian uses.
Saying when in plain words
A todo you add on the home page or with space n c can say when in plain
words, and Greed writes the date for you:
| You type | It’s |
|---|---|
call the bank tomorrow 18:00 | due tomorrow, with a reminder at 18:00 |
dentist on friday at 9 | due Friday, reminder at 09:00 |
renew passport in 3 weeks | due in three weeks |
party 31 dec, trip jan 5, report 2026-11-02 | due that day |
plan the trip next week | due next Monday |
movie tonight | due today, reminder at 20:00 |
water plants every monday | due Monday, and every Monday after |
water plants every monday and thursday at 18 | each Monday and Thursday, reminder at 18:00 |
pay rent every month on the 1st | due on the 1st, every month |
backup every 2 weeks until december | every other week, until the end of December |
vitamins every day! at 8 and 20 | a habit: every day, reminders at 08:00 and 20:00 |
stretch every weekday! at 10:30 from nov 2 | a habit on weekdays, from 2 November |
Times can be 18:00, 6pm or at 6, several with and; a time alone
is today’s, or tomorrow’s once it has gone by. The words are English for
now.
Repeats, habits and reminders
A todo repeats with every: and how often: day, weekday, week,
month, year, weekdays (monday or several, mon,thu), or a count
(2weeks, 3days). from: and until: say when it starts and stops;
without them it repeats until you change the line.
- [ ] pay rent every:month due:2026-11-01 remind:09:00 until:2027-06-30
- [ ] vitamins every:day! remind:08:00 remind:20:00
- stretch every:weekday remind:10:30 remind:15:00 from:2026-11-01
- A repeating todo is one thing to do at a time. Ticking it off brings the next one back under it, due on its next date after the one it was due on, so a missed one stays overdue until you catch up.
- A habit,
every:with a!after it, comes up on each of its days whatever happened the day before. Ticking it says it’s done for today (done:2026-10-18on the line); the box stays, for its next day. A habit is on the agenda each of its days until it’s done. - A reminder with a time alone,
remind:10:30, goes off on the line’s own days: a todo’s due date, each day the line repeats on, or every day on a line that says neither. Give a line as many as you like. - Notes from Obsidian’s Tasks plugin repeat too:
🔁 every week on Mondayisevery:monday, and🛫 2026-11-01isfrom:.
Looking back
Notes are only worth keeping if they come back. The home’s From before shows:
- what you wrote a week, a month and a year ago, from those days’ notes;
- Remember this?: a note you haven’t changed in a month or more, a different one each day;
- Waiting a while: todos without a date in notes untouched for three weeks or more, with their box and when, to do, date or drop.
Review the week (ctrl-space n w, space n w with Vim’s or Helix’s
keys) writes a note for the week, reviews/2026-W42, and opens it: what
you ticked off, what’s overdue, what’s coming in the next week, what has
waited, the inbox, and the notes you wrote. It’s written once a week, so
what you add to it, under Thoughts or anywhere, stays.
Ticking a todo off writes the day on it, done:2026-10-18, which is how
the review knows; unticking takes it away.
Lists that keep themselves: queries
A notes block in any note lists what its query finds, and keeps it
current as your notes change:
```notes
is:todo is:open due:..+7d sort:due
```
The query is the one Greed searches with everywhere: words, field:value,
- for not, OR for either, and ( ) to group.
| You write | It finds |
|---|---|
is:todo is:open due:..+7d sort:due | what’s due in the next week, soonest first |
is:overdue OR is:waiting | what’s late, and what has waited a long time |
is:todo in:(tag:garden) -is:done | open todos in notes tagged garden |
is:note tag:meeting date:2w.. | meetings in the last two weeks |
is:note has:(is:todo is:open) | notes with something still to do |
is:habit | your habits |
done:this-week | what you ticked off this week |
- What:
is:note,is:todo,is:heading. - Todos:
is:open,is:done,is:overdue,is:today(as the agenda’s Today has it),is:due-today,is:habit,is:recurring,is:waiting. - Fields:
title,note,tag(a todo has its note’s tags too),due,done,starts,until,every,date(front matter’sdate:, a day’s note’s day, or when a note last changed),modified, and your ownkey:: valuefields and front matter. A list in front matter matches each of its values, and a link by its note’s name:genre:sci-fifindsgenre: ["[[Sci-fi]]", Noir]. A field whose values are all dates is a date (read:<2023), as is one Obsidian’s property types call a date. - Where:
in:NAMEorin:(query)for what’s in a note,has:(query)for notes holding something. sort:due,sort:-date(newest first) andlimit:20say how to list them.
To tick a todo the block lists, open its table (enter on its top
border, or :data-open on the block) and enter on the todo: Tick or untick ticks it in its note, and Open goes to it.
A query with a mistake says what’s wrong where its results would be. The
agent can ask the same questions (notes_query), so “what’s overdue in my
garden notes?” gets the same answer.
Adding from anywhere
From any shell, without opening anything:
greed capture call the bank tomorrow 18:00
greed capture --note the plumber comes at noon
The first adds a todo to today’s note, read as above; --note adds a
line that isn’t a todo.
Templates
Each day’s note starts as templates/daily.md in your notes folder says,
when there is one. {{date}} becomes the date (2026-10-18), {{day}}
the day in words (Sunday 18 October), {{title}} the note’s name and
{{time}} the time:
# {{day}}
## Plans
## Notes
Each note in the templates folder is a kind of note you can start from,
named without its “Template”. With templates/Meeting Template.md holding
---
categories:
- "[[Meetings]]"
date: {{date}}
people: []
---
## Agenda
:notes-new (ctrl-space n n, space n n with Vim’s or Helix’s keys)
asks which kind (Meeting), then the name, and opens the new note filled
in. :notes-type (ctrl-space n y) in a note you have gives it the kind’s
fields it’s missing, with the template’s values, and leaves the ones it
has alone. Tagging a note with a kind’s name (#meeting, or meeting in
its tags:) does the same through a hint on that line: ⊕ Meeting: ctrl-. adds date, people (space a with Vim’s or Helix’s keys).
In front matter, typing a key at the start of a line lists the keys your
notes use, and after key: (or - under a key) the values they give
it, most used first.
Having the agent help
Write ? and a question in the box on the home page and press
alt-enter: Greed’s agent answers from your notes and links where each
part of the answer came from.
? when is the plumber coming
:notes-agent (ctrl-space n j, space n j with Vim’s or Helix’s
keys) picks other jobs for it:
| Job | What it does |
|---|---|
connect | Links the inbox (or the note you’re in) to your other notes, adds tags and context (ctrl-space n l) |
todos | Pulls the todos out of the note you’re in, a meeting’s say, under ## Todos |
ask | Answers a question from your notes (:notes-ask QUESTION) |
week | Sums up the week from what you wrote, in the week’s review |
The agent’s transcript opens beside you. Whatever it changes in a note you have comes to you as a proposed edit to accept or reject; it doesn’t delete anything.
connect and week can also run on their own, when you set a schedule
in your config:
greed.option.set("notes-agent-schedule", "week friday 16:00, connect weekdays 08:00")
The day is daily, weekdays or a weekday’s name. A run Greed was
closed for happens when it next starts that day, and a run with nothing
new to work on (an inbox unchanged since the last one) is skipped, so
the model isn’t asked for nothing. Hoard’s own session runs the schedule
and your reminders, whichever sessions you have open. It starts when you
first open Hoard or your notes; to have reminders and scheduled runs from
the moment Greed starts, start it with Greed:
greed.option.set("services-at-start", "hoard")
What a scheduled run changes waits for your review like any other.
Where your notes are
Your notes are plain text files (Markdown) in a folder, ~/notes unless
you set another:
greed.option.set("notes-folder", "~/Documents/notes")
Nothing is kept anywhere else, so the folder works with git, Syncthing or any other program, and stays readable without Greed. Notes changed by other programs show up within a few seconds.
The notes section of Using Greed has the rest: keys for notes in the editor, reminders, notes in projects and agents working with your notes.
Several clients on one session
Any number of terminals and windows can show one session at once: run
greed or greed attach in a second terminal, greed --gui for a window,
or greed ssh HOST from another machine. Each is a client of the session.
They edit the same buffers, with one undo history per buffer, and each has
its own cursors.
greed notes.md # in one terminal: starts the session
greed attach # in another: shows the same session
greed ssh desk notes.md # from a laptop: the session on desk
What each client has
Each client keeps these to itself:
- its cursors and selections, and where each view is scrolled;
- the view it has focused, and its mode and half-typed keys;
- pane zoom (
:pane-zoom), even while it follows the others; - pickers, prompts, the command line, completion and hover: they show only on the client that opened them, and only its keys reach them;
., which repeats that client’s own last change, and macro recording;- the font size of a window:
ctrl-=andctrl--zoom the window you type them in,ctrl-0puts it back, and settinggui-font-sizesets it for every window again; - copies, which go to the system clipboard of the client that copied.
Buffers, their undo history, the clipboard history, projects and options are shared. Desktop notifications go to the client you used last.
Following, or laid out on its own
A client that attaches follows the others: it shows the same project, the same tab and the same panes, with its own focus and zoom. When one opens a tab, switches project or splits a pane, the others show that too.
Another client never moves you while what you’re in still shows: you can go on typing in a file or a terminal while someone splits a pane or opens a panel. When what you had focused goes out of sight (another tab or project is shown, or the pane closes), you move to the shown tab’s active pane, what you had typed halfway is dropped, and you’re back in normal mode there, so keys meant for a terminal never land in a file.
| Command | |
|---|---|
:client-independent | Give this client a layout of its own. It starts from a copy of what it showed (the same tabs, panes, panels and the tab’s floating terminals, as new views of the same buffers, scrolled and selected the same); from then on its tabs, panes and project change apart from the others’ |
:client-follow | Follow the others again. The panes it had on its own close, their buffers stay open, and you go on in the file you were in, in the pane the others show it in |
Both say what they did at the bottom.
Floats keep their place and size in proportion on screens of different sizes: a float in the middle of a big window is in the middle of a small terminal too. A tab’s floats, like floating terminals, are shown to every client showing that tab.
Seeing each other
Each client’s cursors and selections show for the others in a color of
its own, one of six: client color N uses ui.cursor.peer.N and
ui.selection.peer.N, which fall back to ui.cursor and ui.selection.
The built-in themes give each a color of their palette. A client laid out
on its own shows its cursors where it works, in a view of the same buffer.
Terminals
A program in a terminal pane has one screen size. It’s the size of the
client that last typed into the terminal, pasted into it or focused it,
and a terminal window resizing changes it only for that client, so two
clients never fight over it. The others see the program’s screen as it is:
a terminal crops it to the rows around the program’s cursor (or its bottom
rows), and where it’s smaller than the pane, shows a note like
80×24 for tui@laptop in the room left over; a window scales it to fit.
Typing into it from another client sizes it for that one.
Image files and PDFs fit the width of the client that opened them or last focused them, in the same way.
Leaving and coming back
:detach (or closing the terminal) lets one client go and leaves the
others attached. A client is known by its kind and machine, like
tui@laptop or gui@desk, with a number when there are two of a kind on
one machine (tui@laptop#2). One coming back by the same name gets its
cursors, focus, mode and layout back: it takes the first name no attached
client has, so the second terminal on a laptop to come back gets what
tui@laptop#2 had. A new one follows the others and starts where the
last-used client is.
:quit-session ends the session for every client, whatever runs in it,
unless files have unsaved changes (:quit-session! ends it anyway).
From a shell, greed ctl quit NAME ends it unless files have unsaved
changes (--force ends it anyway); it works on a session of another
Greed version too, as after an upgrade.
For plugins
Code always acts for one client: the one whose key, click or menu ran a command, or the one an event is about.
| API | |
|---|---|
ctx.client, greed.client.id() | Which client is acting |
greed.client.current() | Its name, kind, size and layout |
greed.client.list() | Every attached client |
greed.client.set_layout("independent" | "follow", id?) | What the two commands above use |
greed.client.set_status_line(shown, id?) | Hides or shows one client’s status line, as slides do while you present; hidden, it still shows while there’s a message, like a question |
greed.option.set(name, value, { client = true }) | A value of its own for the acting client |
buffer:set_screen_size | Lays a buffer out at one size in every view, as terminals do |
State a plugin keeps for what a client has open, like a picker, belongs in
a table keyed by greed.client.id(). A float is shown only to the client
it opened for unless its spec says shared = true; sizes and places like
"37.5%" keep it in proportion on every client. Writing plugins
has more.
A client that attaches over the session socket can ask to be laid out on
its own with "layout": "independent" in its attach request.
Sessions, machines and the hub
Greed keeps track of what runs in every session on every machine you use,
so the status line can say ◆ 1 waiting for you in api on eris and one
key takes you there. This page explains how: sessions, the hub that
follows them on each machine, and how machines follow each other.
Sessions and clients
A session is a Greed running in the background, normally one per project,
named after its folder. What you look at is a client attached to it: a
terminal, a window (greed --gui), or a terminal on another machine over
greed ssh. A client always attaches to one session.
greed ls # the sessions on this machine
greed # in a project: attach to its session, or start it
greed ssh eris # a session on eris, shown here
Sessions are kept apart on purpose: a stuck plugin or a hungry language server in one project leaves the others alone.
Chat, mail and Hoard keep their accounts and notes in a session of their
own too, a service’s session: chat.service, mail.service,
hoard.service. You never start one yourself; greed chat, :chat and the
like start it when it’s needed. They work from a folder of their own, so a
project folder called chat gets its own session as usual. greed ls and
space P mark them as services, and greed attach or greed ctl without
a name leave them out when they look for the only session running.
Nothing runs in the background unless you ask for it, since plenty of people won’t use mail or chat at all. If you want mail syncing, Hoard’s reminders or chat’s accounts going from the moment Greed starts, name them. Like this:
greed.option.set("services-at-start", "mail hoard chat")
Each one still waits until it’s set up, so mail won’t start without a
mail.toml.
The hub: one session follows the others
Each session wants to know what the others are doing: which agents wait for you, which finished, what failed. Rather than every session watching every other, one session on each machine does it for all of them: the hub.
- The hub follows every other session on the machine and gathers what they report.
- The other sessions follow only the hub: each has one connection to it, rather than one to every other session.
- The hub decides what to tell you, so a waiting agent gives one desktop notification, not one per session. It remembers what it told you, so a restart doesn’t tell you again.
The hub isn’t a separate program. It’s a role one of your sessions takes, and every session works out which one by the same rule:
- the session the
hub-sessionoption names, if it runs; - otherwise the first by name of the running sessions of the same greed build.
A service’s session is never the hub, even named: a stuck chat service shouldn’t take everything else down with it.
Every session looks at the running sessions every few seconds and applies that rule, so they agree without asking each other. When the hub ends, the next one by name becomes the hub within seconds. There’s nothing to start and nothing to set up.
Sessions of another build (say, after you rebuilt greed while they ran) have a hub of their own until they’re restarted.
To keep the hub in one place, for example a session you never quit:
greed.option.set("hub-session", "dotfiles")
Other machines
Once you’ve used greed ssh eris, this machine’s hub follows the hub on
eris, and eris’s agents show up here: on the status line, in space i A
(:machine), and in desktop notifications. enter on one opens that
session as greed ssh eris would.
| Follow a machine | greed ssh HOST once; it’s followed for two weeks after you last did |
| Follow one you never ssh to | greed.option.set("hub-hosts", "mini eris") |
| Stop following one | :machine-forget |
Following uses your ssh keys or agent and never asks for a password or a new host key. A machine that’s off is tried again after a minute, then less often, at most every half hour.
No hub is in charge. Each machine’s hub follows the machines you point it at, and what they know comes along: if your laptop follows eris and eris follows mini, the laptop sees mini too. Each report says which machine it’s about, and the newest wins, so when two machines follow each other nothing is counted twice: you still get one notification per waiting agent.
Over greed ssh
With greed ssh eris, your terminal talks straight to the session on
eris. Your own machine’s hub isn’t in between.
Two things connect the machines:
- Your terminal also asks your own machine’s hub what’s going on at home,
and passes the answer to the session on eris. That’s how
space i Aon eris lists your laptop’s agents, andenteron one comes back. It’s read only: nothing on your laptop can be done from eris through it. - Separately, your laptop’s hub follows eris’s hub, so eris’s agents show at home even when no terminal is open there.
What the hub is used for
Agents waiting for you, notifications, and the list of agents across sessions and machines (Agents has the details).
The shell
:shell opens a shell in a buffer; greed --shell starts Greed in one.
Type a command at the prompt and enter runs it. It becomes a block above
the prompt: the command, what it printed and how it ended. Blocks stay, so
you can search, fold, copy and rerun them, and send their output to the
next command. For a long interactive session, use a terminal pane.
❯ 1 cargo test -q ✗ exit 101 · 4.1s
error[E0308]: mismatched types
--> src/main.rs:12:5
❯ 2 git status --short ✓ 0.02s
M src/main.rs
⎇ main ~/s/app ❯ |
The prompt shows the shell’s folder (every folder but the last cut to its first letter), and before it what the prompt knows, like the git branch.
space o s | Switch to this project’s shell, or open one; with several, or from the only one, list them with a new one to open |
:shell NAME | Open another shell |
:!cargo test | From anywhere, run a line in this project’s shell (opening one if there’s none); its output stays there as a block |
Each shell has its own folder and variables, and a project can have
several. Shells and their blocks last until you close them or the session
ends. There’s nothing to save, so :q doesn’t ask about them.
A new shell says to type help, which lists what the shell runs itself,
what a line can hold, which shell runs the rest, and the keys in your
style; help TOPIC shows one part (builtins, line, tables, prompt
or keys).
The prompt
⎇ main ⎈ prod-eu:payments ~/s/infra ❯ kubectl get pods
Before the folder, the prompt shows:
- the branch of the repository the shell is in (with jj, the nearest bookmark and the change)
- the kubernetes context and namespace
kubectlwould use (from thekubernetesplugin), read from the config filesKUBECONFIGnames or~/.kube/configwithout running kubectl, so it costs nothing ❄ devenvin a project with a devenv environment (see Project environments)
They’re worked out again after every command, so a cd, a checkout or
kubectl config use-context shows on the next prompt. Plugins can add
pieces of their own, a cloud profile say; help prompt lists what’s
there.
A context matching a pattern in shell-production-contexts (prod by
default; several go with spaces between them, as Luau patterns, like
:set shell-production-contexts "prod ^live%-") shows in red, and so
does the ❯.
space o k (:kube-context) | Switch the context, from those your kubeconfig has with their namespaces, the current and production ones marked. A click on the context in the prompt does the same |
space o K (:kube-namespace) | Switch the namespace, from those the cluster has |
enter in either list | Switch everywhere, as kubectl config use-context does |
ctrl-s in either list | Switch only in this shell, which then reads a small kubeconfig of its own ahead of yours; other shells and terminals keep theirs (prod in one shell, staging in the next) |
:kube-context NAME | Switch to one directly; :kube-context! NAME only in this shell |
:kube-namespace NAME | The same for the namespace; :kube-namespace! NAME only in this shell |
Each piece has a color of its own from the theme (shell.segment.git,
shell.segment.kubernetes, shell.segment.environment). With a Nerd Font,
:set shell-icons nerd uses its icons in place of ⎇ ⎈ ❄.
With starship, :set shell-prompt starship shows
your starship prompt instead, with its colors. Greed runs starship prompt after each command with the shell’s folder, variables, the last
exit code and how long it took. The ❯ stays Greed’s own (red in
production), so starship’s prompt character is left out. In your config:
greed.option.set("shell-prompt", "starship")
Blocks
A block starts with its command, ❯ before it (◆ for one an agent ran)
and its number, the 3 of $3. After the command come how it went, how
long it took, where cd went and which variables it set:
◐ | Running, with how long so far |
✓ | Done |
✗ exit 1 | Failed, with its exit code |
■ INT | Stopped |
↗ | Handed to a terminal |
? | A question to a model that brought no command back |
A block that went quiet while it could be reading a line says it may be waiting for input. One that has printed nothing after a second says so where its output will go, so a slow command (kubectl reaching a far cluster) shows it’s at work.
Output that’s JSON or a table is kept as a value on the block too, and
the status says so (JSON · 3 items, table · 12 rows); see Filtering
and tables. Places in files the output names, like
src/main.rs:12:5, are links: ] e and [ e go to them, and enter on
one opens the file there, taking relative paths from the folder the block
ran in.
A block shows at most shell-max-lines (5000) lines of its output, the
first half and the latest half, saying how many it leaves out between them;
space v opens all of it in a buffer of its own. Past shell-max-record
(8 MB) the whole output goes to a file in the cache folder, which space v
opens.
A prompt of more than shell-confirm-lines (5) lines, as pasting a
transcript or a file can leave there, asks y/n before it runs as one
command.
Everything above the prompt is read-only: you can select and copy it, but not change it. Typing or pasting there, in any style and with or without blocks mode, goes to the end of the prompt, and backspace at the prompt’s start deletes nothing.
Undo at the prompt takes back what you typed since the last command ran, even while output streams in above it; it never reaches into a command that ran.
Moving between commands
esc at the prompt goes to blocks mode (BLOCKS on the status line),
where the commands you ran and the rows they printed are things to move
between and act on, a key each. It takes the place of your style’s normal
mode, so coming back to a shell from a file you opened lands here, and so
does clicking in a command’s output. The selected command or row is
marked, with its keys on a line under it:
❯ 2 df -kP ✓ 0.04s · table · 13 rows
enter change · r run again · / filter · . actions · ↓ rows · J K commands · esc prompt
Filesystem 1024-blocks Used Available Capacity Mounted on
| Key | |
|---|---|
up down (k j) | A step through everything you can act on, in order: a command, the rows it printed (a table’s rows, like pods or files, or the files and lines it names), the next command, and last the commands still running on the strip above the prompt, where enter watches one and s stops it. Other text is passed over; o opens it to read and search |
J K (ctrl-down ctrl-up) | The next or previous command, past its rows |
right left (l h) | Into the command’s rows, or back up to the command |
enter | On a command, put it at the prompt to change: running it then runs it again in its place (↻ 2 before the prompt says so; empty the prompt to run something new instead). On a row, what the row does: open the file and line it names, describe the pod |
r | Run the command again in its place |
b d | What it showed the run before, or what changed since then, - then and + now |
/ | Keep the rows with what you type |
. | What can be done with it, or with the row |
y Y | Copy what it printed, or the command |
o | Open what it printed in a buffer of its own, to edit or search |
v | Show it in a pane beside, following it while it runs, to filter there on its own |
p | Its JSON lines readably, or as they came (see JSON lines) |
s ctrl-c | Stop it |
ctrl-t | Type into its program, in a terminal in the shell’s place |
ctrl-r | Pick a command typed before, in any shell |
tab shift-tab | Fold it under its command or unfold it, or all of them |
: | The command line |
? | These keys |
g G | The first or last command |
esc i a | Back to the prompt |
Typing a character goes back to the prompt with it, and keys with nothing
on them do nothing, so you never type into a command’s output. space and
its keys work as elsewhere.
:set shell-blocks false goes back to moving about the shell as text, with
esc going to your style’s own normal mode and the keys under
Keys.
Drilling down
What an action on a row runs comes up where you are, as k9s shows it: enter
on a pod, or . and “logs”, opens what it ran in a float over the shell,
titled with the way there:
❯ 1 pods › victoria-logs-collector-5c9b6 › describe
Acting on a row in that float goes a level further down in its place, and
esc goes back up one, to the row you were on. Every command still lands
in the shell too, in the order it ran, so it’s there to read again,
filter, or pin to a board. This works for every kind of row with actions,
not only pods.
A command that keeps running, like following a pod’s logs, stops when you
go back up from the float it was started to show. ctrl-z goes back up
and leaves it running instead, on the strip above the prompt, as ctrl-z
puts a job in the background in a shell. The float’s footer says which
key does what.
/ in the float filters what it shows, as you type. The shell keeps every
line, lines still to come are filtered as they arrive, and changing the
filter shows the lines it hid. To watch the same log two ways, v on the
block in blocks mode (or “open beside” in its actions) opens it in a pane
beside, as many times as you like, each with its own / filter.
A float showing a block, like the one enter on a running block opens,
keeps its own keys: esc closes it.
Keys
In Helix and Vim you type at the prompt in insert mode. With
shell-blocks off, enter on a block, the keys for moving between blocks
and files, g o and the space keys work in normal mode; up, down,
alt-enter and tab work while typing.
| Keys | |
|---|---|
enter | At the prompt, run what’s there. On a running block’s line above the prompt, open the block in a float. On a block, put its command at the prompt to change; on a file and line it names, open it there; on a row that’s a thing (a file, a pod), do its usual action |
alt-enter | Another line at the prompt |
up down | At the prompt: the commands typed before that start with what’s typed |
ctrl-r | Pick a command typed before, in any shell |
right end ctrl-e | At the end of the prompt, take the rest of the command it suggests |
tab | Complete a program, its arguments and flags, a file or folder, a variable, $3, buf: or @sel: the only match or what they all start with at once, else a menu, which tab again goes through |
ctrl-c | Interrupt the running block |
ctrl-t | Type into the running block’s program, in a terminal in the shell’s place |
[ p ] p | The block before or after the cursor |
g o | Select the block’s output |
] e [ e | The next or previous file and line the output names |
space r space R | Run the block again as it ran, or in the shell’s folder now |
space C | Change the block’s command and run it in the block’s place |
space y space Y | Copy the block’s output, or its command |
space x | Stop the running block for good |
space v | Open the block’s whole output in a buffer |
space c | Take the finished blocks away |
/ | On a block’s output, keep the lines (or a table’s rows) with what you type; elsewhere, search |
space s space S | Sort a table by the column under the cursor; show a block as it came |
tab shift-tab | On a block, fold it under its command or unfold it; fold or unfold every block (see Folding blocks) |
In the vscode style you’re always typing, so the keys that need normal mode have others:
| Keys | |
|---|---|
ctrl-c | Copy when something is selected, else interrupt |
ctrl-up ctrl-down | Between blocks |
f8 shift-f8 | Between the files and lines the output names |
ctrl-f | Filter a block |
ctrl-k ctrl-l | Fold or unfold a block; ctrl-k ctrl-0 folds them all, ctrl-k ctrl-j unfolds them all |
ctrl-space | In place of space for the keys above |
space . (alt-. in the vscode style) on a block, or on a row that’s a
thing (see Rows you can act on), lists what you
can do with it.
Folding blocks
A folded block shows only its command line, with how it ended and how many
lines it hides (⋯ 240 lines). tab on a block folds or unfolds it, and shift-tab folds or
unfolds them all. In what a command printed, tab folds the lines indented
under the line instead, a section of YAML or of kubectl describe. A block
that’s still printing stays folded as its output grows.
JSON or YAML of more than shell-fold-structured lines (100) shows its
top keys folded as it ends, metadata: ⋯ 24 lines, and inside a fold
that long, the keys under it, so kubectl get pods -o json opens to its
items, each one folded. :set shell-fold-structured 0 shows it all.
Resting the mouse on a folded block shows it in a float without moving the
cursor: scroll it there, or click into it to filter it with / and act on
its rows. Moving the mouse away closes it.
Blocks can fold by themselves. Blocks that failed never do, since those are the ones to read again:
local greed = require("@greed")
-- Fold a block that printed more than 40 lines as it ends.
greed.option.set("shell-fold-lines", 40)
-- Running a command folds the finished blocks above it.
greed.option.set("shell-fold-older", true)
What runs your commands
The shell runs a few commands itself:
| Command | |
|---|---|
cd [DIR] | Change the shell’s folder: a path, - for the one before, nothing for home |
export NAME=VALUE ... | Set variables for the commands after |
unset NAME ... | Leave variables out of the commands after |
env [reload] | List the variables this shell sets or leaves out, and the environment its folder brings (devenv, direnv); reload loads that again |
history | The commands typed before |
clear | Take the finished blocks away |
open PATH ... | Open files, or buf:NAME buffers, in the editor |
help [TOPIC] | What works here, and the keys in the style you use; a topic for one part |
which NAME ... | What a word at the start of a line runs: a builtin, a table stage, one of your aliases or a program |
stop [N ... | all] | Stop running blocks by their number, or all of them; without one, list them |
watch [-n SECONDS] COMMAND | Run a command again and again, every two seconds, its block showing what it printed last with the changes marked |
prom QUERY [--range DURATION] [--step DURATION] [--url URL] | Ask Prometheus: a row a series as it is now, or over a range a row a time, to table or chart |
data SOURCE [KEY=VALUE...] [QUERY] | Read a table from a data source: csv, sqlite, psql (see “Databases and files” below) |
What open opens comes up in your style’s own mode, to read and move
around in, not typing as at the prompt. Plugins add commands of their own
(Writing plugins), and help builtins lists them
with these.
Every other line goes to your shell, so ls and ls | head behave the
same. That’s your $SHELL when it’s a POSIX shell (sh, bash, zsh, dash,
ksh and the like), fish or nu, and sh otherwise; :set shell-fallback bash picks one. cd and export there carry over to the commands after,
as in a terminal. If shell-fallback names a shell of another kind, the
line still runs in it, and its block says cd and export in it don’t
carry over. Startup files aren’t read for each line, so your shell’s
functions are missing unless you :set shell-fallback-rc true.
With nu, a table a line gives back (ls, ps, open data.csv | where size > 10) is data in the block as well as drawn by nu: its rows are
things like any table’s (see Rows you can act on),
and the stages work on it with its real values: sizes in bytes, dates
in full. Its first 10000 rows are kept that way. nu numbers each row so
the shell knows which line is which.
Your aliases work too. The shell asks your shell for them once, with its startup files, and a line starting with one runs what it stands for; the block shows what you typed.
- The shell’s own commands win over an alias of the same name.
^NAMEruns the programNAMEwhatever else has that name (^env, or$3 | ^sortfor thesortprogram rather than the table stage).which NAMEsays what runs.:set shell-aliases falseleaves aliases alone.
As in bash and zsh, !! in a line is the command before, !$ its last
word, and a line ^old^new runs the command before with old changed to
new. The block shows the command as it ran.
Programs get these variables:
PAGER=cat, GIT_PAGER=cat | So their output comes back as text |
GREED_BIN | The greed program running the editor |
GREED_SESSION | The session’s name |
GREED_BLOCK | The block they run in |
Editing files from a command
A program that opens an editor, like git commit, jj describe, kubectl edit or crontab -e, opens the file in Greed, in the pane the command
ran from. :wq (or :q once it’s saved) hands it back and the shell shows
there again; :cq stops the program with an error, so git commit gives
up. EDITOR, VISUAL, GIT_EDITOR, JJ_EDITOR and KUBE_EDITOR are
greed edit --wait, so this wins over an editor set in git’s or jj’s
config. An agent’s commands keep your own editor, and :set shell-editor false turns it off; export EDITOR=vim in a shell picks another for that
shell.
greed edit FILE... works from any terminal too: it opens the files in
the running editor, and with --wait returns once each is done with.
Project environments
In a folder with a devenv.nix, the shell loads devenv’s environment, as
devenv shell would, and its commands run with it: the project’s tools on
the PATH, its variables, and what enterShell sets up. No direnv is
needed, and devenv’s own rule applies: a project loads once you’ve run
devenv allow there. The prompt says it’s there, ❄ devenv, with …
while it loads (a command typed meanwhile waits for it, its status saying
loading devenv, and ctrl-c runs it without), or that it failed, which
env says more about. A block’s time counts from when its program starts,
so the wait isn’t in it.
Changing devenv.nix, devenv.yaml, devenv.lock or anything else devenv
read loads it again; env reload does too. Leaving the project leaves its
environment behind, and what you export wins over it. Every shell in a
project shares one load, and an agent’s commands get it too.
A folder with an .envrc and no devenv.nix loads it through
direnv, when that’s installed and you’ve run direnv allow there, the prompt saying ❄ direnv. Changing the .envrc loads it
again; for other files it reads, env reload does. A project with both,
like an .envrc holding use devenv, gets devenv’s straight away.
shell-environments (devenv direnv) says which kinds load and which
is asked first; :set shell-environments "" turns them off. Plugins add
other kinds.
Terminals
Commands you type run in a pseudo terminal of their own, so they see a terminal: they print their colors and progress bars, and their output and errors come in order. A line longer than the screen stays one line in the buffer, so each client shows it wrapped at its own width.
A program that wants the whole terminal (an editor, a pager, htop,
ssh, sudo asking for a password) takes over the shell’s pane as a
terminal, and the shell comes back when it’s done with the screen or
exits, its block marked ↗. ctrl-t does the same for any running block,
to answer a question it’s waiting on. Start a line with ! to run it in a
terminal from the start.
Data from the editor
A line can start with something from the editor, piped into the command:
$3 | sort | What block 3 printed |
buf:NAME | wc -l | The text of a buffer: one > buf: made, an open file at that path, or an open file of that name |
@sel | jq . | The selection in the file you’re in, each range on a line of its own |
@file | head | The whole file you’re in, unsaved changes included |
And end with where its output goes:
... > buf:NAME | Into a buffer, made if there’s none, emptied first |
... >> buf:NAME | Added to the end of a buffer |
The buffer opens in a split beside the shell as the command runs, unless
it shows already, and you go on typing at the prompt. Errors still show
in the block. One of these alone passes it on: $3 shows block 3’s
output again, and $3 > buf:keep keeps it in a buffer. Later, open buf:keep shows that buffer again, and space b lists it as buf:keep
beside your open files. Such lines run through a pipe rather than a
terminal, so a > buf: gets only what the program printed, and can’t be
combined with !.
After a command’s first word, $3 is a file holding what block 3
printed, for programs that read files rather than their input:
❯ diff $3 $5
❯ kubectl apply -f $7
❯ open $3
The file ends .json when the block printed JSON. Single quotes keep
$3 as it is (awk '{print $3}'), and so does \$3.
Filtering and tables
Most output is text, and stays text. On top of it the shell keeps what it can read out of it, and every layer below works on what’s under it.
Filtering a block
/ on a block’s output keeps the lines with what you type in them, as you
type:
- Several words keep the lines with all of them, minding neither case
nor accents:
cafekeepsCafé.shell-filter-search-casesays when case matters, and then accents do too. -wordleaves out the lines with it,error OR warnkeeps lines with either (ORin capitals), and"connection refused"is a phrase.- A filter that starts with
/is a regex (/^error|warn). enterkeeps the filter.esc, while typing it or after in normal mode on the block, shows every line again;space Salso undoes a sort.
The status shows what’s kept (2 of 340 lines · / error), and so does the
prompt as you type. The block’s record keeps every line, so $3, space y and space v give the whole output. On a block’s command or at the
prompt, / searches as usual.
These words look at the structure of what’s printed:
key=value | In a line of JSON, as many logs are, or logfmt (level=info msg=ready), its field key is value: level=error, HelmRelease.name=vikunja (a dotted path, looking through arrays). In other lines, the word itself in the text |
key~value | Its field key has value in it: msg~timeout; !~ keeps the lines where it doesn’t |
key>=value | >, >=, <, <= compare as a table’s where does: levels in their order (level>=warn keeps warnings and errors), numbers as numbers with sizes and durations (took>500, took>1.5s, mem>512Mi); != keeps the lines where it isn’t, or that have no such field |
.key.key | The section of indented text under those keys, with the keys above it: .status.conditions of kubectl get pod -o yaml, .conditions of kubectl describe. The keys can be anywhere in the path, and the last matches by its start, so the section shows as you type it |
/.conditions ready keeps the lines of that section with “ready” in them,
and the keys they’re under. tab while typing a filter completes from what
the block printed: its sections, its JSON lines’ fields and its table’s
columns, each field with a few values it has. A readable log line leaves
the names of its time, level and message out, so tab on an empty filter
is where to see whether a log calls it level or severity. up and
down there go through the filters used before on the same kind of
command, like kubectl logs. The filter is shown in colours as you type
it, and a mistake (a quote or a regex not closed) is underlined, with what’s
wrong said after it.
In a float or a pane showing one block, / filters that view alone, the
same way (words, or / and a regex), while the shell and other views of
the block show every line. Lines that come in later are filtered too, and
since nothing is thrown away, changing the filter shows earlier lines it
hid. esc on the filter prompt shows them all again.
JSON lines
Output whose lines are JSON objects or logfmt (level=info msg="ready"),
as many programs log, shows each line with its time, level and message
first and the other fields after it, dimmed, nested ones as
HelmRelease.name=vikunja. A time with its zone, like kubernetes’ UTC
2026-10-12T11:58:12Z, shows as the time here:
11:58:12 error release failed: timed out waiting HelmRelease.name=vikunja controller=helmrelease
The record keeps each line as it came, so /level=error, copying and
$3 see the JSON. p in blocks mode, or
“readable or as it came” among a block’s actions, switches between the two;
:set shell-json-lines raw shows them as they came from the start.
Tables
Output in columns under a header, as kubectl get, docker ps, ps aux
and df print it, is also kept as a table on the block, and the status
says so (table · 12 rows). So is ls -l’s output. The shell looks for a
header in capitals with the columns lined up under it in every row, and
when it isn’t sure, the output is text: prose is never taken for a table.
A table’s lines don’t wrap: one wider than the view goes on past its
right edge, where › marks it. The view scrolls sideways when the cursor
goes there (or with the wheel sideways, shift and the wheel in most
terminals), ‹ marking what’s gone off the left. Other output wraps as
text does.
A table the shell draws itself (after a stage, a filter or a sort) shows
its values as people read them: sizes in bytes as 142.6 kB, dates as
3 h ago (or the date, past a week), nested JSON as {4 fields} or
[12 items], numbers lined up on the right, and a cell wider than 48
columns cut with …. The values stay as they were, so sort size sorts
by bytes, and space h i on a row shows them whole.
A table’s header is set apart, and in a column saying how things are
doing (STATUS, STATE, PHASE, READY) Running or Completed
shows green, Error or CrashLoopBackOff red and Pending yellow, as
does READY short of all (0/1); <none> and nested JSON show faint.
The colors are the theme’s shell.table.header, .good, .bad,
.warn and .dim. A table nu drew keeps nu’s own colors.
In a table, / keeps rows: a word like STATUS=Running or NAME~api
looks in one column, RESTARTS>0 and AGE<1h compare numbers, and other
words look in every cell. space s sorts the rows by the column under
the cursor, again from the greatest, and a third time as they came.
❯ 3 kubectl get pods ✓ 0.41s · 2 of 5 rows · / STATUS=Running api
NAME READY STATUS RESTARTS AGE
api-7d9f8b6c5-2xkqz 1/1 Running 0 3d16h
api-7d9f8b6c5-9wlmn 1/1 Running 3 (3d16h ago) 5d2h
A table also goes to the next command through $, where the shell itself
runs these on it, each making a new table, as in $3 | where STATUS = Running:
where COL OP VALUE | The rows passing tests: = != ~ !~ < > <= >=, with OR and - |
select COL,... | Only those columns, in that order |
sort COL [-r] | Sorted by a column, from the greatest with -r |
- Column names don’t mind case, and
container_idnamesCONTAINER ID. - Numbers compare as numbers, with sizes (
512Mi,1.5G,250mof a CPU), percentages and ages (45s,12m,3d16h) read as what they mean, so$3 | where AGE < 1hand$3 | sort RESTARTSwork. kubectl’s3 (3d16h ago)restarts count as 3. - Log levels compare in their order, other text without minding case:
=and!=the whole value,~and!~text in it. - A filter’s fields (
/level>=warn) compare the same way.
Stages chain, and a program after them reads the table as text:
❯ $1 | where STATUS != Running | select NAME,STATUS,AGE
❯ $1 | sort RESTARTS -r | where RESTARTS > 0 | wc -l
❯ $1 | where IMAGE ~ postgres > buf:databases
sort without a column, or with a flag, is the sort program, as always.
They work after a program too, in one line: what it prints is read as a table, as a block’s output is, and the stages run on that.
❯ kubectl get pods | where STATUS != Running | select NAME,AGE
❯ docker ps --format json | where Image ~ postgres
❯ $1 | grep api | where RESTARTS > 0
where, select, get, columns, from, lines, filter, map,
count, group, first, to and each start the stages after a
program, since no program goes by those names. sort, split, uniq,
sum and last are programs too: after a program they’re the stages
when given something that isn’t a flag (ls | sort size -r, ls | last 2), and the programs otherwise (sort, sort -n); ^sort is always
the program.
Only what comes out at the end shows, with the program’s errors. A stage on output that isn’t a table says so, and what makes one.
Some programs are asked for JSON when stages follow them, so the stages
read their data rather than columns on screen: kubectl get gets -o json, docker ps and docker stats --no-stream get --format json.
The table has the columns the program prints itself (READY, STATUS,
RESTARTS, CPU %), and the status says read as data with the line
that ran. A line asking for its own output (-o wide, --format) or
watching runs as typed, and when the JSON form fails (an old docker,
say) the line runs again as typed and its table is read instead.
More stages
filter EXPR | The rows a Luau expression holds for, with the row’s cells as r and its numbers as n |
map COL = EXPR | A column made (or changed) by a Luau expression on r and n |
count | How many rows there are |
first [N] | The first N rows, one without N |
last N | The last N rows |
uniq COL | The first row for each value in a column |
sum COL | The numbers in a column added up |
group COL | Each value in a column and how many rows have it |
to json|csv|tsv | The table as JSON, CSV or tab separated values |
each COMMAND | Run a command for every row, {COL} in it the row’s cell, quoted |
filter and map take Luau. In it, r is the row, its cells as text
(r.STATUS, r["CONTAINER ID"]), and n the cells that read as numbers,
sizes and ages included (n.RESTARTS, n.AGE in seconds). It runs in a
sandbox that can read the editor and nothing more, so a line an agent
wrote can’t do anything else either. A column that isn’t there says which
there are, and n.NAME of a cell that isn’t a number says to read it as text,
r.NAME. Fractions a map makes show to two places; the values stay as
they are.
❯ kubectl get pods | filter n.RESTARTS > 0 and r.STATUS ~= "Running"
❯ kubectl get pods | map hours = n.AGE / 3600 | sort hours -r | first 5
❯ kubectl get pods | group STATUS
❯ kubectl get pods | where STATUS = Evicted | each kubectl delete pod {NAME}
❯ docker ps | to csv > buf:containers.csv
each runs its command once for every row, with {COL} the row’s cell,
quoted for your shell; the commands run one after another in your shell
and print into the block. What comes after each is all the command, so
each echo {NAME} | wc -c counts each name.
Plugins add stages of their own (Writing plugins),
and help tables lists them all.
JSON
Output that’s JSON is kept as a value on the block (JSON · 3 items),
and an array of objects is a table too, with a column for each key, so
/ and space s show it lined up in columns, and $3 | where works on
it. Many tools print JSON when asked, which is the surest way to a table:
kubectl get pods -o json gives every field, where its columns give a
few. A command on its own runs as typed; the shell reads what it
printed.
The stages work on an object too: its fields are the columns of one row,
so $3 | select name gives its name, and when one of its fields holds an
array of objects, like kubectl’s items, the columns it doesn’t have are
that array’s. A dotted column reaches inside a column of objects, so
$3 | where status.phase = Failed | select metadata.name looks through
kubectl’s pods. get picks a field:
get PATH | A field of JSON, like items or items.0.name (arrays count from 0) |
$3 | get items is the items’ table, $3 | get items.0.name the first
one’s name, $3 | get metadata.labels an object, printed as JSON, and
$3 | get items.name each item’s name.
Saying what it is
When the shell finds no table, say how to read the output, as in $3 | from csv:
columns [-H] | Text lined up in columns, under a header or with -H none |
from csv|tsv|json | CSV, tab separated values, or JSON or JSON lines |
split SEP | Each line cut at SEP into columns 1, 2, … |
lines | A row for each line, in a column line |
parse 'PROGRAM' | A row for each match of a sikt program, its captures the columns |
columns -H names the columns 1, 2, …, as split does, and from json reads JSON lines too, an object on each line, as many logs are.
parse reads any text you can describe with a
sikt pattern,
a line at a time: literal text in quotes, name: for a column, until for
“up to”. The cells keep the text as printed, and where and sort read
sizes, durations and numbers in them as they do in any table:
❯ $4 | parse 'time: until " " " " level: 1+ upper " " msg: until text end' | where level = ERROR
❯ du -sh * | parse 'size: size 1+ space path: until text end' | sort size -r | first 5
❯ git log --oneline | parse 'hash: 7+ hex " " subject: until text end' | where subject ~ fix
A mistake in the program says what’s wrong and where.
They make tables like any other, for where, select and sort:
$3 | split : | where 7 ~ zsh | select 1. A buffer or the selection
works too: buf:data.csv | from csv | where total > 100. A program in a
terminal prints tabs as spaces, so tab separated output reads best from a
file, with buf:.
Commands read as tables
These commands’ output is read as a table though it has no header to go by, each line a row:
| Command | Columns |
|---|---|
free | kind, total, used, free, shared, cache, available |
ss | netid, state, recv, send, local, peer, process |
ip -br addr | name, state, addresses |
ip -br link | name, state, mac, flags |
mount | device, path, type, options |
uptime | time, up, users, load1, load5, load15 |
ping | host, seq, ttl, ms |
cargo test | name, result |
go test -v | result, name, took |
who | user, tty, since, from |
env, printenv | name, value |
git branch | mark, name, commit, subject |
git remote -v | name, url, use |
git stash list | stash, on, message |
So cargo test | where result = FAILED, ss -tlnp | where local ~ :5432
and free -h | select kind,available work as they do on any table.
git status, git log, jj st and jj log are read too, their rows
files, commits and changes you can act on.
Parsers from plugins
A plugin can read its commands’ output as tables, ahead of the shell’s own look and its own readers above (Writing plugins has how); a sikt program in your config does the same for a command of yours:
-- `git (2.46.0) < 2.47.0`
require("@shell").parser("^brew outdated", [[name: until " (" " (" have: until ")" ") < " latest: until text end]])
And when jc is installed, output
the shell found no table in, from a command jc knows (ifconfig, dig
and many more), gets jc’s reading of it.
Watching a command
watch COMMAND runs a command every two seconds (-n 5 for every five).
Its block shows what it printed last, with the lines that changed since
the run before marked. It stays a block among the others; ^watch runs
the watch program in a terminal.
❯ 7 watch kubectl get pods ◐ 1m12s · every 2s · 1 changed · 14:05:02
NAME READY STATUS RESTARTS AGE
api-7d9f8b6c5-2xkqz 1/1 Running 0 3d16h
worker-5c6b7d8f9-abcde 0/1 CrashLoopBackOff 13 2h
The table and its rows follow along: a / filter
or a space s sort stays on what each run shows, space . on a pod acts
on it as it is now, and $7 | where STATUS != Running reads
what it shows. The whole line is watched, pipes and table stages
included, so watch kubectl get pods | where RESTARTS > 0 shows only the
pods that restarted, as they are now.
ctrl-c or space x stops it, keeping what it showed last; it also stops by itself after
shell-watch-minutes (60), and space r starts it again. Agents can’t
watch, as a watch runs until someone stops it.
kubectl get pods -w needs no watch: kubectl prints a pod again each
time it changes, and the block shows each pod once, in its place, lined
up under the header, the ones that changed since they first showed
marked, rather than a longer and longer list. Its rows are pods to act
on, as any kubectl get block’s are. It ends when kubectl does, or with
ctrl-c.
space C on a block changes its command and runs it in the block’s
place: the same number, where it was, its floats still showing it, with
what it printed, its filter and its sort replaced. A watch or -w block
stays live, so one block can go from pods to deployments rather than the
shell filling up with them. On a kubectl get block, space . offers
“another resource” (the ones the cluster has, its custom resources too)
and “another namespace” (or all of them), which do the same with the
resource or namespace flags changed, as k9s’s views do:
❯ 7 kubectl get pods -n payments -w ◐ 2 changed · 14:05:02
↓ another resource: deployments
❯ 7 kubectl get deployments -n payments -w ◐ 0 changed · 14:05:09
Charts
| chart draws a table as a chart, in characters every terminal shows:
braille for lines, eighth blocks for bars, in the theme’s colours.
Charts has the rest: every option, a line for each thing,
Prometheus, dashboards, boards for Linux and macOS, and pitfalls.
❯ 4 kubectl top pods | chart
api-7d9f8b6c5-2xkqz ████████████▊ 0.25
worker-5c6b7d8f9-abcde ████████████████████████████████████████████ 1.2
redis-0 █▊ 0.035
ingest-6f7c-xyz ████████████████████████████████▌ 0.64
It guesses the chart from the columns:
| The table | The chart |
|---|---|
A name column and numbers (kubectl top pods) | Bars of the first number, a row each |
| A time column and numbers | A line a number column, over time; with a name column whose names come again (samples of several hosts), a line a name |
| Numbers only | A line a column, row by row; two columns are dots, one against the other |
Text that isn’t a table (cat /proc/loadavg) | Its words as columns, a first line without numbers as the header |
In the window (greed --gui) and in a terminal with kitty graphics
(kitty, Ghostty, WezTerm, Konsole) the chart is drawn as an image, smooth
lines and bars in the theme’s colours, with its labels and numbers still
text. :set scene-drawing cells keeps charts in characters everywhere,
and GREED_IMAGES=none in one terminal.
Numbers keep their unit (128Mi, 250m of a CPU, 45%) on the axis and
beside the bars.
Anything it guesses can be said, as in chart bar CPU MEMORY (both
columns, a bar each); Kinds of chart lists
every option (line, area, scatter, --stacked, --log, --width,
--height). A chart is as wide as the view and chart-height lines tall
(12). When it can’t draw one, it says why, naming the columns it found,
and chart --why shows how it read each column and why it picked the
chart it did.
In a watch every run adds a point, so the chart is of how the numbers
went: watch -n 2 kubectl top pods | chart draws a line a pod, of its
CPU, over the last 120 runs (--last keeps another number). A watch
drawing a chart doesn’t mark its lines changed, as they all do.
On a board, chart after a card’s language draws it as a
chart as big as the card.
Prometheus
prom QUERY asks a Prometheus server (prometheus-url,
http://localhost:9090 unless you set it, or --url) and gives a row a
series, named by its labels’ values, as a table to read or chart:
❯ prom 'sum by (job) (rate(http_requests_total[5m]))' | chart
api ███████████████████████████████████ 41.2
worker ████████▌ 9.8
--range 1h asks for the last hour instead, a row a time with a column a
series, which | chart draws as a line a series (--step 30s sets the
time between points). In a watch, watch -n 5 prom 'QUERY' | chart, each
run adds a point, so the chart moves as Prometheus’s numbers do; on a
board, a card with every=5 does the same.
Databases and files
data SOURCE reads a table from a data source, the same ones a Markdown
document’s data blocks use: csv (path=FILE), sqlite (db=FILE and a
query) and psql (db= a connection and a query). @name in a query is
the shell’s variable of that name, passed to the database as a parameter:
❯ export city=oslo
❯ data sqlite db=shop.db "SELECT name, total FROM customers WHERE city = @city"
❯ data csv path=sales.csv | where units > 10 | chart bar units
Its table keeps the source’s columns in order, so stages, charts, a watch
and a board’s cards work on it as on any command’s. Databases open
read-only unless you add write=true.
Running blocks above the prompt
A watch, or anything else still running, scrolls up out of sight as you run more commands. So every running block but the last gets a line just above the prompt, saying what it shows now (how many rows, for a table) and what changed in it last, or how long it has run:
❯ 9 git status --short ✓ 0.02s
M src/main.rs
◐ 7 watch kubectl get pods · 3 pods · api-7d9: STATUS Running → Error · 14:05
◐ 8 cargo build --release · 1m 12s
~/s/infra ❯
What changed names the row: new worker-abc, worker-abc gone, or the
first column that changed, with how many more rows did. Columns that
change by themselves, like AGE or the (5m ago) of RESTARTS, don’t
count, so a quiet watch stays quiet. To hear about changes while you’re
in another window, space . on the block (or its line) and “notify on
changes” (shell-notify): each change then sends a desktop notification
saying the same, while Greed isn’t focused. Again to stop.
Such a line stands for its block, a line or two up from the prompt:
| Key | |
|---|---|
ctrl-c space x | Stop that block rather than the latest |
space . | What you can do with it |
space r | Run it again |
enter, or a click on its number | Open the block in a float |
/ | Open it in a float to filter |
The float shows that block and nothing around it, and works as the block
does in the shell: enter or space . on a row acts on the pod or file
it is, and ctrl-c stops it. / filters what the float shows, leaving
the shell as it is (see Filtering a block). A
watch’s float follows it as it refreshes, and esc closes it. space .
on any block offers “open in a float” too. A line goes when its block
ends.
These floats stay while you work elsewhere, one for each block, so you
can keep several watches, logs and builds in sight at once: opening
another leaves the others open, and opening one again goes to it. They
are the tab’s floats, so alt-w lays them out (tiled, cascade, one
at a time), alt-{ and alt-} go between them and alt-f hides them
all and shows them again. The float the mouse opens resting on a folded
block is the only one that goes by itself, when the mouse moves away.
At the prompt, ctrl-c stops the latest running block and says which
others still run. stop lists them by number, stop 7 stops block 7,
and stop all stops them all.
From anywhere, even a file you’re editing, space o w lists what runs
in every shell, this project’s first, with each one’s output beside it:
enter opens it in a float, ctrl-o goes to it in its shell, and
ctrl-x stops it.
Rows you can act on
Some tables’ rows are things, and the status says so (table · 5 pods):
| Rows of | Are |
|---|---|
ls -l, or any table with a name and a type of file or dir (nu’s ls) | Files and folders |
ps on any system, or any table with a PID (lsof, docker top) | Processes |
kubectl get | Pods, deployments and other kubernetes objects (the kubernetes plugin) |
docker ps | Containers (the docker plugin) |
git status (short or long), jj st | Changed files: diff, open, restore, and with git stage and unstage (the vcs plugin) |
git log | Commits: show, checkout, cherry-pick, revert (the vcs plugin) |
jj log | Revisions: show, diff, new, edit, squash, abandon (the vcs plugin) |
The vcs plugin’s commands name the repository the block ran in.
On such a row, space . lists what you can do with it, the same actions
that kind of thing has anywhere in Greed, and enter does the usual one:
a file opens, a folder becomes the shell’s folder, a pod or another
kubernetes object is described, a container shows its logs. ctrl-o
(alt-left in the vscode style) comes back from a file you opened to the
row you opened it from.
A kind can put the columns its rows are known by first: docker ps shows
NAMES, IMAGE and STATUS first, so a narrow pane cuts COMMAND and
CONTAINER ID at its edge rather than the names. The block’s output, as
an agent reads it, stays what docker printed.
Rows a table stage kept are still what the command listed: after
kubectl get pods -A | where name ~ api, each row is still a pod, and so
after $3 | where name ~ api from block 3’s pods, in the cluster block 3
ran against.
| Kind | Actions |
|---|---|
| Pod | describe, logs, follow logs, events, yaml, json, delete, shell |
| File | open, float, split, rename, delete, diff (what changed since the last commit), reveal in tree, copy-path |
| Folder | cd, new shell here, grep here, rename, delete, reveal in tree |
| Process | stop, interrupt, hang up, kill, open files, its folder |
A pod’s shell opens a shell in it (bash if the image has it, else sh)
in a floating terminal, asking which container when it has several;
ctrl-d or exit ends it, and esc esc stops typing into it. A file’s
and folder’s actions are the same wherever one shows up, a path in any
buffer included.
Select several rows (x a few times in Helix, V in Vim, shift and the
arrows in the vscode style) and space . offers each action once for all
of them (describe 3 × pod: api-0, api-1, api-2), running it on each in
turn. One that deletes or stops asks once for all of them (see below).
watch on a row (or anything else, under space .) looks at it again
every watch-interval seconds (10), and at once when the plugin that owns
it says it changed. When it differs, a notification on the status line and
to your desktop says how:
worker-5c6b7d8f9-abcde: RESTARTS 12 → 13; STATUS Running → CrashLoopBackOff
A pod is looked at with kubectl get pods NAME, a container with docker ps, a process with ps -p, each run where its row came from. Once it’s
gone the notification says so and watching it stops. watch again stops
it, and :watches lists what’s watched, where enter stops one.
❯ 4 kubectl get pods ✓ 0.38s · table · 3 pods
NAME READY STATUS RESTARTS AGE
api-7d9f8b6c5-2xkqz 1/1 Running 0 3d16h
worker-5c6b7d8f9-abcde 0/1 CrashLoopBackOff 12 2h ← space .
describe · logs · follow logs · shell
yaml · json · events · delete
What an action does is a command, run as a block of its own, so you see it, can run it again and change it:
❯ 5 kubectl logs worker-5c6b7d8f9-abcde --tail 200 --context prod-eu -n payments
follow logs on a pod or a container opens its block in a float that
stays on the last line as lines come, like tail -f; move up to read and
it stays put, go back to the last line and it follows again. / there
filters the logs as they come. esc closes the float and stops following;
ctrl-z closes it and the logs keep coming in the line above the prompt,
where ctrl-c stops them. An action whose command still runs in the shell
doesn’t start a second one: it opens the one running (already running as $7).
A deployment’s logs and follow logs merge the logs of all its pods
(kubectl logs -l SELECTOR --prefix), and each line shows which pod it
came from as a field after its message, pod=api-1.
A row remembers where it came from. The kubernetes context and namespace
are the ones the command ran against, from its flags or else kubectl’s
config as it was when the block finished, so acting on a row of an old
block after kubectl config use-context still goes to that row’s
cluster, and the command says which. With -A, each row’s namespace is
its own. docker --context is kept the same way.
Actions that delete or stop something (delete, restart, killing a
process, stopping a container) ask first, and say so when the row is in
a context matching shell-production-contexts:
delete worker-5c6b7d8f9-abcde - in PRODUCTION (prod-eu)? y/n
For several at once, or for any an agent asks to run, a review lists each
with the command it runs, every one ticked: space unticks one, a
ticks or unticks them all, enter runs the ticked ones and esc none.
[x] delete worker-5c6b7d8f9-abcde kubectl delete pods worker-5c6b7d8f9-abcde --context prod-eu -n payments (in PRODUCTION (prod-eu))
[ ] delete api-7d9f8b6c5-2xkqz kubectl delete pods api-7d9f8b6c5-2xkqz --context prod-eu -n payments (in PRODUCTION (prod-eu))
shell on a pod or a container opens a shell in it in a terminal.
What the blocks above showed completes the next command. After kubectl get pods, kubectl logs <tab> offers those pods first, each saying which
block it’s from (pod · $4), then whatever kubectl itself offers; so do
exec, describe pod, delete deploy and rollout restart deployment
for theirs. Only rows from where the command goes are offered: the
context and namespace its flags name, or else kubectl’s config now.
docker logs <tab> offers the containers of a docker ps above, and
kill <tab> the processes of a ps.
Rows are objects too, so space h i on one shows its
cells, the block it’s in and its actions. A row of a known kind is named
by what it is: pod:prod-eu/payments/api-7d9f8b6c5-2xkqz, process:4711,
container:web, file:/home/me/notes.txt. The same pod in a newer block
is the same object, and the newest row is the one found; a kubernetes
object no block shows any more is still found by its id, by asking
kubectl whether it’s there. The rows of any
other table are plain rows of their block (row:12.3.2, the third block
of buffer 12, its second row), with their cells as their state.
A kubernetes object knows what it belongs with, asked of kubectl as the block it came from would: in the inspector a deployment lists its pods (by its selector), and a pod its deployment (through its ReplicaSet) or whatever else owns it, like a StatefulSet.
Some cells are things of their own: the node a pod runs on (kubectl get pods -o wide) and its namespace (with -A) are kubernetes objects, and a
container’s image is an image, which inspect, history and pull work
on. space . on such a cell offers the row’s actions first, then the
cell’s (a node’s describe, an image’s pull), and the inspector lists
them among the row’s relations. A namespace or a node is named as kubectl
names it, namespace/billing.
A row of kubectl get events is the object the event is about, the
pod/pay-0 of its OBJECT column, so enter describes the pod that
failed its probe and . offers its logs.
Any cell of any table is something to act on too: copy copies what’s
in it, and filter by this keeps the rows with the same in that column
(STATUS=Running; with spaces in it, the rows with its words). A plain
row copies as text, its cells with tabs between them, or as a JSON
object. Agents reach them the same way, through the objects, inspect
and act tools: a block’s rows are among the objects it relates to.
Plugins add kinds of rows and actions of their own (Writing plugins).
Asking for a command
These lines ask a model for a command instead of running anything:
❯ ? the ten biggest files under here
❯ ls | where ? only files over 1 MB
A line starting with ? asks, and so does one with a ? between what
you’ve typed so far and the question. A line ending in ? asks when it
reads as a question (three words or more, so ls a? stays a glob).
The model gets the shell’s folder, which shell runs your lines, and your last few commands with how they ended and the end of their output, marked as text someone else wrote. Its command goes to the prompt for you to read, change and run.
It asks the model playing shell-ask-role (fast); :models shows and
sets them up. Without one, or without its key, a block marked ? (nothing
ran, so it has no exit code) says why, naming
the variable that sets the key, like ANTHROPIC_API_KEY.
History and completion
The commands you type at every shell are kept in your data folder
(~/.local/share/greed/shell/history.jsonl on Linux), the last
shell-history-size (5000) of them, so up and ctrl-r find them in
every session. An agent’s commands aren’t kept.
As you type, the prompt suggests the rest of the newest command that
starts with what’s there, dimmed after the cursor, as fish does: right,
end or ctrl-e at the end takes it, and typing on goes past it.
:set shell-suggestions false turns it off.
~/s/app ❯ cargo t|est -q --workspace
tab completes what fits where the cursor is, as a shell does: the only
match goes in at once, and with several, what they all start with. When
that’s all there is, tab shows the menu, and tab again puts each item
in place in turn (shift-tab goes back); enter or typing on keeps it.
Command names that start with what you typed come first, then those
holding it, then looser matches, so hist offers history first.
A menu also opens by itself once typing pauses
(completion-delay, 150 ms). It’s a hint
until you move into it with tab: enter runs the line as typed, and
up and down go through the history. So typing ls -la, pausing and
pressing enter runs ls -la. :set completion-enter first makes enter
take the menu’s first item instead.
What the shell itself knows is marked greed in the menu, with what it
does beside it:
- A command’s first word: the builtins, your aliases and the programs on
your
PATH; after$3 |, the stages too. - A builtin’s arguments: folders after
cd, files and buffers afteropen, variables afterexportandunset, topics afterhelp. - A stage’s: the columns of the table it reads (
$3 | where), then the comparisons, then the values in that column;from’s formats. $for variables and earlier blocks,buf:for buffers, and@seland@file.
A program’s arguments come from the first of these that answers:
- A completer a plugin added for the program.
- The program itself when it’s built with Cobra (kubectl, helm, gh, docker, flux, argocd, and any other with Cobra’s completion inside).
- fish’s completions, when fish is installed.
- carapace’s, when it is.
- For a flag, the program’s man page, read from the file.
- When you press
tabon a flag, what the program prints for--help(and for a subcommand its help lists, that one’s).
Files and folders when none of them knows, or the program says files fit.
~/s/app ❯ kubectl get po
pods Pod
podtemplates PodTemplate
poddisruptionbudgets PodDisruptionBudget
The programs asked run in the background, in the shell’s folder with its
variables, for at most shell-completion-timeout (2000) milliseconds;
typing on stops one that’s no longer needed, and an answer is kept a few
seconds, so typing more of a word narrows it without asking again.
Your program runs only for --help: a Cobra program is asked with its
__complete command, the way every shell asks it, and whether a program
is Cobra’s is found by looking inside it. :set shell-help-completion never stops --help from running at all, and shell-help-never lists
programs it never runs for (reboot, shutdown and the like).
shell-completion-sources (cobra fish carapace man help) says which
sources to ask, in order.
Agents
Agents run commands in the project’s first shell (opened if there’s none,
without taking your screen) with the shell tool group:
| Tool | |
|---|---|
shell_run | Run a command line and get back its id, exit code, output and errors (cut to whole lines at their start and end when long), how long it took, where cd went and what it set, the files and lines it names, its JSON, and a table’s columns, first 50 rows and how many there are |
shell_read | A block by id, or the latest one, yours too |
shell_wait | Wait for a block shell_run left running past its timeout_s |
shell_kill | Stop a block an agent ran |
An agent’s commands run through a pipe with their input closed, from the
project’s root unless they ask for a folder, in sh without its startup
files. Their blocks are marked ◆, and their cd and export show in
their block without changing your shell.
What a command prints goes back
to the model between <untrusted-…> tags it’s told to read as data and
not to follow, with secrets in it hidden (private keys, cloud and API tokens,
bearer tokens, the values of variables like DB_PASSWORD); greed ctl
gets it as it is. shell-agent-max-output (30000
bytes) is how much of the output and of the errors an agent gets; where
it’s cut says how many lines are left out and that $ID | where, select
or get narrows it.
Each block has one id, unique across shells, and in an agent’s command
$ID is that block, whichever shell it ran in, so shell_run with
$12 | where STATUS != Running works on what block 12 printed. A tool
called without an argument it needs, or with one it doesn’t take, says
which it takes and runs nothing; greed ctl shell_run --help lists them.
Limits
- A program in a pseudo terminal that prints faster than the shell reads
(
seq 1 10000000, a hugecat) can lose lines in between, and its block says how many. A flood of output belongs in a pipe:$-lines,> buf:and agents’ commands run through one, which keeps every line. - Blocks don’t survive a restart yet.
- Only the client a block ran from sizes its terminal.
Boards
A board is a page of live shell commands, saved by name: pods that aren’t running, the disks filling up, the last deploys. Each command is a card showing what it prints now. Cards sit side by side as far as the window is wide and go on down the page, which scrolls like any buffer.
ops
payments
◐ pods every 5s · 1 changed · 14:05:02 ◐ disk every 60s · 0 changed · 14:05:00
NAME READY STATUS Filesystem Size Used Avail Use%
worker-5c6b7d8f9-abcde 0/1 CrashLoopBackOff /dev/nvme0n1p2 468G 401G 44G 91%
For one live command in a note or a runbook rather than a page of them,
a shell code block with every=SECONDS does the same where it is; see
Runnable code blocks.
Making one
:board-new ops makes a board in the project, at .greed/boards/ops.md,
and opens it; :board-new! ops makes one of your own, in boards under
your config folder, there in every project. On a board, space a asks for
a command and adds it as a card.
From a shell, once a command shows what you want, space . on its block
and “pin to board” adds it to a board you pick, or a new one. A watch is
pinned as a card running every so often (watch -n 5 df -h runs df -h
every five seconds), and a block that ran in another folder than the
project’s root keeps it.
The file
A board is a Markdown file. Its # heading is its title, ## headings
are its sections, and every shell code block is a card; other text stays
in the file and isn’t shown:
# ops
## payments
```shell every=5 title=pods
kubectl get pods -n payments | where STATUS != Running
```
```shell every=60 title=disk height=4
df -h /
```
A card’s language is shell, as for a shell block
anywhere: it runs in the Greed shell. sh, bash, zsh, fish, nu
and console blocks are cards too, and run the same way. After the language:
every=SECONDSruns it again that often (the board’s ownwatch, so the command needs none);livealone is every two seconds. Without either it runs once, and again when the board does. A command that keeps printing, likekubectl get pods -w, stays live by itself.title=NAMEnames the card, which is its command otherwise.height=LINESis how many lines of it show (10); past that the card says how many more there are.span=COLUMNSmakes it as wide as that many cards side by side, andwideas wide as the board.chartdraws it as a chart as big as the card;chart="bar CPU"says which. A command ending in| chartof its own is as big as the card too.dir=PATHruns it in another folder, from the project’s root.
space e opens the file, and saving it shows the board as it says. Cards
that run what they ran before keep running as they were; only the ones
you changed start again.
Cards are at least board-card-width columns wide (50), so a window of
100 or more shows two side by side, and one of 150 three. Each section
starts a row of its own, and a row is as tall as its tallest card. What’s
wider than a card is cut at its edge: enter shows all of it.
For the same layout in any window, set columns in front matter. With
two, a card is half the row and wide (or span=2) the whole of it; a
window too narrow for two shows one.
---
columns: 2
---
# machine
```shell every=2 chart wide height=12 title=load
cat /proc/loadavg
```
```shell every=5 chart=area height=8 title="memory, MiB"
free -m | awk '/Mem:/ { print $3 }'
```
```shell every=10 chart height=8 title="example.com, seconds"
curl -o /dev/null -s -w '%{time_total}\n' https://example.com
```
Using one
:board ops opens a board, and :board alone picks one. Its cards run in
a shell of the board’s own, out of sight, from the project’s root, as
watches and other live blocks do, with the
same tables, filters and rows to act on.
| Key | What it does |
|---|---|
enter | Open the card’s block in a float, all of it, to filter and act on its rows |
space . | Act on the card’s block, as in a shell: change its command, filter, stop it |
< > | Move the card back or on along the board, in its file too |
space a | Add a command as a card |
space e, or i a c o on a card | Open the board’s file, at the card’s command; saving it updates the board, and ctrl-o (alt-left in the vscode style) goes back to it |
space r | Run every card again |
< and > work in every editing style, as a board can’t be typed in.
A board stays open while you look at something else, and closing it stops its cards.
Live charts
A card with chart is drawn as a chart, and one that
runs every so often adds a point each time, so the chart moves. Each
of these is a whole board; save one as .greed/boards/NAME.md and
:board NAME. The first is for Linux.
# machine
## load
```shell every=2 chart title="load average" height=8
cat /proc/loadavg
```
```shell every=5 chart=area title="memory used, MiB" height=8
free -m | awk '/Mem:/ { print $3 }'
```
## disks and the web
```shell every=60 chart="bar Use%" title=disks height=4
df -h -x tmpfs -x devtmpfs
```
```shell every=10 chart title="example.com, seconds" height=4
curl -o /dev/null -s -w '%{time_total}\n' https://example.com
```
A cluster, with metrics-server running in it:
# cluster
```shell every=10 chart title="CPU by pod" wide
kubectl top pods
```
```shell every=10 chart="bar MEMORY(bytes)" title="memory by pod"
kubectl top pods
```
```shell every=30 chart=bar title="restarts"
kubectl get pods --no-headers | awk '{ print $1, $4 }'
```
kubectl top pods charted every ten seconds is a line a pod, of its CPU,
in cores and millicores; with bar MEMORY(bytes) it’s a bar a pod, as
it is now, in MiB and GiB. A card’s chart is as wide as the card, and
height lines tall.
Boards from others
A board runs commands, so one you didn’t make asks before it runs
anything, as code blocks in Markdown do:
y runs it this time, a always for that file. Trusting a file for one
trusts it for the other. Boards you make with :board-new or “pin to board” are trusted.
Trusting a board trusts the commands it has then. A card that changed
from outside since (a git pull, an agent’s edit) doesn’t run: it shows
the command it would run, and enter on it runs it from then on. Cards
you add with space a, or write yourself and save, run as they are.
Boards and their cards are objects too: space h i (the inspector), and
agents through inspect, see a board’s file and cards, and a card’s
command and the block showing what it prints.
Charts
| chart turns a table into a chart: a command’s output in the
shell, a shell block in a note, or a card on a
board.
❯ kubectl top pods | chart
api-7d9f8b6c5-2xkqz ████████████▊ 0.25
worker-5c6b7d8f9-abcde ████████████████████████████████████████████ 1.2
redis-0 █▊ 0.035
Run it again with watch or every= and the chart follows the numbers as
they change; a board of those is a dashboard. In a Markdown
file, a <!-- chart: bar per_year --> line under a table or a data block
charts it and follows it as it changes (see Live
values).
In a terminal a chart is drawn in characters (braille for lines, eighth
blocks for bars). In the window, and in terminals that draw pictures
(kitty, Ghostty, WezTerm, Konsole), it’s drawn as a picture with smooth
lines; :set scene-drawing cells keeps characters.
Kinds of chart
| Kind | Guessed when the table has | Ask for it with |
|---|---|---|
| Bars | A name column and numbers: a bar a row | chart bar, chart bar CPU MEMORY for two, --stacked to stack them |
| Lines | A time column and numbers, or numbers alone, or any table in a watch | chart line, chart line rate over time |
| Area | Never guessed | chart area, --stacked to stack the series |
| Dots | Two number columns and nothing to name the rows by | chart scatter (the first column across, the second up) |
The rest of what can follow chart:
COLUMN ... | The number columns to chart, in place of the guess |
over COLUMN | What runs along the bottom: a time column, or any number column |
by COLUMN | What names the rows: bars, or with a time column a line for each name |
--log | A log scale, for numbers that span powers of ten |
--last N | In a watch, how many points each line keeps (120) |
--width N, --height N | Its size in cells; it’s as wide as the view, chart-height (12) tall |
--why | Say how each column was read and why it chose the chart it did |
Column names match without minding case, spaces or marks, so by mounted_on is df’s Mounted on; the rest of a name has to be there, as
in MEMORY(bytes).
How it reads a table
chart --why shows its reasoning, a line a column:
❯ kubectl top pods | chart --why
NAME names, for the rows
CPU(cores) numbers, in cores, charted
MEMORY(bytes) numbers, in bytes, left out
bar: CPU(cores) by NAME: api-7d9f8b6c5-2xkqz 250m, worker-5c6b7d8f9-abcde 1.2, +1 more
because the rows have names (NAME): a bar each, of CPU(cores)
- The first text column names the rows. With a name column, only the first number column is charted, as CPU and memory on one scale would hide the CPU; name the columns to chart more.
- A column of dates and times (ISO 8601, or numbers in a column called
time,date,timestamports) runs along the bottom. - Columns of ids (
PID,user_id) and durations (AGE) are left out: they aren’t measurements. Name one to chart it anyway. - Numbers keep their units:
128Miand1.5Giare bytes, kubectl’s250mis cores,45%a percent. Bars of two columns in different units are each scaled to their own greatest. - Text that isn’t a table, like
cat /proc/loadavg, is read as words, a column each; a first line without numbers is its header. - JSON (
kubectl get pods -o json,docker ps --format json,nu -c '... | to json') is a table of its fields. CSV and TSV needfrom csvorfrom tsvin front:cat samples.csv | from csv | chart.
Over time
There are three ways to get a chart over time.
Run it again, in a watch or a block or card with every=SECONDS: each
run adds a point to every line. Each row becomes a line, named by its
name column:
❯ watch -n 2 kubectl top pods | chart
draws a line a pod, of its CPU, over the last 120 runs. A table of one row, like the load average, gets a line a number column instead. Rows with the same name in one run add up to one point, so a program with ten processes is one line of their total.
Chart a table with a time column: it’s drawn along that column, a line a
number column. When a name column’s names come again, as in samples of
several hosts, it’s a line for each name, or say which column with by:
❯ cat samples.csv | from csv | chart cpu by host
time,host,cpu
2026-10-12T07:26:40Z,web,20
2026-10-12T07:26:40Z,db,50
2026-10-12T07:27:40Z,web,27
2026-10-12T07:27:40Z,db,53
Ask Prometheus for a range: prom QUERY --range 3h gives a row a time
and a column a series, a line each (see Prometheus).
A line for each thing
Each line is one thing in the table: a pod, a node, a program, a host. These work as written:
❯ watch -n 2 kubectl top pods | chart a line a pod, of its CPU
❯ watch -n 2 kubectl top pods | chart MEMORY(bytes) of its memory
❯ watch -n 2 kubectl top nodes | chart a line a node
❯ watch -n 2 ps -A -o pcpu= -o ucomm= | sort -rn | head -n 8 | chart
a line a program, of its CPU
❯ cat samples.csv | from csv | chart cpu by host a line a host
❯ prom 'sum by (instance) (rate(node_cpu_seconds_total{mode!="idle"}[5m]))' --range 3h | chart
a line a machine
A chart has at most eight lines: the eight greatest now, as top would
show them, each keeping its colour while it stays. Lines that drop out
come back when they’re among the greatest again. To choose what’s shown,
narrow the table first: head -n 8, where, or sum by in PromQL.
Prometheus
prom QUERY asks a Prometheus server, or anything that answers its query
API, like VictoriaMetrics and Thanos. It asks prometheus-url
(http://localhost:9090 unless you set it) or --url. Each series is a
row, named by its labels’ values:
❯ prom 'sum by (namespace) (kube_pod_container_resource_requests{resource="cpu"})' | chart
webshop ███████████████████████████████████████████ 1.88
kube-system ████████████████████████████████████▎ 1.58
flux-system ████████████▋ 0.55
monitoring ███████▏ 0.31
Queries that chart well:
| Query | What it shows |
|---|---|
sum by (namespace) (kube_pod_container_resource_requests{resource="cpu"}) | CPU requested, a bar a namespace |
count by (phase) (kube_pod_status_phase == 1) | Pods by phase: how many run, wait, fail |
sum by (instance) (rate(node_cpu_seconds_total{mode!="idle"}[5m])) with --range 3h | Busy CPUs per machine, the last three hours |
max by (instance) (node_load1) | The load of each machine |
sum by (job) (rate(http_requests_total[5m])) | Requests a second, per job |
histogram_quantile(0.99, sum by (le) (rate(http_request_duration_seconds_bucket[5m]))) with --range 1h | The 99th percentile latency over the hour |
--range DURATION (30m, 3h, 2d) asks for that long up to now, and
--step sets the time between points (about 120 points unless said).
Use sum by (...) to keep a query to a few series with short names: a
series is named by all its labels’ values, joined with /, and only
eight lines show.
For a live chart, run it again: watch -n 15 prom 'QUERY' | chart in the
shell, or every=15 on a card. Each run adds a point. For a longer view
right away, --range draws what Prometheus already has.
Dashboards
A board is a Markdown file of commands, each a card. A card
with chart after its language is drawn as a chart as big as the card,
and every=SECONDS runs it again so the chart moves. This one is for a
cluster with kube-state-metrics:
---
columns: 2
---
# cluster
```shell every=15 chart wide height=10 title="busy CPUs per machine"
prom 'sum by (instance) (rate(node_cpu_seconds_total{mode!="idle"}[5m]))'
```
```shell every=60 chart=bar title="CPU requested by namespace"
prom 'sum by (namespace) (kube_pod_container_resource_requests{resource="cpu"})'
```
```shell every=30 chart=bar title="pods by phase"
prom 'count by (phase) (kube_pod_status_phase == 1)'
```
The same works in any note: a shell block with every=5 and a line
ending in | chart keeps its chart up to date where it is, until
space m s stops it.
Boards for Linux and macOS
Many commands print differently on the two, or take other flags: free
is Linux’s, ps -o comm is a cut-off path on a Mac, df -h says Use%
on Linux and Capacity on a Mac. This board uses forms both agree on and
works as it is on both:
---
columns: 2
---
# machine
```shell every=2 chart wide height=8 title="load average"
uptime | awk -F'load averages?: ' '{ gsub(",", "", $2); print "load1 load5 load15"; print $2 }'
```
```shell every=2 chart height=10 title="CPU % by program"
ps -A -o pcpu= -o ucomm= | sort -rn | head -n 8
```
```shell every=30 chart="bar Capacity by mounted_on" height=10 title="disks"
df -kP | where Filesystem ~ /dev/
```
```shell every=60 chart=bar height=8 title="this folder, KiB"
du -sk * | sort -rn | head -n 8
```
```shell every=5 chart=area height=8 title="memory used, MiB"
case "$(uname)" in Darwin) vm_stat | awk -v page="$(pagesize)" '/Pages active/ { a = $3 } /Pages wired/ { w = $4 } END { print "used"; print int((a + w) * page / 1048576) }' ;; *) free -m | awk '/Mem:/ { print "used"; print $3 }' ;; esac
```
What makes it work on both:
- POSIX forms.
df -kPprints the same columns on both,Capacityincluded.ps -A -o pcpu= -o ucomm=gives each process’s CPU and its program’s name, number first, as Mac program names can have spaces.du -skis in KiB on both. case "$(uname)"for what has no common form, like memory: one line, a branch forDarwinand one for the rest. A card runs a line at a time, so the wholecasegoes on one line.- nu. Where nu is installed, its
ps,ls,duandsysgive the same tables on every system, with full names. Hand them over as JSON, which the shell reads as a table:
nu -c 'ps | select name cpu | sort-by cpu --reverse | first 8 | to json'
Pitfalls
ps’s%CPUdiffers. On Linux it’s the average over the process’s whole life, so a long-running program’s line hardly moves; on a Mac it’s a recent average. nu’spsmeasures it now on both.- A header that looks like numbers isn’t one.
1m 5m 15mreads as numbers (1mis kubectl’s millicores), so the first row becomes data. Name columns with words:load1 load5 load15. - Names that come back add up. In a watch, rows of the same name are summed, which is right for processes of one program but not for two different things that share a name. Make the names unique first.
- Eight lines at most. The rest aren’t drawn; narrow the table so the ones you care about are among the eight.
- The history is in memory. A watch’s or card’s points are kept while
it runs. Changing its command or what follows
chartstarts over, and so does closing the board. - Commands that read your whole home folder (
du -sk ~/*) on a Mac ask for access to Music, Photos and iCloud folders, and take long. Point them at the folders you mean. --logneeds numbers above zero. Zeros and negatives have no place on a log scale and are left off.- A chart that won’t draw says why, naming the columns it found.
--whytells what it made of each.
Greed reads, searches and writes your mail. greed mail opens it in a
session of its own, on a full page: your inbox, newest first, with the
search box over it.
Nothing of it runs until you open it, and it doesn’t start with Greed
unless you ask it to (Sessions says
how). Searching everything at once just leaves mail out until there’s a
mail.toml.
What you type narrows the list as you type, in the query language every search in Greed speaks:
in:inbox is:unread unread in the inbox
from:anna invoice date:2w.. from Anna, about an invoice, the last two weeks
in:work -is:mine in the Work folder or label, not sent by you
account:work is:flagged flagged, in the work account
subject:"quarterly report" is:attachment
file:invoice type:pdf from:kia a PDF attached called something with invoice
type:image date:1w.. pictures sent this last week
file: searches the names of what’s attached (a plain word does too),
and type: their kind: the extension (pdf, docx, jpg), or image,
audio and video for any of those.
Setting it up
Mail needs two things: greed-mail, the program that syncs it, and a
mail.toml saying which accounts to sync.
greed-mail comes with Greed: Greed’s packages put it beside greed (the
Nix package and the static Linux build too), and Greed finds it there (or
on your PATH). If yours is somewhere else, say where with
:set mail-program /path/to/greed-mail. On another machine you reach
with greed ssh, the greed put there brings it along, so greed mail
works there too. Greed and greed-mail
check they speak the same way when they meet; one older or newer than
the other says so over the list, and which to update, rather than
misreading the other.
mail.toml goes in Greed’s config folder: ~/.config/greed/mail.toml, or
under $XDG_CONFIG_HOME when that’s set. One account looks like this:
[[account]]
name = "private"
address = "anna@example.com"
imap = { host = "imap.example.com" }
smtp = { host = "smtp.example.com" }
password = ["rbw", "get", "mail"]
password is a command that prints the password, here from Bitwarden;
["pass", "show", "mail"] or ["security", "find-generic-password", "-w", "-s", "mail"] work as well. It runs when a connection needs the password,
and the password is never written down. Each setting is explained under
mail.toml below; Gmail and Proton have their own ways, shown
there too.
If the command waits, say for you to unlock your password manager, the mail list says so over your mail (“waiting for rbw to give the password”) and syncing picks up once it’s given. A sync that fails says why there too, until the next one goes through.
greed-mail check logs in to each account and says what its server can
do, which is a quick way to see that mail.toml is right. Then:
greed mail
The first sync brings the newest mail first, and the list fills in as it goes; a message you open has its text fetched ahead of the rest. A big mailbox takes a while the first time (on Proton through Bridge, each message’s text comes from Proton when first asked for). While it syncs, a line over the list says how much of each account is in, and while it indexes, a bar says how far it got. After that, new mail shows within seconds.
The mail session and the quick look
The mail session (mail.service; greed mail from a shell,
:mail-session from inside Greed) is the mail client: it has the full
page, and it’s the one that syncs. It starts whenever another session
needs it, so you never start it yourself, and with Greed too once there’s
a mail.toml and services-at-start names mail. Detach from it as from any session; it goes on
syncing.
In any other session, :mail opens a quick look: the same mail, in a
floating view of the tab over what you’re working on. alt-f hides it
and shows it again like the tab’s other floats, :mail brings it back,
and q closes it. Threads open in it, and q goes back to the list. It
works as the page does, and what you mark, archive, delete, write or
answer there, the mail session does for it, starting first if it isn’t
running.
After an upgrade, the mail session indexes your mail again the first time it starts (a minute or two for a hundred thousand messages); the list shows how far it got, and fills in as it goes.
Several accounts
Add an [[account]] for each, with a name of your choosing:
[[account]]
name = "private"
address = "anna@example.com"
imap = { host = "imap.example.com" }
smtp = { host = "smtp.example.com" }
password = ["rbw", "get", "private-mail"]
[[account]]
name = "work"
address = "anna.berg@company.example"
imap = { host = "mail.company.example" }
smtp = { host = "mail.company.example", tls = "starttls" }
password = ["rbw", "get", "work-mail"]
[[account]]
name = "gmail"
address = "anna.berg@gmail.com"
provider = "gmail"
password = ["rbw", "get", "gmail-app-password"]
They all sync into one place, so one list shows them all: in:inbox is
every account’s inbox together, and a search finds mail in any of them.
account: narrows a search to one, by its name:
account:work in:inbox the work inbox
in:inbox -account:work every inbox but work's
account:private from:anna Anna's mail to your private address
For a tab for each, put them in your saved searches:
require("@mail").searches = {
{ name = "All", query = "in:inbox" },
{ name = "Private", query = "account:private in:inbox" },
{ name = "Work", query = "account:work in:inbox" },
{ name = "Gmail", query = "account:gmail in:inbox" },
}
You don’t need tags to keep accounts apart: account: does that, for
mail old and new. Tags are for sorting within your mail, and they live on
each account’s server, so a tag set on work mail stays with the work
account.
What you write goes through the account it’s from. A reply is from the
address the mail was sent to, so a reply to work mail goes from work. New
mail (c) starts from the address from names in mail.toml, or your
first account’s (see Identities); change the From: line
to any other address of yours, and it goes through that account. Changes,
like archiving or deleting, happen in the account the message is in.
Rules see every account; add account: to a rule’s query for one alone:
require("@mail").rules = {
{ query = "account:work from:jira@company.example", tag = "jira", archive = true },
}
The list
In the list, enter reads the thread under the cursor in its place, /
searches again and $ syncs now; q in a thread goes back to the list.
] m and [ m go to the next and previous row, and in a thread to the
next and previous message.
Reading a thread marks it read.
A dot marks unread mail, ⚑ flagged mail and 📎 mail with something
attached; a message’s folders, labels and tags follow its subject
(#work).
Over the list are your saved searches, each with how many unread messages
it finds, counted again as mail comes in. They go as tabs do: tab and
shift-tab to the next and the one before, alt-1 to
alt-9 to one, and g s picks any of them by name, however many you
have; pressing one goes to it too. Set your own in your config
(~/.config/greed/init.luau):
require("@mail").searches = {
{ name = "Inbox", query = "in:inbox" },
{ name = "Work", query = "in:work is:unread" },
{ name = "Recent", query = "date:2w.. -is:mine" },
{ name = "Receipts", query = "(receipt OR invoice) is:attachment" },
}
A thread shows once, as its newest message the search found, with how
many it found after the subject ((3)). A change to a row changes those
messages and no others of the thread, so archiving a thread found in the
inbox leaves your replies in Sent. :set mail-threads false lists every
message on its own.
These work on the message under the cursor, or in a thread on all of it:
| Key | Does |
|---|---|
u | marks it read, or unread when it’s read |
s | flags it, or takes the flag off |
t | asks for a tag and puts it on, or takes it off if it’s on |
T | makes a todo of it in your inbox note (see below) |
b | opens it in a web browser, loading nothing from anywhere |
e | moves it to the archive |
d, # | moves it to the trash; in the trash, asks, then deletes |
r | replies to who sent it (in a thread, its last message) |
a | replies to everyone it went to |
c | writes new mail |
z | undoes the last change, or takes back mail just sent |
space . lists the same actions for the mail under the cursor, as it
does for anything else in Greed, and in mail being written offers to
send or discard it.
A change shows at once and goes to the server within seconds. If the
server refuses it (a folder that went, say), it’s taken back and Greed
says why. z undoes the last one, even once the server has it:
something archived goes back where it was, a mark comes off again.
Deleting from the trash is for good, so it asks first (y deletes).
Reading
A thread opens on what’s new: messages you’ve read before show as a line
each (who, when, how it starts) and open when you press them, and a quote
of four lines or more folds into one line saying how many, with the
“Anna wrote:” line over it; pressing it shows them. o shows all of the
thread at once, and folds it again.
Mail sent as HTML reads laid out in Greed: headings, bold and italics,
lists, tables of data (a receipt’s lines) in columns, and tables only
there for layout as plain text. What the sender hid stays hidden, and
images show as their descriptions: nothing is fetched from anywhere, so
no tracking pixel tells the sender you read it. Links show as links;
tab goes from one to the next and enter opens it.
h reads the thread as its plain text instead (and back). b, in a
thread or the list, opens the message in your web browser as it was sent,
with everything that would load from elsewhere blocked: scripts, remote
images, fonts and styles.
What’s attached is listed under a message’s header, a line each, with an icon for its kind, its size and how it opens:
📎 2 attached
📄 Invoice 41.pdf 240.9 kB · opens in Greed
📄 Contract.docx 31.2 kB · opens with libreoffice
enter on one opens it as any file of its kind opens in Greed: a PDF or
a picture in Greed itself, an office document or a video with the program
your system (or core.file.open_with, see Other
files) opens it with. A program (⚠) never opens,
only saves. S saves one where you say (~/Downloads to start; the one
under the cursor, or the thread’s only one). The mail session fetches it
from the server the first time, whole, and keeps it beside your mail for
next time; what’s attached to the last two weeks’ mail and to flagged
mail (up to 10 MB a message) it fetches ahead as it syncs, so that opens
at once, and without a connection. A file that’s already where you save
is never written over.
space . on one offers the rest: open, open-outside, save,
save-all (everything attached to the thread, in a folder you say) and
copy-path; saving offers the folder you saved in last.
Invites
A calendar invite reads as a card over the message: what it is, when in your time zone, where, and who sent it.
┌ Invite ──────────────────────────┐
│ Garden plans │
│ Friday 24 Oct 10:00 to 11:00 │
│ The shed │
│ From: Bob │
│ Accept Maybe Decline │
└──────────────────────────────────┘
enter on Accept, Maybe or Decline sends your answer to whoever sent the
invite, the way calendars expect it, so it shows in theirs. It goes from
the address the invite was sent to, like any mail, with a copy in Sent. A
cancelled invite says so, and an answer to one of yours says who accepted
or declined.
Writing
A reply opens with its header lines, the cursor on the line where your text goes and the message you answer quoted under it:
From: anna@example.com
To: Bob Lind <bob@example.com>
Cc:
Subject: Re: Invoice 41
Paid this morning.
On 2026-10-19 08:00, Bob Lind wrote:
> Please pay by Friday.
Edit it as any text, the header lines too (add Bcc: for blind copies,
addresses apart by commas). On To:, Cc: and Bcc: addresses complete
as you type, from the people you’ve had mail with, those you write to
most first; on From:, from your own addresses. :mail-attach FILE
attaches a file, on an Attach: line you can edit too (paths apart by
commas, 25 MB in all at most).
What you write is Markdown: **bold**, *italic*, [a link](https://…),
lists and code. It goes as what you wrote, which reads as it is, and the
HTML it makes beside it, so mail programs that show HTML show it set out.
Your lines stay as you broke them, a reply’s quoted lines are a quote, and
the signature goes as it is. :set mail-markdown false sends plain text
alone.
ctrl-enter (or alt-enter, in a terminal that can’t tell ctrl-enter
from enter) sends it, while typing too, and so does :mail-send; then
it goes back to the list. It waits ten seconds,
in which z takes it back and opens it again, then goes, and Greed says
when it’s sent. A copy goes in your Sent folder (Gmail and Bridge file
it themselves), and the message you answered is marked answered. Mail
the server won’t take stays out, and Greed says why.
What you write is kept as a draft a moment after you stop typing, and
at once with :w, so it outlasts closing it with :mail-close and the
mail session ending. :mail-drafts lists your drafts, newest first:
enter goes on writing one, and alt-. on one offers to discard it.
Drafts are kept on this machine, beside the store, and go once sent.
While writing:
| Keys or command | Does |
|---|---|
ctrl-enter, alt-enter | sends it |
:w | keeps it as a draft now |
:mail-close | closes it, kept as a draft |
:mail-attach FILE | attaches a file |
:mail-from | picks which of your addresses it’s from (see Identities) |
:mail-drafts | lists your drafts to go on with one |
space . | offers to send it, pick who it’s from, or discard it |
Sending from space . asks y first; the keys and :mail-send don’t.
Tags
in:work (or tag:work) finds a message’s folders, labels and tags.
Proton’s labels and Gmail’s come along as they are. t puts a tag on, or
takes it off, on the server, where your other mail apps see it too:
- On Gmail it’s a Gmail label. Taking one off leaves the message where it is.
- On Proton it’s a Proton label, one you’ve made in Proton already. It
goes on as a copy of the message in the label’s folder, and comes off
by deleting it from there, which on Proton takes only the label off.
It’s off until the account in
mail.tomlsayslabels = true: try it on a message you can lose first. - On other servers (Dovecot, Fastmail) it’s an IMAP keyword.
Mail and Hoard
Mail and Hoard, your notes and todos, meet in todos. T on
a message (or in a thread) asks for a todo about it, starting as who sent
it and what it’s about, and adds it to your inbox note, the one Hoard’s
home page opens under Inbox. Say when it’s due in words, as anywhere
in Hoard: Bob Lind: Invoice 41 friday, or ... friday remind:09:00 to
be reminded. It ends in a link back to the message:
- [ ] Bob Lind: Invoice 41 [mail](mail:41@example.com) due:2026-10-23
From there it’s a todo like any other: it’s on the home page and the
agenda when it’s due, its reminder goes off in Greed and on your desktop,
and you can move it to any note. Opening the link, as any link in a note
opens, reads the thread again at that message, unfolded, in the mail
session or as a quick look anywhere else. The link names the one message
by its Message-ID, so it keeps
working after the mail is archived or moved, and the todo reads well
without it too, on your phone say. A [mail](mail:ID) link works in any
note, so a meeting’s notes can link the thread they’re about.
Rules
Rules act on new mail as it comes in: a query, and what to do with what
it finds. They’re Luau tables in your config (~/.config/greed/init.luau,
which runs again when you save it), and the query is the one the search
box takes:
require("@mail").rules = {
{ query = "from:github.com", tag = "github", archive = true },
{ query = "from:boss@example.com", flag = true },
{ query = "subject:newsletter", read = true },
}
A rule can mark what it finds read, flag it, put a tag on it, and
archive or trash it, in that order. Each rule looks at the new mail on
its own, so one that archives doesn’t stop the next from tagging. Rules
run in the mail session, on mail that arrives once a mailbox is all
synced: what the first sync brings is left as it is.
To see what a rule does before it does it, :mail-rule-try picks one and
shows what it finds in the mail you have, changing nothing. :mail-rule-run
runs it over all of that, once you’ve said y to how many it finds: for
a new rule over mail you already have.
A rule with all = true keeps on over all the mail it finds, not only new
mail: after the mail session syncs, at most once an hour. That keeps mail
an age, as a retention rule:
require("@mail").rules = {
-- A list's mail out of the inbox after a month, a shop's to the trash after a week.
{ query = "in:inbox list:news.example.com date:..30d", archive = true, all = true },
{ query = "in:inbox from:shop.example date:..1w", trash = true, all = true },
}
One that would change more than a hundred messages at once doesn’t: it
says so, and :mail-rule-run does it once you’ve looked, so a query
that finds more than you meant can’t move your mail unseen. Rules never
delete for good: trashing what’s in the trash is left to you.
Mail and agents
Talk to an agent about your mail as about anything else in Greed. With each message it’s told what you’re in, like “the mail list, searching in:inbox, 198 shown” or “a mail thread of 3 messages”, so you can ask about what’s in front of you:
what language is this in, and what does it say?
is this a real invoice, or phishing?
which of these need an answer from me this week?
For mail that isn’t on screen it has the mail tools, a group it
switches on when it needs them (see Agents):
| Tool | Does |
|---|---|
mail_search | searches every account with the query the list takes |
mail_read | reads a thread; it stays unread |
mail_show | opens a thread for you, as if you’d pressed it |
mail_act | marks, flags, tags, archives or trashes mail, asking you first |
So you can ask for things like:
find the mail from my bank about the new card this year
summarise what's unread in work since monday
archive the newsletters in my inbox older than a month
The tools reach your mail through the mail session, from any session you ask in, starting it if it isn’t running.
What an agent can and can’t do:
- What it reads of mail, through the tools,
readorfocus, is marked as from outside, to read as data: a mail saying “ignore your instructions” is something it read, never something you asked for. - Changing mail asks you first, as you’ve set agents to (see
Permissions);
zin the mail undoes it. Nothing an agent does deletes mail for good: trashing what’s in the trash is left to you. - It can write in mail you’re writing, as in any buffer. Sending, with
:mail-sendorspace ., asks you every time, whatever you’ve allowed it. - Luau it runs with
evalreads what the editor has open, mail too, and what it returns isn’t marked;:set agent-eval askshows you each run first. An agent you let run shell commands can read the store in~/.local/share/greed/maillike any file of yours.
Greed sends none of your mail to a model by itself: nothing sorts,
summarises or answers it unless you ask an agent to. To have one help
with a reply, press r, ask it to write the reply in the mail you’re
writing, then read it and send it yourself.
What’s there and what isn’t
There now:
- IMAP and SMTP accounts, any number, with Gmail (an app password) and Proton (through Bridge) set up for their ways.
- A local copy of everything, searched as you type, offline too, by sender, subject, text, date, folder or label, account, list, and what’s attached by name and kind.
- Threads, HTML laid out in Greed with nothing loaded from anywhere, and attachments opened in Greed or the program for them.
- Writing in Markdown, replies quoting what they answer, address completion, attachments, identities with signatures, a default From, drafts that outlast closing, and ten seconds to take mail back.
- Read, flag, tag, archive and trash, undoable and sent to the server; rules for new mail and for mail of an age; saved searches as tabs.
- Answering calendar invites, and todos in Hoard linking back to mail.
Not yet:
- Forwarding mail, and moving it to a folder of your choosing (on Gmail and Proton, a tag does that).
- Drafts on the server: they’re kept on this machine only, so your other mail apps don’t see them.
- Signing in with OAuth, so accounts that only allow that (Microsoft 365, Gmail without app passwords) can’t be added.
- PGP and S/MIME, for encrypting and signing.
- An alert when new mail comes, beyond the counts over the list.
- A calendar: invites are answered, not kept.
- Contacts from an address book: completion knows the people you’ve had mail with.
- Replying from the address you got a Bcc’d or forwarded mail at, when it
isn’t on the mail’s To or Cc lines: change the
From:line. - Windows.
mail.toml
Each [[account]] has:
| Setting | What it is |
|---|---|
name | what you call it: account:NAME searches it |
address | its address; new mail is from it, and you log in as it |
password | a command that prints the password |
imap | where its mail is: { host, port, tls } |
smtp | where its mail is sent, with the same login |
user | who logs in, when it isn’t the address |
aliases | the other addresses it gets mail at and sends from |
provider | gmail or proton-bridge, for their ways; leave it out for any other |
labels | true lets t set Proton labels (see Tags); off without it |
tls is implicit (the default: ports 993 for IMAP, 465 for SMTP),
starttls (ports 143 and 587), or none for a server on this machine
only. port is needed only when it isn’t one of those.
aliases are you too: mail from them counts as yours (is:mine), a reply
or an invite’s answer goes from the alias it was sent to, From: may name
any of them, and they’re never offered as people to write to.
Identities
How mail goes out from an address: the name on its From line, a
signature, where replies go and a copy to yourself. Set them on the
account, and for an alias that’s different, in an [[account.identity]]
under it; what an identity leaves out, the account’s settings give:
[[account]]
name = "proton"
address = "anna@proton.me"
aliases = ["support@spool.example"]
display_name = "Anna Berg"
signature = "Anna"
bcc = "anna@proton.me"
[[account.identity]]
address = "support@spool.example"
display_name = "Hyperspool Support"
signature_file = "~/.config/greed/support.sig"
reply_to = "help@spool.example"
| Setting | What it does |
|---|---|
display_name | the name on the From line: Anna Berg <anna@proton.me> |
signature | the signature, written here |
signature_file | the signature, from a file (in place of signature) |
reply_to | where replies go, on a Reply-To: line you can change |
bcc | who gets a copy, on the Bcc: line, like yourself |
New mail and replies are written with the identity of the address they’re
from: the From line with its name, a Reply-To: and Bcc: filled in, and
the signature under where you write (above the quote in a reply), after a
-- line as mail programs expect. All of it is there in the text to
change before sending. An identity’s address must be the account’s or
one of its aliases.
New mail is from your first account’s address unless from, at the top
of mail.toml, names another of yours:
from = "support@spool.example"
[[account]]
…
A reply is from the address the mail was sent to, among your own. To
send from another, :mail-from (or space . in the mail, then from)
picks one of your addresses by name: the From line changes, and with it
the signature, Reply-To and Bcc, where they’re still as the last identity
put them; one you’ve changed stays as you left it.
Gmail
[[account]]
name = "gmail"
address = "anna.berg@gmail.com"
provider = "gmail"
password = ["rbw", "get", "gmail-app-password"]
Gmail needs no imap or smtp. Its password here is an app password
(made under your Google account’s security settings, with two-step
verification on), not the one you sign in with. Gmail’s labels are places
like folders: in:receipts finds what’s labelled Receipts.
Proton
Proton’s mail comes through Proton Mail Bridge, which runs on your machine (or another you reach) and gives each account an IMAP and an SMTP port and a password of its own:
[[account]]
name = "proton"
address = "anna@proton.me"
aliases = ["anna@pm.me", "hello@annaberg.example"]
provider = "proton-bridge"
imap = { host = "127.0.0.1", port = 1143, tls = "starttls" }
smtp = { host = "127.0.0.1", port = 1025, tls = "starttls" }
password = ["pass", "show", "mail/bridge"]
The ports, the password and whether it’s starttls are the ones Bridge
shows for the account. List every address Proton lets you send from in
aliases. Proton’s labels are places like folders, and folders under
Proton’s Folders/ show without it.
How syncing works
greed-mail syncs your accounts into a store on this machine (in Greed’s
data folder, ~/.local/share/greed/mail) and keeps an index of
it that Greed searches, so searching never waits on a server. Changes you
make are made in the store at once and sent to the server in the next
round, within seconds.
Once everything is in, new mail shows within seconds: greed-mail waits on
each account’s inbox for the server to say something arrived (IMAP IDLE),
and checks every two minutes on a server that can’t. When an account
can’t be reached it tries again a little later each time, up to every
five minutes. greed-mail sync syncs once, on its own, if you want to see
it work. Until an account is all in, the mail list shows a bar for it
over your mail, how many messages are here of how many the server has.
Headers come first, every mailbox’s, so all your mail shows up in the list
and searches early on. Bodies follow. One you open doesn’t wait for any
of that: it’s fetched right away on a connection of its own, same for an
attachment you open.
Sometimes a server shows a big mailbox nearly empty for a while. Proton
Bridge does it when its disk fills up (its temporary files go to /tmp),
or while it rebuilds its cache. So when fewer than half of the messages
you have here are on the server, greed-mail leaves the mailbox alone and
the mail list says so, until the rest are back. If they really did go,
greed-mail --start-over sync lets them go here too.
Chat
Matrix and Mattermost rooms in Greed, from any session. Your accounts stay
connected in a session of their own, the chat service’s (chat.service),
which starts by itself when something needs it; :chat anywhere shows the
same rooms. This is experimental; what’s there and what isn’t is listed at
the end.
Nothing connects until you sign in to an account (:chat-login), and
chat doesn’t start with Greed unless services-at-start names it
(Sessions).
greed chat
greed chat goes to the chat service’s session, which shows your rooms
and channels in a sidebar on the left, those that mention you first, then
those with something unread, then the most recent; a dot beside a direct
message says whether the other person is around (Mattermost). After them
come your Matrix spaces and Mattermost teams (◆), each with your rooms
in it under it. enter opens a room
beside the sidebar: its messages, laid out as Markdown and kept up to date
as they come, and a box under them, and q goes back to the sidebar. The
room is marked read as you look at it, who’s writing shows under the
messages, and on Matrix “seen by” says who has read up to where.
:chat shows the same sidebar in any other session.
Going to a room or a person
alt-g in the list or a room (or space M g, :chat-go anywhere) lists
every room, channel and direct message of every account, mentions and
unread first, then the most recent. Type a few letters of a name and
enter opens it. alt-enter (or ctrl-v) opens it in a new pane beside
the one you’re in instead, and ctrl-s below, so two rooms sit side by
side. The last entry, “Write to someone…”, finds a person.
Rooms are named after themselves in space space and the tab line, and a
thread after its room (Ops · thread).
:chat-write (space M w) asks for a name, lists the people the server
finds by it, and opens your direct messages with the one you pick,
starting them if you’ve never written. On Mattermost that’s anyone on the
server; on Matrix it’s who the server’s user directory shows, which is
usually the people you share a room with plus public profiles.
| Key | |
|---|---|
space M g, alt-g in chat | Go to a room or person |
space M s | Your rooms as a sidebar |
space M w | Write to someone |
space M j | Join a room |
space M / | Search messages |
| Key | In a room |
|---|---|
enter (writing) | send what’s in the box, as Markdown |
alt-enter | a new line in the box |
alt-r | answer the message under the cursor |
alt-t | open its thread; what you send there goes in the thread |
alt-k | react to it, or take your reaction back |
alt-e | change it (your own); enter sends the change |
alt-d | delete it, after asking |
alt-b, enter | press one of its buttons, or pick from its menu (Mattermost) |
alt-/ | pick a command into the box (Mattermost) |
alt-up | fetch older messages |
] m, [ m | the next or previous message |
tab, shift-tab | the next or previous room in the bar over a room (the rooms you opened); alt-1…alt-9 one of them |
q, esc | stop answering or changing; else back to the room, or to the list (the sidebar) |
space . on a message offers the same, and copying what it says.
Code blocks and tables in a message keep their lines, so a bot’s
box-drawn table stays lined up. A wide one gets cut with … at the edge,
which isn’t great, so open as text on space . puts the whole message
in a buffer of its own where you can scroll sideways.
A room shows each thread’s first message with how many replies it has;
the replies are in the thread. A reply to a message (Matrix) gets a line
above it saying what it answers, like ↳ Bea: lunch at noon?.
On Mattermost, a message starting with / runs a command, like /away or
an integration’s; what it answers only you shows in the room. Posts from
integrations show their attachments’ text, and their buttons and menus
under them.
A link’s preview shows under its message: the site, the page’s title, and a line of what it says (see below for where they come from).
In any other session, :chat opens the same sidebar, starting the chat
service’s session first if it isn’t running. With :set chat-list float
it opens in a floating view of the tab instead: rooms open in it and q
goes back to the list; alt-f hides it and shows it again like the tab’s
other floats, and :chat brings it back showing the rooms. In a room,
esc then q goes back to them too.
Signing in
:chat-login asks for the service and the server (matrix.org,
mm.example.com), then offers the ways that server has:
- Password, with the code from your authenticator app when your Mattermost account asks for one.
- In the browser: single sign-on, like a company’s Keycloak behind
Mattermost, or a Matrix server’s own sign-in page (OAuth, as matrix.org
has it). Greed opens the page; sign in there, and approve Greed if the
server asks. The browser then comes back to Greed by itself where it
can; where it can’t (Greed over ssh, Mattermost’s
mattermost://link, a server that hands the sign-in back to a link of Greed’s own), paste the link the browser ended on into the prompt, or let your system hand it over (below). When Mattermost’s page offers to open the Mattermost app, cancel that and copy the address it’s on. Overgreed sshthe page opens in your own browser; with no browser anywhere, Greed copies the sign-in link for you to open in yours.
Your sign-in is kept in the system keyring (or Greed’s secrets file
where there’s none), never in a file of its own. :chat-logout signs out
and forgets it.
Letting the browser hand links to Greed
greed link URL hands a link to the chat service, which finishes the
sign-in waiting for it, in whichever session you started it. On Linux,
Greed’s packages install the desktop entry greed-link.desktop, which
does that for mattermost:// links and Greed’s own (io.github.johnae:).
Make it their handler once:
xdg-mime default greed-link.desktop x-scheme-handler/mattermost
xdg-mime default greed-link.desktop x-scheme-handler/io.github.johnae
From the tarball, unpacked into ~/.local, run
update-desktop-database ~/.local/share/applications first. Without the
handler, or on macOS, paste the link the browser ends on when Greed asks.
Making greed-link.desktop the handler for mattermost:// also takes
those links from Mattermost’s own desktop app, if you have it.
Encrypted rooms (Matrix)
Greed signs in as a device of its own, which needs your keys to read encrypted rooms. The room list says when this device isn’t verified yet.
:chat-recovertakes your recovery key (Element calls it a security key) and unlocks the keys kept on the server: older messages decrypt and this device counts as verified.:chat-verifyasks your other devices (your phone, Element) to verify this one. Accept there, and Greed shows seven emoji to compare with what the other device shows; say whether they’re the same.- When another device asks to verify this one, Greed asks you to accept, then shows the emoji the same way.
:chat-encryptionsays how an account stands. For an account with no recovery key yet it sets one up and shows it once: keep it somewhere safe, Greed doesn’t keep it.
Joining and leaving
+ in the list (or :chat-join) offers the rooms you could join: on
Matrix the rooms your server lists publicly, on Mattermost your teams’
public channels you aren’t in. Or pick “By its name, address or id” and
type one: on Matrix #garden:example.org, or #garden for one on your
own server; on Mattermost the channel’s name (garden, ~garden) or the
name it shows (Garden), in any of your teams. The room opens once
you’ve joined.
A Matrix space is a list of rooms rather than a room to talk in. Join one
like any room (+, #space:nixos.org), and it shows in the list with
◆. enter on it offers the rooms it holds, ✓ before those you’re in:
pick one to open it or join it, or a space inside it (◆) to see that
one’s. Rooms on another server are joined through the servers the space
names, and joining one there can take a minute. A Mattermost team works
the same way: enter on it offers its public channels.
An invite shows in the list with + before it; enter on it asks: y
joins, n says no. - in the list (or :chat-leave in a room) leaves a
room after asking.
Searching
/ in the list (or :chat-search) searches the messages of every account;
alt-s in a room searches that room. What it finds comes newest first, and
the message you pick opens in its room, older messages fetched until it
shows.
It’s the same search as mail’s and your notes’: words, and from:bea,
in:plans (a room), before:2026-10-01, is:mine, is:direct,
"a phrase".
The chat service keeps every message it sees to search, on this machine,
in Greed’s data folder: as they come, and each room’s older ones fetched
in the background as an account comes in, back to chat-search-days (90
by default). Encrypted rooms are kept once their messages are decrypted
here. What integrations post counts too: a Mattermost webhook’s alert is
kept with the text of its attachments, under the name the webhook gives,
so from:alertmanager in:alerts-platform-prod firing finds it, and so do
agents with chat_search.
greed.option.set("chat-search-days", 365)
Alerts
A new message that mentions you, or any message in a direct message, alerts you:
- the room shows as needing you in the chat service’s status until you look at it in any session,
- you get one notification wherever you are: the hub tells the Greed window or terminal on each machine you’re attached from, whichever session it shows, as it does when an agent waits for you.
A room you’re looking at, in any session, doesn’t alert. :chat-alerted
goes to the room of the latest alert.
:set chat-alerts all alerts of everything the service would notify you of
(on Matrix, what your push rules on the server notify of),
:set chat-alerts off of nothing. :set chat-alerts-desktop true sends
them to the desktop’s own notifications too (notify-send on Linux,
osascript on macOS), for when no Greed is attached anywhere.
Only new messages alert: what came while Greed was away shows as unread counts in the list.
Chat and agents
Agents have the chat tools, a group they switch on when they need them
(see Agents):
| Tool | Does |
|---|---|
chat_rooms | lists your rooms, channels and direct messages, unread first |
chat_read | reads a room’s latest messages, or older ones; it stays unread |
chat_search | searches every account with the query chat’s search box takes |
chat_send | sends a message as you, asking you every time |
So you can ask for things like:
what did I miss in #infra since yesterday?
did anyone answer my question about the runbook?
tell Bea in our DM that I'm running ten minutes late
What an agent reads of chat is marked as from outside, to read as data:
a message saying “ignore your instructions” is something it read, never
something you asked for. chat_send asks you every time, whatever you’ve
allowed agents, and shows what it would send and where. It doesn’t send
slash commands.
To have an agent keep an eye on rooms for you, escalating what matters and drafting replies, set up a watcher.
What isn’t here, and what happens instead
| Thing | What Greed does |
|---|---|
| Voice and video calls | Greed shows a call starting; enter on it opens it in the service’s own app or web client to join. Greed doesn’t do calls itself. |
| Videos and recordings | Shown as files with their size. enter on a recording or voice message plays it in the background with mpv or ffplay where one is installed (again stops it), else opens it in your system’s player; a video opens in your system’s player. Videos with a small picture show it. |
| Pictures and stickers | Drawn in the room where the window or terminal can show images (Greed’s window, kitty); elsewhere a line with the name. enter opens the picture in Greed. |
| Other files | enter fetches and opens it: a PDF or picture in Greed, the rest in the program your system opens it with. :chat-attach PATH sends one. |
| Link previews | The page’s site, title and a line of what it says, under the message, as the server fetched it: Mattermost where the server has link previews on, Matrix where the server allows them. None in encrypted Matrix rooms, so the server doesn’t learn their links. :set chat-previews false turns them off. No pictures from the pages. |
| Presence | Mattermost’s dot beside a direct message. Matrix servers don’t send it the way Greed syncs, so none there. |
| Read receipts | “seen by” on Matrix. Mattermost has none to show. |
| Polls | Matrix polls show their answers, votes and yours; enter votes for one (one answer a vote). Mattermost polls are made of buttons, which work as buttons. Making a poll isn’t here. |
| Locations | A place shows its coordinates; enter opens it on OpenStreetMap in the browser. A live location is named as one, without where it is. |
| Mattermost Boards, Playbooks, and interactive dialogs a command or button opens | Not supported; open the message in the browser (space .) to use them. |
| Discord, Slack and others | Not supported. |
The programs
Greed talks to each service through a program of its own,
greed-matrix and greed-mattermost, that keeps your accounts connected
and stores what Matrix needs locally (rooms, encryption keys, files it
fetched), locked with a key kept with your sign-in. They come with Greed:
its packages put them beside greed, and Greed starts them from there (or
your PATH); the chat-matrix-program and chat-mattermost-program
options name others. On another machine you reach with greed ssh, the
greed put there brings them along, so greed chat works there too.
Editing styles
Greed has three editing styles, two with modes and one without, and you can switch between them while it runs. Each is a plugin with its own modes, written against the same API, and follows the editor it comes from: Helix’s selections and motions, Vim’s operators, text objects, registers, macros and visual modes, the usual shortcuts of modeless editors. Where one still differs from the original, its section below says so.
| Style | How it works | Like |
|---|---|---|
helix | Select text, then say what to do with it | Helix, Kakoune |
vim | Say what to do, then where: d w, c i w, y y | Vim |
vscode | No modes, VS Code’s keys: typing inserts, shift and the arrows select | VS Code, most editors |
:style vim switch now
:style pick one from a list
Brackets and quotes come in pairs as you type in the helix and vscode
styles, as in those editors, and not in vim’s; :set auto-pairs on or
off changes that for any style (see Using Greed).
The status line shows the style’s name, dim, on the right; clicking it opens the same list. The mode on the left reads the way the style’s editor says it: NORMAL, INSERT, SELECT in Helix’s, VISUAL in Vim’s.
The first time you start Greed it asks which you’d like (:setup asks
again), and :tutor teaches your style’s keys with lines to practise on.
To start in a style every time, set it in ~/.config/greed/init.luau
(with none set, Greed starts in Helix’s):
require("@greed").option.set("editing-style", "vim")
The keys that aren’t about editing live in the leader: space in Helix
and Vim, ctrl-space in the vscode style (where typing a letter inserts
it). After the leader a hint lists what can follow.
| Helix, Vim | vscode style | |
|---|---|---|
space f | ctrl-space f | Find files |
space / | ctrl-space / | Search the project |
space L | ctrl-space L | Search this buffer, listing the lines that match |
Helix and Vim also share : for commands, g d to go to a definition
and ] d to the next problem. Prompts and pickers work the same in all
three.
Keys in every style
Bind keys for the leader or for a role, and they work in whichever style you use, styles added later included:
local greed = require("@greed")
greed.keymap.bind({ layer = "leader" }, { W = "save-all" }) -- space W, or ctrl-space W
greed.keymap.bind({ role = "typing" }, { ["ctrl-s"] = "save" }) -- insert mode, or vscode's mode
greed.keymap.bind({ style = "vim", role = "command" }, { ["g h"] = "line-start" })
The roles are command (Helix’s and Vim’s normal mode), typing
(insert mode, vscode’s mode) and selecting (Helix’s select mode, Vim’s
visual mode). A binding for one style’s role wins over the style’s own
keys, and those win over a binding for every style’s role. Keys
has the whole order.
Helix
Normal mode is for moving and selecting, and every movement selects: w
selects to the next word, x the line, % the whole file. Then a command
acts on what’s selected: d deletes it, c changes it, y copies it.
x d select the line, delete it
x x d select two lines, delete them
% s foo select every "foo" in the file; typing now edits them all
The cursor sits on a character, as in Helix, and is part of what you
select: v l l selects three characters, ; leaves the cursor on the
character it was on, and d on a bare cursor deletes that character.
w, b and e move as Helix’s do.
With :set motion-hints true (off by default), a word motion (w b
e and their WORD forms) numbers the next nine places doing it again
would take you, and typing a number goes there: w 3 instead of
w w w w. In select mode it extends the selection. Right after such a
motion a digit is a number to jump to rather than the start of a count;
any other key drops the numbers. Vim’s style has the same option for
w b e W B E g e g E, in normal and visual mode. The nearest three
numbers use the theme’s ui.motion.hint style and the rest
ui.motion.hint.far; in the window both are drawn as badges, like key
caps. A number sits on the space beside its place when the place is a
letter, so it hides none of the text.
You see what a command will act on before you run it. s, S, C and
alt-s make selections, and every edit then happens at each one, which
covers most of what macros and search-and-replace are used for.
Using Greed lists the keys. The style is the helix
plugin, and its modes are helix, helix-insert and helix-select.
Vim
Vim’s normal mode works the other way round: an operator first, then a
motion saying how far. d w deletes to the next word, c i w changes the
word under the cursor, 3 j moves three lines down. The cursor sits on a
character, and v starts a visual mode for selecting by hand.
| Keys | |
|---|---|
h j k l w b e W B E g e 0 ^ $ g _ g g G % | Move, with counts: 3 w; % to the matching bracket (of the next one on the line, off a bracket), 50 % halfway down |
{ } ( ) H M L - + _ | | Paragraphs, sentences, the top, middle or bottom of the screen, lines, a column |
f t F T + a character, ; , | To the next or previous character on the line; again, or back |
d c y + a motion or text object | Delete, change or copy; doubled (d d) for whole lines |
i w a w i W i ( a " i s i p i t … | Text objects: words, brackets (b B too), quotes, sentences, paragraphs, tags, and the rest of the objects Helix’s m i takes (i f a function, i d a number, i n ( the next parens…) |
> < g c + a motion | Indent, dedent, comment; > > < < g c c for the line |
g ~ g u g U g ? + a motion | Switch case, lowercase, uppercase, rot13 (~ u U in visual mode) |
g q g w = ! + a motion | Rewrap to the text-width option (g w keeps the cursor), reindent, pipe through a command |
x X D C s S | The usual shortcuts for deleting and changing |
r ~ J g J | Replace a character, switch case, join lines (g J without adding or removing spaces) |
ctrl-a ctrl-x | Add to or subtract from the number at or after the cursor, with counts |
p P | Paste after or before |
i a I A o O, g i | Insert; with a count (3 i) what you type goes in that many times; g i where you last stopped typing |
u ctrl-r U | Undo, redo, put back the last changed line |
g - g + | Back or on through every state of the text, across undo branches (space u t shows them all) |
v V ctrl-v | Visual mode, by character, line or block; i/a there select a text object |
o r J p in visual mode | Go to the other end, replace every character, join the lines, paste over the selection |
g v g n | Select the last visual selection again, or the next search match (c g n then . changes match after match) |
y s + a motion or object + a character, d s c s, S in visual mode | Surround, as vim-surround does: ysiw) wraps the word in brackets (( with spaces inside), ds" takes the quotes away, cs"' changes them, yss wraps the line |
alt-o alt-i | Select the syntax node around the cursor, growing it in visual mode, or shrink it back |
alt-shift-right alt-shift-left | Move the selected syntax node past the next or previous one |
K, g r n g r a g r r g r i g r t, g O | As in Neovim: hover, rename, fixes and code actions (and a plugin’s, like linking a note a line mentions), references, implementations, type definition, symbols in the file |
g s | Label the words on screen and jump to the one you type |
ctrl-n | Select the word under the cursor, then add its next match each time, as vim-visual-multi does; c d y i a I A act on every selection, ctrl-x skips a match, ctrl-p drops the last; esc after typing keeps a cursor in each place, and esc then goes back to one |
Z Z Z Q | Save and close, close without saving; in a split, like :wq and :q, they close only that window |
ctrl-^ | The file you were in before, like :b# |
I A in visual block mode | Type before or after the block on every line ($ takes it to each line’s end) |
* # | Search for the word under the cursor, forward or back |
ctrl-f ctrl-b ctrl-d ctrl-u ctrl-e ctrl-y | Page, half page and a line down and up |
z z z t z b, z a z c z o z R z M z f z j z k z d z E | Center the view, cursor line to the top or bottom; folds |
R | Type over the text; backspace puts back what it replaced |
[ space ] space | A blank line above or below, as vim-unimpaired does |
g ; g , | Back and forward through the places you changed |
ctrl-o ctrl-t ctrl-d ctrl-n ctrl-p in insert mode | One normal mode command, indent, dedent, complete from words in open files |
ctrl-o ctrl-i | Back and forward through where you jumped from |
m + a letter, ' ` + a letter | Set a mark (a–z in the file, A–Z across files), go to its line or to it |
. | Repeat the last change, with what it typed |
q + a letter, q | Record a macro into that register, stop |
@ + a letter, @ @ | Play a macro, play the last one again |
" + a letter | Use that register for the next yank, delete or paste; an uppercase letter appends; "0 holds the last yank, "1–"9 the last line deletes, "- a small one |
The Vim style is the vim plugin, plain Luau against the same API any
plugin uses, with its own modes: vim, vim-insert, vim-visual,
vim-visual-line, vim-visual-block, vim-replace and vim-multi.
The unnamed register is the system clipboard, so p pastes what you
copied in another program too; "+ is the same and "_ keeps nothing.
Text from another program pastes as it is, even when it ends in a line
break. Panels like the file tree and help keep their own keys.
Line commands with ranges (:%s/a/b/g, :g/regex/d, :'<,'>norm A;)
are on the command line; Using Greed lists
them. Some of Vim is still missing: a copied block pastes as plain
text (one piece per line), and Vim’s own regex syntax (\(, \<) since
patterns are the same regexes search uses.
VS Code
No modes, VS Code’s keys. Typing inserts text, replacing a selection if there is one, and the keys are the ones VS Code and most editors use.
| Keys | |
|---|---|
arrows, home end, ctrl-left ctrl-right | Move; home goes to the first non-blank, then the line’s start |
pageup pagedown, ctrl-home ctrl-end | A screen up or down, the start or end of the file |
shift + arrows, home end, ctrl-left ctrl-right | Select |
ctrl-a, ctrl-l | Select all, select the line (again for the next one) |
ctrl-c ctrl-x ctrl-v | Copy, cut, paste; with nothing selected, copy and cut take the line |
ctrl-z ctrl-y | Undo, redo (ctrl-shift-z redoes too, where the terminal can tell it from ctrl-z) |
tab shift-tab, ctrl-] | Indent or dedent the selected lines; tab alone types a level of indent |
ctrl-backspace ctrl-delete | Delete a word back or forward |
alt-up alt-down, alt-shift-up alt-shift-down | Move the line up or down, copy it up or down |
ctrl-shift-k, ctrl-enter ctrl-shift-enter | Delete the line, start a new line below or above |
ctrl-d, ctrl-shift-l | Select the word, then add its next match as another cursor; select every match |
ctrl-alt-up ctrl-alt-down, alt-click | Add a cursor above or below, or where you click |
ctrl-/ | Comment or uncomment the lines |
ctrl-f | Find as you type, in any case, with the matches counted (2 of 5); enter and shift-enter go to the next and previous match with the find bar open, esc closes it and leaves the match selected |
f3 shift-f3 | The next or previous match |
ctrl-h | Replace in the file: type what to find (its matches light up and are counted), enter, then what to put instead; enter replaces them all as one change |
ctrl-g | Go to a line: type its number |
f12 shift-f12 f2 ctrl-. | Go to the definition, find references, rename, fixes and code actions (and a plugin’s, like linking a note a line mentions) |
f8 shift-f8, ctrl-shift-m | The next or previous problem, all problems |
ctrl-shift-o ctrl-t | Go to a symbol in the file, in the project |
alt-left alt-right | Back and forward through where you jumped from |
ctrl-u ctrl-shift-u | Back to the cursors before the last command, and forward again |
ctrl-p ctrl-b, ctrl-w | Find a file, switch to an open file, close the file (the one you were in before takes its place) |
ctrl-\ | Split the pane to the right |
ctrl-k then a key | VS Code’s chords: ctrl-k ctrl-0 and ctrl-k ctrl-j fold and unfold everything, ctrl-k ctrl-l folds or unfolds the block, ctrl-k ctrl-i shows what’s under the cursor, ctrl-k ctrl-q goes to the last change, ctrl-k ctrl-t picks a theme, ctrl-k s saves every file |
ctrl-P, alt-x | Pick a command to run from a list; open the command line (: in the other styles) |
ctrl-space | The leader: ctrl-space f finds a file, ctrl-space / searches the project, the rest as space in Helix and Vim |
ctrl-s, ctrl-q | Save; quit, asking first whether to save unsaved files |
Keys with ctrl-shift need a terminal that reports them, such as one with
the kitty keyboard protocol (kitty, WezTerm, foot, Ghostty).
Everything else in Greed works through the leader (ctrl-space),
ctrl-P and the command line (alt-x). Completion comes up as you type.
The style is the vscode plugin: VS Code’s keys over core’s editing
without modes, which another modeless keymap can use the same way (see
below).
Making your own
A style is a few modes with keys bound in them, registered with the
core plugin. It says which of its modes plays each role and which keys
open the leader, and everything bound for those comes with it, with no
plugin having to know the style exists:
local greed = require("@greed")
greed.keymap.bind("mine", { j = "move-down", k = "move-up", i = "insert-mode" })
greed.keymap.fallback("mine-insert", "insert-char")
require("@core").style.define({
name = "mine",
doc = "My own keys",
mode = "mine",
-- Which mode plays each role; insert-mode goes to the typing one.
roles = { command = "mine", typing = "mine-insert" },
-- What the status line shows for each mode.
labels = { mine = "normal", ["mine-insert"] = "insert" },
-- The keys that open the leader, where `space f` and the rest live.
leader = "space",
-- Type brackets and quotes in pairs, unless `auto-pairs` says otherwise.
pairs = true,
})
With that, :style mine switches to it, and it shows in the :style
list and the setup page. What comes with it:
- The leader opens with
space, with the same hint after it. - Keys plugins bind for the command role (
:,g d,] d) work inmine, and the typing keys every style shares (enter,backspace, the arrows,escback tomine) inmine-insert. - The file tree, pickers, help and other panels keep their keys.
- Completion, signature help and Markdown shown as written while typing
follow the typing mode. A style without modes makes its own mode the
typing one (
roles = { typing = "mine" }). repeat-change(.in Helix and Vim) works in any style once bound: it types the keys of the last change again.require("@core").commands.tag("no-repeat", { "my-undo" })leaves out commands that shouldn’t count as one.
The vim plugin, which is the Vim style, is a full example to read.
A style without modes, like a JetBrains keymap, is shorter still: bind its keys in its one mode, and core’s editing without modes (the vscode style’s) does the typing, replacing the selection, and the rest:
local greed = require("@greed")
greed.keymap.bind("jetbrains", {
["ctrl-c"] = "copy-or-line",
["ctrl-v"] = "paste-over",
["ctrl-d"] = "copy-lines-down",
["ctrl-y"] = "delete-lines-at-cursor",
["ctrl-shift-up"] = "move-lines-up",
})
require("@core").modeless.define({
name = "jetbrains",
doc = "No modes, JetBrains' keys",
leader = "ctrl-space",
})
Roles decide where keys live, not what commands mean, so two styles still
differ in what d does. And Vim’s operators read the motion after them
straight from the keyboard, so leader and role keys don’t apply between
d and its motion.
Keys
Every key runs a command, and every binding can be changed from your config. This page covers finding out what keys do, binding your own, and how keymaps are organised.
Finding out what a key does
| Keys | |
|---|---|
space h k | Press a key and see the command it runs, its other keys and where it’s defined |
space h c | Pick a command and see what it does and which keys run it |
space h h | Describe anything: commands, options, events, functions of the plugin API, plugins, modes, editing styles and the objects of the running editor, from one picker |
space h i | Inspect what’s under the cursor, or with nothing there the editor itself: an object’s state, the objects it relates to (enter goes to one, backspace or ctrl-o comes back, ctrl-i goes forward again) and its actions (enter runs one) |
space h o space h e space h a space h p space h m space h s | Describe an option (its value, default and who set it), an event (what handlers get, who listens), an API function, a plugin, a mode and its keys, or an editing style: its modes, the role each plays and its leader |
space ? | Every command, with its keys; enter runs one |
f1 | The keys of the mode you’re in and what each does, in the pane, tab and resize modes and in terminals too |
space h d | Go to a page or heading of this manual, which comes with Greed (:docs WORDS goes straight to one) |
space h / | Search this manual as you type |
space . (alt-. in the vscode style) | What you can do with what’s under the cursor: a file path, a link, a symbol, a problem, a change, a button, the selection; alt-. in a picker does the same for the current item |
space, g, ], … | After the first key of a sequence, a hint lists what can follow, naming the groups of keys that lead further (require("@hints").leader_groups names your own) |
Commands have names like goto-end or select-line, and : runs any of
them by name. Keys starting with space are the leader’s: in the vscode style
they start with ctrl-space instead.
Going back
q and esc go back in anything you read rather than edit: a picture, a
PDF, help, the file tree, a multibuffer, mail, chat. If the thing has steps
of its own they come first, so in mail q takes a thread back to the list,
and in a chat room it stops an answer you started. Then it goes where you
came from, same as ctrl-o, and a float with nowhere to go closes.
In text you edit, q and esc stay your style’s (macros, normal mode),
and in a prompt or a picker only esc cancels, since q is something you
type. ctrl-o and ctrl-i go back and forward through where a pane has
been everywhere.
Binding keys
Bindings go in ~/.config/greed/init.luau. Commands like finding a file
or searching the project live in the leader, a layer every editing style
opens its own way (space in Helix and Vim, ctrl-space in the vscode
style). Bind there and the key works in whichever style you use:
local greed = require("@greed")
-- space q in Helix and Vim, ctrl-space q in the vscode style
greed.keymap.bind({ layer = "leader" }, {
q = "quit",
W = "save-all",
["g p"] = "pick-changed-file",
})
Check a key is free first (space h k, or the hint after the leader): a
binding replaces every longer sequence that starts with the same keys, so
binding the leader’s w alone would take away space w v and the other
window keys. space h k shows what a key hides, under the command it
runs.
Other keys belong to a role. Each style says which of its modes plays each one:
| Role | For | Helix | Vim | vscode |
|---|---|---|---|---|
command | Moving around and running commands | normal mode | normal mode | none |
typing | What you type goes in | insert mode | insert mode | its one mode |
selecting | Moving selects | select mode | visual mode | none |
Bind for a role and the key works in every style’s mode for it,
including styles a plugin adds later; add style for one style only:
-- In every style's typing mode: insert mode in Helix and Vim, vscode's mode
greed.keymap.bind({ role = "typing" }, { ["ctrl-s"] = "save" })
-- In normal mode in every style that has one
greed.keymap.bind({ role = "command" }, { ["g P"] = "pick-changed-file" })
-- Only in Vim's normal mode
greed.keymap.bind({ style = "vim", role = "command" }, { ["g h"] = "line-start" })
For exact control, bind in a mode by its name:
greed.keymap.bind("helix", { ["g q"] = "quit-all" })
The mode names depend on your editing style: helix, helix-insert and
helix-select for Helix, vim, vim-insert and vim-visual for Vim,
and vscode for the vscode style. The status line shows them as NORMAL,
INSERT, VISUAL and so on; Modes and layers lists
them all.
A binding maps a key, or a sequence of keys separated by spaces, to a command name. When the same keys are bound in several places, the more specific wins:
- keys for the kind of buffer you’re in, like the file tree’s
- keys for one style’s role (
{ style = "vim", role = "command" }) - the leader, for the keys that open it
- the mode’s own keys, like those its style binds
- keys for a role in every style (
{ role = "command" }) - keys for every mode (
{})
Within one place, a newer binding replaces an older one for the same
keys, so your config, loaded last, wins over the default plugins. To
change a key a style binds itself, bind it for that style’s role or its
mode; a binding for every style’s role stays behind it. Helix’s g p, for
one, still goes to the previous buffer whatever you bind for
{ role = "command" }.
Roles decide where keys live, not what commands mean: Helix still
selects and then acts, and Vim’s d w reads its motion straight from the
keyboard, so role and leader keys don’t apply after an operator.
Key names:
- Letters, digits and symbols as themselves:
x,X,5,%,/. Capitals are shifted letters. - Named keys:
space,enter,esc,tab,backspace,delete,insert,up,down,left,right,home,end,pageup,pagedown, and the function keysf1,f2and on. - Modifiers in front, joined with
-:ctrl-s,alt-x,ctrl-shift-left,ctrl--for ctrl and minus.
Taking keys away
-- Hide some keys; whatever they did before comes back if the plugin that
-- unbound them is removed
greed.keymap.unbind("helix", { "U", "g w" })
-- Start a mode over: everything bound in it so far is hidden, and bindings
-- made afterwards apply as usual
greed.keymap.clear("helix")
Panes, tabs and terminals
These follow zellij: alt keys that work
everywhere, in every editing style and while typing into a terminal, and
two modes where single keys act until esc.
| Keys | |
|---|---|
alt-h alt-j alt-k alt-l (or alt and an arrow) | Move to the pane or panel (the file tree, an agent) on that side; from a pane at the left or right edge, on to the tab before or after, stopping at the first and last tab. A panel at the edge stays. In a zoomed tab, every pane shows again |
alt-n | A terminal in a new pane, on the pane’s longer side; while floating views are shown, a floating terminal |
alt-f | Hide the tab’s floating views or show them again, where they were (terminals keep running); with none, open a floating terminal |
alt-F | This file in a new floating view (:float-file PATH for another) |
alt-w | Lay the tab’s floating views out with the next float layout: free, one, tiled, cascade |
alt-{ alt-} | Bring the floating view before or after to the front (in one, the one that shows) |
alt-W | Pick a floating view from the dock: its number, or the arrows and enter |
alt-= alt-- | Give the pane more room, or less |
alt-< alt->, alt-1 to alt-9 | The tab before or after (round the ends), or tab N. alt-[ and alt-] too, in terminals with the kitty keyboard protocol: in others they start an escape code |
alt-space | Arrange the tab with the next layout |
alt-m | Swap the pane with the main one |
alt-p | Pane mode: h j k l move, tab the next pane, n / r / d a terminal (anywhere, right, below), v / s this file again (right, below), x close, f zoom in on the pane, g label the panes and go to the one you type (esc leaves the mode), w (or z) hide or show the floats, W another floating terminal, E this file floating, e (or F) float the pane or panel (the tab’s last pane shows another buffer instead) or put a float back, b move the pane to a new tab, t to a tab you pick, P into a panel, T tile the floats, C cascade them, O one at a time, Y pick a float layout, { } the float before or after, H J K L make the pane bigger toward that side, = - resize, R the resize mode, p place a new pane (a frame shows where; h j k l move it, enter opens it, t a terminal, esc cancels), space next layout, y pick a layout, m swap with main, o rotate, [ ] main smaller or bigger, f1 every key, esc done. Keys that open or move something (n, x, b, t, P, y, Y, p) leave the mode |
alt-t | Tab mode: h l (or [ ]) switch, n new, t new with a terminal, x close, r rename (these four leave the mode), f1 every key, esc done |
alt-r | Resize mode: h j k l make the pane, panel or floating view bigger toward that side, H J K L smaller from that side (at the screen’s edge the other edge moves), arrows move a floating view, = - every way, esc done |
The window keys from Vim and Helix follow ctrl-w in normal mode, and
the leader’s w in every style (space w, or ctrl-space w): v and s
split, h j k l move, H J K L swap the pane with its neighbour, w the
next pane, q close, o close the others, t a terminal, z zoom, g
label the panes, f and F open the file named under the cursor below or
to the right, n s and n v a new empty buffer below or to the right. In
the Vim style, g t and g T change tabs.
All of these are ordinary bindings to commands (pane-left,
pane-terminal, tab-next, …), so they change like any other:
local greed = require("@greed")
-- alt-n is something else in my shell
greed.keymap.unbind({}, { "alt-n" })
greed.keymap.unbind("terminal", { "alt-n" })
-- Split with space | and space -
greed.keymap.bind({ layer = "leader" }, {
["|"] = "pane-split-right",
["-"] = "pane-split-down",
})
-- The pane mode on ctrl-p, in terminals too, as in zellij
greed.keymap.bind({}, { ["ctrl-p"] = "pane-mode" })
greed.keymap.bind("terminal", { ["ctrl-p"] = "pane-mode" })
The terminal’s mode takes every key, so the alt keys are bound in the
terminal layer too; unbind a key there as well to let it through to the
program. require("@panes").keys holds the defaults, by layer.
In a terminal, keys go to the program except those bound in the
terminal layer: ctrl-\ to stop typing into it (or esc twice
quickly; once goes to the program), ctrl-space to stop
and open the leader (so ctrl-space f finds a file), and the alt keys
above. Bind more there the same way:
-- ctrl-o finds a file without leaving the terminal first
greed.keymap.bind("terminal", { ["ctrl-o"] = "pick-file" })
Modes and layers
Bindings live in layers. Most belong to a mode:
| Mode | Used by |
|---|---|
helix, helix-insert, helix-select | The Helix style |
vscode | The vscode style |
vim, vim-insert, vim-visual (and vim-visual-line, vim-visual-block, vim-replace, vim-multi) | The Vim style |
terminal | Typing into a terminal (takes every key) |
pane, tab, resize | The pane, tab and resize modes |
view | The sticky view mode (Z in the Helix style) |
The leader layer isn’t a mode: each style’s mode opens it with its own
keys (space, or ctrl-space in the vscode style), and what’s bound in it works
after them. A style can open any layer this way with
greed.keymap.enter(mode, keys, layer). Role layers aren’t modes either:
each style’s mode for a role uses { role = ... } after its own keys and
{ style = ..., role = ... } ahead of them.
A layer can also be limited to one kind of buffer, so a key does something different in the file tree or a picker than in a file. Bound for the kind alone, a panel’s keys work in every style and every mode, ahead of the mode’s own:
-- o opens the file under the cursor, but only in the file tree
greed.keymap.bind({ kind = "tree" }, { o = "tree-open" })
-- Only in Helix's mode, in the file tree
greed.keymap.bind({ mode = "helix", kind = "tree" }, { O = "tree-open" })
-- An empty layer applies in every mode
greed.keymap.bind({}, { ["ctrl-q"] = "quit" })
That’s also how you change the keys of Greed’s own panels: a picker’s are
bound for the kind picker, the file tree’s for tree, help’s for help.
space h k in one shows where a key comes from, like kind:picker -> picker-next. Say you’d rather move through pickers with ctrl-j and
ctrl-k, and drop ctrl-n:
greed.keymap.bind({ kind = "picker" }, {
["ctrl-j"] = "picker-next",
["ctrl-k"] = "picker-prev",
})
greed.keymap.unbind({ kind = "picker" }, { "ctrl-n" })
When a key is pressed, Greed looks first in the layers for the buffer’s kind: the style’s role’s, the mode’s, the leader’s, those of the layers and modes it inherits, then the kind’s for every mode. Then come the style’s role layer, the leader if the keys open it, the mode’s own layer, the layers and modes it inherits (the role’s for every style), and the layer for every mode. The first layer where the keys run a command, or start a longer sequence, decides.
greed.keymap.inherit lets a mode use another mode’s keys, all of them or
only those starting with some prefixes, and what that mode inherits in
turn. Helix’s select mode uses it to keep normal mode’s keys; see
Editing styles.
Binding your own commands
Any Luau function can become a command, and then a key:
local greed = require("@greed")
greed.command({
name = "upcase-line",
doc = "Upper-case the line the cursor is on",
run = function(ctx)
local buffer = ctx.buffer
local line = buffer:line_of(ctx.view:cursor())
local from, to = buffer:line_start(line), buffer:line_end(line)
buffer:edit(function(e)
e:replace(from, to, string.upper(buffer:slice(from, to)))
end)
end,
})
-- alt-u while typing, in every style
greed.keymap.bind({ role = "typing" }, { ["alt-u"] = "upcase-line" })
Writing plugins covers commands, and the rest of the API, in more detail.
Highlighting
Greed highlights code with tree-sitter. A language’s highlights query
gives pieces of the text names like keyword.control.return or
markup.heading.1, and the theme gives each name a style. The names are
the same in every language, so one theme entry styles keywords everywhere.
Files are parsed again in the background after each edit; until that’s
done, the highlights from before move with the text you typed.
A name falls back to its parent when the theme has no entry for it:
keyword.control.return uses keyword.control, then keyword. A theme
can style only the top-level names, or any of the finer ones.
require("@greed").theme.set({
keyword = { fg = "magenta" },
["keyword.control.return"] = { fg = "red", bold = true },
["markup.heading.1"] = { fg = "blue", bold = true, underline = true },
})
The tables below list the names Greed’s queries and themes use; use them
in queries you write. They’re Helix’s names, so its queries work as they
are. A theme entry can also be set for one kind of client only, with tui
and gui parts:
require("@greed").theme.set({
comment = { fg = "bright-black", gui = { italic = true } },
})
Code
| Name | For |
|---|---|
attribute | #[derive(Debug)], decorators |
comment | Comments |
comment.line | // ... |
comment.line.documentation | /// ... |
comment.block | /* ... */ |
comment.block.documentation | /** ... */ |
constant | Constants |
constant.builtin | nil, None, self as a value |
constant.builtin.boolean | true, false |
constant.character | 'a' |
constant.character.escape | \n in a string |
constant.numeric | Numbers |
constant.numeric.integer | 42 |
constant.numeric.float | 4.2 |
constructor | Some(...), new Foo |
function | Functions |
function.builtin | print, len |
function.method | x.len() |
function.macro | println! |
function.special | Preprocessor functions and the like |
keyword | Keywords |
keyword.control | Keywords that change the flow |
keyword.control.conditional | if, else, match |
keyword.control.repeat | for, while, loop |
keyword.control.import | use, import, require |
keyword.control.return | return, break, continue |
keyword.control.exception | try, catch, throw |
keyword.directive | #include, #! |
keyword.function | fn, function, def |
keyword.operator | and, or, in |
keyword.storage | let, const, static |
keyword.storage.type | struct, enum, class |
keyword.storage.modifier | pub, mut, async |
label | 'outer:, a code block’s language |
namespace | Modules and packages |
operator | +, =, -> |
punctuation | Punctuation |
punctuation.bracket | ( ) [ ] { } |
punctuation.delimiter | , ; . |
punctuation.special | ${ in strings, Markdown’s > |
special | Anything else a query wants to stand out |
string | Strings |
string.regexp | Regular expressions |
string.special | Dates, symbols and the like |
string.special.path | Paths |
string.special.url | URLs |
string.special.symbol | :symbol, atoms |
tag | HTML and XML tags |
tag.builtin | HTML’s own tags |
type | Types |
type.builtin | u8, string, int |
type.parameter | T in Vec<T> |
type.enum.variant | Enum variants |
variable | Variables |
variable.builtin | self, this |
variable.parameter | Function parameters |
variable.other.member | Fields, properties, keys |
Prose
| Name | For |
|---|---|
markup.heading | Headings |
markup.heading.marker | The # of a heading |
markup.heading.1 | A level 1 heading, and so on to markup.heading.6 |
markup.heading.2 | |
markup.heading.3 | |
markup.heading.4 | |
markup.heading.5 | |
markup.heading.6 | |
markup.list | List markers |
markup.list.unnumbered | -, * |
markup.list.numbered | 1. |
markup.list.checked | [x] |
markup.list.unchecked | [ ] |
markup.bold | **bold** |
markup.italic | *italic* |
markup.strikethrough | ~~gone~~ |
markup.link | Links |
markup.link.url | A link’s address |
markup.link.label | [label] in a reference link |
markup.link.text | A link’s text |
markup.quote | Block quotes |
markup.raw | Code |
markup.raw.inline | `code` |
markup.raw.block | Code blocks |
Writing queries
Queries are files named queries/LANGUAGE/highlights.scm, in a plugin or in
~/.config/greed/queries; see Using Greed.
In greed repl, tostring(require("@greed").view():buffer():tree()) shows
the current buffer’s syntax tree, which is what a query matches against. A
capture whose name starts with _ (like @_name) is only there for a
predicate and isn’t drawn.
Plugins to install
Plugins for Greed that don’t come with it. Each one lives in a git
repository of its own, with its own docs, and installs with a line in your
init.luau. Once it’s in, :docs and space h d show its docs right
beside this manual.
It’s a really short list for now - one plugin, and it’s mine. I’m hoping yours ends up here too, Adding yours says how.
Themes
Zenbones
Themes that tell code apart by contrast, bold and italic instead of a lot of colors. It’s a port of Michael Chris Lopez’s lovely zenbones.nvim: twelve variants, most of them dark and light, and in the window comments can go in a font of their own.
Like this:
require("@git-plugins").use("https://github.com/johnae/greed-zenbones")
require("@theme").use("zenbones")
It asks for nothing beyond the editor. Repository · Docs
Installing one
The use line just records the plugin. Greed fetches what’s missing in
the background once it’s up, so starting never waits on the network.
A plugin that wants more than the editor (running programs, say, or the
network) asks you first and names what it wants. Each one is pinned to a
commit in plugins.lock next to your config, and :plugins-update moves
them on. Configuration has the rest.
Adding yours
Wrote a plugin others could use? Open a pull request that adds it here, with a few lines on what it does and its install line. What I’d ask of one on the list:
greed checkpasses on the current release, in its own CI;- it has a README and a license;
- it works on its own, without a setup only you have.
Sharing a plugin has how to set one up, docs folder and all.
Writing plugins
Greed’s own features are plugins written against this API, so the default
plugins in runtime/plugins serve as examples: core holds the editing
commands, helix gives them Helix’s keys, grep is the project search,
agent the MCP tools.
Plugins are written in Luau, a typed dialect of Lua. If
you know Lua, the differences you’ll meet are types (local n: number = 1,
optional or checked strictly), if a then b else c as an expression,
backtick strings with {interpolation}, +=, and for k, v in t do
without pairs.
A plugin starts with no access to files, programs or the network; Greed decides what each one may reach (capabilities, and Plugins and the sandbox). The types let Greed check a plugin against its API before it loads, which is also how a plugin an agent wrote is tried before you approve it.
A plugin
A plugin is a folder. Run in ~/.config/greed/plugins, greed new greet
creates one with a working test and type checking set up:
~/.config/greed/plugins/greet/
plugin.toml name = "greet", what it may use
init.luau runs when the plugin loads
test/greet.luau tests, run with `greed test greet`
plugin.toml can list plugins this one uses, like
requires = ["core", "picker"]; they load first and are available as
require("@core") and require("@picker"). A plugin’s init.luau
requires its other files with require("@self/name"), and those files
require each other with require("./name"). A plugin can’t require files
outside its folder.
A plugin that needs something newer than the oldest Greed people run says
which, greed = "0.4", and on an older Greed it doesn’t load and says to
update Greed, rather than failing partway with an error about a function
that isn’t there.
Capabilities
A plugin can edit buffers, add commands, keys, pickers and the rest of the
editor freely. Anything that reaches outside the editor, it declares in
plugin.toml:
name = "greet"
capabilities = ["proc", "fs.read"]
| Capability | What it opens |
|---|---|
proc | Running programs: greed.process.run and spawn, greed.terminal.spawn, greed.lsp.server, typing into a terminal, and a language server’s workspace/executeCommand. A program can do anything you can, so this is full access |
fs.read | Files by path: greed.fs reads, greed.fs.copy, greed.hash.sha256_file, greed.files, greed.load, greed.open, greed.image.load, greed.pdf.open, greed.syntax.tags, greed.syntax.load_grammar |
fs.write | greed.fs.write, mkdir, remove, rename and copy, greed.http.request with save, and buffer:save(path) to a path other than the buffer’s own file |
clipboard | Reading what you copied (greed.clipboard.get, history, and image for the image on the system clipboard of the client you’re at); setting it needs nothing |
net | The network: greed.http to any host, and the Claude Code connection |
net:HOST | greed.http to one host, e.g. net:api.anthropic.com |
secrets:NAME | greed.secrets.get("NAME"), e.g. secrets:anthropic for an API key |
secrets | Every secret, and keeping new ones |
eval | greed.eval, which runs Luau with every capability |
plugins | Loading, approving, unloading and checking other plugins. A plugin it loads can have any capability, so this is full access. Approving still needs you, or a plugin with plugins, to have started it |
commands | Running any command or keys for you with what the command’s own plugin may do, as the command line and the command picker do (see below) |
control | greed.control: answering agents and editors connected to the session, as the agent plugin does |
ssh-agent | greed.ssh_agent.answer: letting a program in a session from greed ssh sign with your ssh key, and setting ssh-agent-confirm |
Using something the plugin didn’t declare raises an error that says what
to add, e.g. greet can't run programs: add "proc" to capabilities in its plugin.toml. Your init.luau and a trusted project’s .greed folder are
config, not plugins, and can use everything.
Capabilities follow the code that uses them, and don’t pass from one plugin to another:
- A command runs with its own plugin’s capabilities when you start it,
with keys, the command line, a menu or your config. When plugin code
starts it, with
greed.runor by feeding keys withgreed.keys.feed, it can do only what that plugin may too, so a plugin withoutproccan’t run programs by running another plugin’s command. This carries on through commands those commands run, what they start withgreed.spawn, and after they wait. A plugin withcommandspasses on whatever it was started with, since it runs what you typed or picked. - Keys a plugin feeds never answer a command waiting for you to press a key, like a “y” to confirm.
- Event handlers run with their own plugin’s capabilities, whatever caused the event: they’re that plugin reacting to what happened. Plugins can’t send events of their own.
- Calling what another plugin offers (
require("@core").project.open(dir)) works with what both plugins may: ifopenwrites a file, the caller needsfs.writetoo. The same goes for a function one plugin hands another, like a picker callback or a hook, and for coroutines a plugin makes: every plugin whose code is running counts. So the plugins Greed ships that run other plugins’ hooks, like core and picker, declare what those hooks need. Code a plugin loads withloadstringcounts as that plugin’s, and plugins don’t getgetfenvorsetfenv. - A plugin that offers a service can vouch for one of its own operations
with
greed.vouch(f, ...): then only its own capabilities count for whatfdoes, not those of the plugin that asked. The models plugin vouches for sending a request with your key, so any plugin can ask a model without being able to read the key, and the key goes only where you let it. Code handed to a vouched function still counts as its own plugin’s. Anything you vouch for, any plugin can make you do, so vouch only for narrow operations you check yourself. - What a plugin registers and another runs later, like a formatter, a block
runner, a project source or a shell alias, runs within the limit of the
plugin that registered it, so it can do no more than that plugin may.
Your own registries can do the same: note
greed.plugin.caller()when something is registered, and run it withgreed.plugin.within(by, f, ...). Hand out copies of what you keep, so callers change it only through your functions. - Luau run with
greed.evalhas every capability, as:luaneeds, even though it runs inside the command line’s code. Callinggreed.evaltakesevalfrom every plugin whose code is running and every one that started it, so a plugin withoutevalcan’t get it by calling or starting one that has it.greed.eval(code, { sandbox = true })runs the code in a fresh environment that can read the editor and edit buffers and nothing else: running programs or commands, changing keys or reaching files fails with an error starting “needs approval:”.
And they limit plugins only: an agent that runs commands in a shell of its own isn’t affected.
A plugin that isn’t one of Greed’s own and declares capabilities loads once
you’ve approved them with :plugins-approve, and one that later asks for
more waits again. Plugins that use nothing beyond the editor load at once,
and installing a plugin an agent wrote approves it. Permissions and
sandboxing has how approving
works, where approvals are kept, and the time budget each call gets.
The plugins folders are watched while Greed runs. A plugin folder that
appears loads, and a plugin reloads when its plugin.toml or code
changes, with no restart. One asking for something you haven’t approved
waits and :plugins-approve opens; until you approve, the version that
was running keeps going as it was. :plugin-reload NAME loads any plugin
again from its folder by hand, Greed’s own included, as after changing its
code.
Checking a plugin that isn’t approved yet (greed.plugin.check, or an
agent’s plugin_try) runs its tests with only what you approved for it,
which before you install it is nothing. A test that needs more fails with
“needs approval”, whether the plugin’s own code asks or a command or
plugin it uses does. greed test from your shell runs a plugin’s tests
with everything it declares.
Commands and keys
local greed = require("@greed")
greed.command({
name = "greet",
doc = "Say hello",
args = { { name = "who", doc = "Who to greet" } },
run = function(ctx)
greed.echo(`hello {ctx.args[1] or "there"}`)
end,
})
greed.keymap.bind({ layer = "leader" }, { g = "greet" })
A command name can’t have spaces, so it can be typed after :. Defining
a command that another plugin already has replaces it, and Greed says so
in a message; your config can replace any command without one. When the
editor starts, it names keys bound to commands that don’t exist, which
usually means a typo. Binding keys another plugin bound to something else
says so too, as does binding keys that hide another plugin’s longer or
shorter ones (g over g z); your config’s keys stay quiet, and space h k shows what a key hides. greed.plugin.check reports all of these as
warnings.
Commands get a context:
| Field | |
|---|---|
ctx.buffer, ctx.view | Where it runs |
ctx.args | The words from the command line (:greet world) |
ctx.count | The count, when one was typed |
ctx.keys | The keys that ran it |
ctx.force | ! was given (as in :q!) |
ctx.char | The character, for keys that type one |
ctx.client | The id of the client that ran it (see Clients) |
The first argument of greed.keymap.bind says where keys go:
| Where | For |
|---|---|
{ layer = "leader" } | Commands people reach for by name. Every editing style opens the leader its own way (space g in Helix and Vim, ctrl-space g in the vscode style) |
{ role = "command" }, { role = "typing" } | Normal mode or typing, in every style’s mode for it, styles added later included |
{ style = "helix", role = "command" } | One style’s mode for a role |
"vim-visual" | One mode, by name |
{ kind = "tree" } | One kind of buffer |
Bindings made later win, and greed.keymap.unbind and greed.keymap.clear
take keys away, so a plugin can rebuild a mode from scratch. A mode is a
name, and it exists once something binds keys in it, gives it a fallback,
a parent or a cursor shape; then greed.mode.set("visual") switches to it.
Switching to a mode nothing made is an error that lists the modes there
are, so a typo can’t leave you where no key works.
greed.keymap.inherit(mode, parent, prefixes)lets a mode use another’s keys (some of them, with prefixes).greed.keymap.enter(mode, keys, layer)opens a layer with keys, the way each style opens the leader; see Editing styles.greed.keymap.fallback(mode, command)runs a command for any single key nothing else takes (a mode inheriting all of another’s keys uses that one’s).greed.keymap.isolate(mode)keeps keys bound for every mode out of one, the way a terminal takes every key.greed.keymap.overlay({ ["1"] = "hint-1" })binds single keys for the next key press only.greed.mode.set_cursor(mode, "bar")sets how the cursor looks in a mode.greed.keymap.find(command)lists the keys that run a command.greed.keys.record(name)andgreed.keys.stop(name)keep what’s typed, for macros and the like; several recordings can run at once.
Keys bound for a kind of buffer alone work in every editing style and
every mode, ahead of the mode’s own, so a panel binds them once, with
{ kind = "tree" }. A buffer kind you type into, like a prompt, says so
with core.style.typing_kind("my-prompt"): focusing one goes to the
style’s typing mode, and core.floats.typing opens a float in it.
core.style.label_kind("my-prompt", "rename") has the status line call
the mode RENAME while one has focus, rather than the typing mode’s name.
Rather than naming other styles’ modes, ask core.style:
is_typing(): whether the current mode types (insert, Vim’s insert, the vscode style)role(): which role the current mode playsmode_for(role): the style in use’s mode for a roleeach_typing(function(mode) ... end): calls back with every style’s typing modes, including styles added later, for modes of your own made from them, like the completion menu’s
Commands can carry tags others check:
core.commands.tag("typing", { "my-type-char" }) keeps them out of the
selection history and in one undo step in the vscode style, and "no-repeat"
leaves them out of what . repeats.
For keys that should mean something in one buffer only for a while,
buffer:set_keys({ y = "my-answer-yes", esc = "my-hide" }) binds single
keys for that buffer, in every mode and ahead of every other binding,
while it has focus; buffer:set_keys(nil) drops them. The agent pane uses
it to answer a question with enter or a letter whatever mode you’re in.
view:set_keys does the same for one view, ahead of its buffer’s keys, so
another view of the same file keeps its usual keys. Slides use it: right
goes to the next slide in the slide show, while the file stays yours to
edit in a pane.
Typed arguments
An argument can say what it is with type, and Greed then checks what the
command is given before it runs, however it runs: from keys, the command
line, greed.run or an agent. The command gets the parsed values in
ctx.values, by name, next to the words in ctx.args:
greed.command({
name = "repeat-line",
doc = "Copy the line a number of times, below or above",
args = {
{ name = "times", type = "number" },
{ name = "where", type = "choice", choices = { "below", "above" }, optional = true },
},
run = function(ctx)
local times: number = ctx.values.times
local where: string = ctx.values.where or "below"
greed.echo(`{times} copies {where}`)
end,
})
:repeat-line abc doesn’t run; it says :repeat-line TIMES [WHERE]: "abc" isn't a number. The types:
type | Takes | ctx.values gets |
|---|---|---|
"string" (the default) | any word | the word |
"number" | a number | the number |
"boolean" | true/false, yes/no or on/off | true or false |
"file" | a file that exists, from the project’s root when relative | its full path |
"folder" | a folder that exists, likewise | its full path |
"choice" | one of choices | the word |
"object" | an object of kind, by its key or label (see Objects) | the object |
"rest" | the rest of the words, last only | them, joined by spaces |
optional = true lets an argument be left out, and it is then nil in
ctx.values; arguments after an optional one must be optional too. Too
few or too many words fail with the command’s usage, as do words that
don’t parse. A spec that can’t work, like a "choice" without choices,
fails when the command is added. Commands whose arguments have no type
work as they always have: nothing is checked, and ctx.values has the
words by name.
A command that takes one object of a kind (its other arguments optional)
is also one of that kind’s actions, so it shows in space . and the
inspector for those objects. Agents find commands with the commands
tool and run them with run_command, checked the same way.
The command line completes a typed argument from its type when it has no
complete: files, folders, true and false, the choices, or the objects of
its kind. greed.commands() lists each argument’s type, optional,
choices and kind, and each command’s usage.
Actions on things
space . lists what you can do with what’s under the cursor, and alt-.
in a picker with the current item. A plugin adds both halves: a finder
that says what’s at the cursor, and actions for a kind of thing. Picker
items get actions by giving a kind, like { label = path, value = path, kind = "file" }.
local actions = require("@core").actions
actions.finder({
name = "ticket",
find = function(view, range)
local buffer = view:buffer()
local text = buffer:line_text(buffer:line_of(range.head))
local id = string.match(text, "%u+%-%d+")
return if id then { { kind = "ticket", label = id, value = id } } else nil
end,
})
actions.action({
kind = "ticket",
name = "open",
doc = "Open it in the browser",
run = function(target)
require("@core").file.open_link(`https://example.atlassian.net/browse/{target.value}`)
end,
})
An action that is an existing command has a short form:
actions.command("text", "search", "search-selection", "Search for it")
(kind, name, command, doc). An action of kind "*" is offered for every
kind, after the actions of everything under the cursor, like the
context’s pin to context.
Things a finder gives with the same group (a string of its choosing),
like the rows a selection covers, are offered as one: each action runs on
every one of them.
Run an action with actions.run(action, target) rather than its run, so
it’s kept in what was done to the thing (actions.history(id), which
history and the inspector show); run may give back the id of what it
made, like a shell block, and quiet = true leaves an action that only
looks out of it.
An action that destroys or stops something says so with danger = true:
actions.run then asks first, with a y/n for one of yours and a review of
them all for several or for an agent’s, saying what each will do
(says = function(target) return "kubectl delete ..." end) and warning
where it’s due (warns). actions.run_all(action, targets) runs one on
several, asking once, and gives back those it ran on. An action that suits
only some things of its kind says which with offers = function(target) ... end, like the kubernetes plugin’s “another resource” on blocks that
run kubectl get.
actions.set_default(kind, name) makes an action what enter does to
things of a kind wherever they’re shown, as a shell row, and puts it first
among their actions;
actions.run_default(target) runs it and says whether there was one.
The kinds Greed itself uses are file, folder, link, symbol,
problem, change (a changed part of a file), button, text (the
selection) and command; the shell adds shell-block, row, cell and
process, the vcs plugin changed-file, commit and revision, the
kubernetes plugin pod, deployment and kubernetes, and the docker
plugin container and image, so a plugin can add actions to those too.
A plugin’s finders and actions go when it’s unloaded.
Objects
The things in a running Greed are objects, each with a kind and an id
(buffer:12, tab:3, shell-block:7.2). An object has its state, the
objects it relates to and its kind’s actions. space h i inspects one, and
agents read them through the describe tool. Greed’s own kinds are
editor (where the inspector starts), buffer, view, tab, plugin,
client, file, folder, terminal, shell, shell-block, language-server,
proposal, agent-session (an agent session: show, stop, close), board,
board-card, note and todo.
A plugin adds a kind for its own things. Everything but the name is
optional: list when there’s a way to list them all, get to find one by
the key in its id, inspect for its state as a table, and relations for
the objects it points at, by name.
local objects = require("@core").objects
local function ticket(key: string): core.Object
return { kind = "ticket", id = `ticket:{key}`, label = key, value = key }
end
objects.kind({
name = "ticket",
doc = "A ticket in the tracker",
get = function(key)
return ticket(key)
end,
inspect = function(key)
local found = tracker.lookup(key)
return { status = found.status, owner = found.owner }
end,
relations = function(key)
local blocks = {}
for _, other in tracker.lookup(key).blocks do
table.insert(blocks, ticket(other))
end
return { blocks = blocks }
end,
})
A kind belongs to the plugin that knows its things. Places that show
things of other plugins’ kinds, like a shell block’s rows, add them with
objects.source({ name, list = function(kind) ... end, get = function(id) ... end, inspect, relations }): objects.list and objects.get ask the
kind first and then the sources, and a source’s inspect and relations
add to the kind’s for values that came from it (nil or {} for others).
objects.shown(id) is the object as a source shows it, for a kind’s get
that would rather give that than ask a program.
What a finder finds is an object once it has an id: the kind’s key(value)
gives one, or the value itself when it’s a string or a number, as a file’s
path is. An object that is somewhere in a buffer says where (buffer,
from, to); objects.act(object, name) then puts the cursor on it before
running the action, so actions that work on what’s under the cursor work
on it from anywhere, the inspector included.
A kind can say how to get its state again from outside the editor with
fresh = function(value) ... end (a table like inspect’s, or nil once
the thing is gone; it may wait on a program). watch, an action every
object has, uses it to look again every watch-interval seconds; a kind
without it is found again by id and inspected.
When the plugin that owns an object knows its state changed, like a
terminal’s agent starting to wait, it says so with
objects.changed(id), and whoever follows the object (a watch, and
objects.on_changed(listener)) looks again at once instead of at its next
look. It’s only a nudge: they read the state again and act on what
differs, so saying it once too often costs a look and changes nothing, and
the regular looks still catch whatever a nudge missed.
objects.list(kind), objects.get(id), objects.inspect(object),
objects.related(object) and objects.at(view) read them.
objects.find(kind, text) is the object of a kind someone typed: by the key
in its id, else by its label; it’s how a command’s "object" argument is
found. A plugin’s kinds go when it’s unloaded.
Going to definitions and hover
g d (going to where something is defined) and space k (what it is) ask
each plugin that answers for them in turn, so one key works for a note’s
[[link]] and a language server’s symbol alike, in every style. An answer
returns whether it handled what’s under the cursor; a fallback, like the
language server’s, is asked only when nothing else answered.
local core = require("@core")
core.lookup.add("definition", function(ctx)
local line = ctx.buffer:line_text(ctx.buffer:line_of(ctx.view:cursor()))
local id = string.match(line, "%u+%-%d+")
if id then
core.file.open_link(`https://example.atlassian.net/browse/{id}`)
end
return id ~= nil
end)
Use "hover" for space k. What a plugin adds goes when it’s unloaded.
Menus of keys
core.transient.show puts a menu at the bottom of the screen listing what
each key does, in groups, like Emacs’s Transient. Switches flip and stay
while you pick; an action runs with the switches that are on and closes
the menu, and any other key closes it. It waits for keys, so call it from
a command. The change stack’s ? is one.
local transient = require("@core").transient
greed.command({
name = "push-menu",
run = function()
transient.show({
title = "Push",
groups = {
{ title = "Switches", items = { { key = "f", doc = "force", switch = "force" } } },
{
title = "Push",
items = {
{
key = "p",
doc = "to origin",
run = function(on)
greed.process.run(if on.force then { "git", "push", "-f" } else { "git", "push" })
end,
},
},
},
},
})
end,
})
Switch keys show as -f and can be typed as f or - f.
Buffers, views and edits
Positions are byte offsets, lines are counted from 0, and a selection is a
list of ranges with an anchor and a head.
local buffer, view = ctx.buffer, ctx.view
local line = buffer:line_of(view:cursor())
buffer:edit(function(e)
e:insert(buffer:line_start(line), "-- ")
end)
Edits made in one edit call are one undo step and are applied together,
so their positions all refer to the text before the edit. Selections move
with the text.
To change the text of every selection and say where each selection goes
afterwards, core.motions.replace_each does the bookkeeping. Return the
new text, which the selection then goes around, or nil to leave that
selection alone. A table says more: place is where the selection goes
(“around”, “keep” for around it the way it pointed, “start”, “end”, or a
number of bytes in), and from and to replace other text than the
selection.
local core = require("@core")
-- Wrap each selection in stars.
core.motions.replace_each(ctx.view, function(i, range)
return "*" .. ctx.buffer:slice(core.text.span(range)) .. "*"
end)
-- Put "TODO " before each selection, leaving a cursor after it.
core.motions.replace_each(ctx.view, function(i, range)
local at = core.text.span(range)
return { text = "TODO ", place = "end", from = at, to = at }
end)
core.textobjects.find(buffer, pos, key, around) finds the text objects every
editing style uses, by Helix’s keys: "w" a word, "p" a paragraph, "("
the parentheses around pos, "f" a function from the syntax tree, and so
on. It gives from, to, linewise, or nil. core.textobjects.pair(char) is
what surround wraps text in for a key.
view:cursor() is the head of the primary selection and
view:set_cursor(pos) makes the selection one cursor there.
require("@core").text.span(range) gives a range’s start and end,
whichever way it points. buffer:line_text(line) is a line without its
line break. buffer:display_column(pos) is the screen column pos is
drawn at, counting wide characters as two columns and tabs up to the next
tab stop, and buffer:at_display_column(line, col) goes back from a
column to a position, which is how up and down keep their column. Tab
stops are buffer:tab_width() apart, which core sets from the language
or the tab-width option; buffer:set_tab_width(n) changes it for one
buffer.
Copying and pasting goes through require("@core").registers, so text
keeps whether it was whole lines in every editing style. A register holds
{ pieces, linewise }, one piece per selection: registers.copy(pieces, linewise) puts them in the register picked with " or on the clipboard,
registers.paste(ctx) gives back what to paste, and registers.join(r)
makes one text of it. Text on the clipboard that Greed didn’t put there
comes back with linewise false.
greed.clipboard.image() waits for the image on the system clipboard of
the client you’re at, as PNG bytes, read on that client’s own machine (so
with greed ssh it’s the laptop’s), or nil. To take pasted images in a
kind of buffer, register with core.images.taker(kind, function(png, ctx) ... end). The paste-image command then hands the image to it: the
window’s paste keys run it when the clipboard holds an image and no text,
and in a terminal, whose paste carries only text, bind a key to it (the
agent box uses alt-v). greed.base64 encodes the bytes for JSON.
greed.open(path) shows a file as text (core.file.open, below, also
knows images and PDFs), greed.load(path) opens one without showing
it, greed.create_buffer(kind, text) makes a scratch buffer, and
buffer:find, buffer:find_all and greed.fs.grep search with regexes.
A scratch buffer goes once nothing shows it, unless buffer:set_kept(true)
keeps it, and buffer:set_line_numbers(false) hides its line numbers.
buffer:set_at_bottom(true) shows a buffer shorter than its view against
the view’s bottom edge, like a chat with its box at the bottom. Its views
don’t scroll past its end either.
Places that move with edits
To find a place again after the text around it changed, say where a command should put its result once a slow program finishes, track it:
local here = buffer:track(pos) -- a position
local line = buffer:track_range(from, to) -- a range
-- ... edits happen, here or elsewhere ...
here:pos() -- where it is now
local from, to = line:range() -- nil, nil once its text was deleted
line:deleted()
here:forget()
Gravity says what happens to text inserted exactly at a tracked place.
A position with { gravity = "right" } (the default) ends up after the
new text, and with "left" it stays before it. A range takes from and
to gravities, one per end. By default text typed at either end stays
outside, and { from = "left", to = "right" } takes it in. Deleting text
around a position moves it to where the deletion was. A range is deleted
once all of its text is, and stays deleted even if undo brings the text
back; one that started empty never is.
Nothing draws tracked places, and each has its own handle, so two
commands tracking the same buffer never get in each other’s way. They go
when you call forget, when the buffer closes, or when your plugin is
unloaded. After that pos and range give nil.
Buffers, views and terminals are handles: two handles to the same one are
equal with ==. A handle you keep can outlive what it refers to.
handle:valid() says whether it’s still there, and handle:id() keeps
working after it’s gone, while its other methods fail with an error.
-- The panel this plugin shows, reused while it's open.
local panel: greed.View? = nil
local function show(buffer: greed.Buffer)
if panel and panel:valid() then
panel:show(buffer)
else
panel = greed.panel(buffer, { side = "right" })
end
end
Paths and the files behind them
Buffers know their files by full path, with . and .. worked out, so
greed.buffer_for(path) finds a file’s open buffer however the path is
written (or gives nil, without opening it), and greed.buffer(id) finds one
by its id, as events give it. Paths an agent or a user gives a plugin are
relative to the project, and so are relative paths greed.fs takes:
greed.fs.read("notes.md") reads the shown project’s notes.md, wherever
Greed started. core.project turns them into full paths and back:
local core = require("@core")
core.project.resolve("src/main.rs") -- the shown project's root/src/main.rs; ~ is home
core.project.resolve("a.rs", "/tmp/x") -- from another folder
core.project.relative(path) -- "src/main.rs", or the full path outside the project
core.project.short(path) -- like relative, but "~/..." under your home folder
core.project.tilde(path) -- "~/src/greed" for a path in your home folder
core.project.basename(path) -- "main.rs" for "src/main.rs"; nil for "/"
core.project.identity(root) -- the repository's store, the same in all its workspaces
core.project.nearest(dir, ".git") -- the nearest folder from dir up holding .git, or nil
core.file reads and writes files the way you’d want an agent to:
core.file.text(path) is the text as you have it, unsaved changes included,
and core.file.write(path, text) goes through the open buffer, so undo takes
it back and the language server sees it, then saves; a closed file is
written to disk. { from, to } replaces just that part, and { load = true }
opens the file first. Both take paths as core.project.resolve does, and
core.file.buffer(path) is the open buffer for one.
core.formula works out formulas: Luau’s expressions, read and worked out
by Greed itself rather than run as code, so they always finish and can only
make a value. core.formula.compile(source) reads one (or gives nil and why
not), core.formula.eval(f, scope) works it out with names from scope (a
table, or a function asked for each name) and gives the value or nil and
what went wrong, in words for whoever wrote it. core.formula.show(value)
is how a value shows. Formulas call only the built-in functions (sum,
avg, count, min, max, round, fixed, …) and those plugins add:
core.formula.add("money", function(n) return string.format("%.2f kr", n) end, "A sum in kronor")
A function you add runs as the formula is worked out, so keep it quick.
A buffer of your own with no file, like a page of results or a command’s
output, can be scratch: core.file.scratch(buffer) keeps its changes from
counting as unsaved, so :q doesn’t refuse over them and the status line
shows no [+], until it’s saved as a file. core.file.unsaved(buffer) says
whether a buffer has changes to save. core.file.before_save(name, hook)
runs hook(buffer, how) just before a file is written, as formatting does;
how.auto is true when auto-save writes it, so skip what would change the
text under someone who only paused. A buffer someone types into in turns,
like a prompt, can let go of its undo history with buffer:clear_history(),
so undo never reaches past the last turn. To tell someone how to set a
secret, greed.secrets.variable("anthropic") is the variable that does
(ANTHROPIC_API_KEY).
To show a file to the user, core.file.open(path) opens it in the main
view, as the picture for an image and the pages for a PDF, and
core.file.open_at(path, line, col) puts the cursor there too (0-based
line, byte column). A file Greed can’t show goes to the program that opens
it, as the user’s core.file.open_with says; core.file.opening(path, mime)
says beforehand how one would open (“viewer”, “text”, “outside”, “binary”
or “refused”) and in words, as mail does under each attachment, and
core.file.open_outside(path) hands one out (never a program).
core.file.open_link(uri) opens a web address with the link-opener
option or the system’s opener, showing it to copy when it can’t;
core.file.open_web(uri) tries the same quietly and says whether it
went, for a plugin that shows the link its own way. core.file.open_page(path) a page a
plugin wrote in the browser. A plugin that shows some kind
of file its own way registers an opener; it goes when the plugin does:
core.file.opener(function(path)
return string.match(path, "%.csv$") ~= nil
end, function(path, views)
local table_buffer = greed.create_buffer("csv", render(path), { readonly = true })
for _, view in views do
view:show(table_buffer)
end
return nil -- or why it can't, and the file opens as text
end)
Files opened another way, like greed FILE from a shell or greed.open,
open as text first and the opener then takes over the views showing them.
Links of a scheme of your own, like ticket:PROJ-12 in a note, open in
Greed once a plugin says how; open_link then calls it, wherever the link
was:
core.file.link_scheme("ticket", function(uri)
show_ticket(string.sub(uri, #"ticket:" + 1))
end)
For files on disk with no buffer, greed.fs has the usual operations, so
a plugin needs no rm or mv. Each returns true, or nil and why. Paths
starting with ~ are in your home folder, as in a shell:
greed.fs.write(path, text) -- creates its folders too
greed.fs.write(path, text, { private = true }) -- readable only by you (0600)
greed.fs.write(path, text, { background = true }) -- on another thread; waits like greed.sleep
greed.fs.mkdir(dir) -- and the folders above it
greed.fs.copy(from, to)
greed.fs.rename(from, to)
greed.fs.remove(path) -- a file, link or empty folder
greed.fs.remove(dir, { recursive = true }) -- a folder and all in it
greed.hash.sha256(text) -- hex, to tell if text changed
greed.hash.sha256_file(path) -- to check a download
greed.hash.random(32) -- 32 random bytes as hex, for a one-time code
Something already gone counts as removed. remove and rename raise an
error rather than touch the root folder, your home folder, a path with ..
in it or a folder holding Greed’s own approvals or secrets, so a path built
wrong can’t take more than it should. greed.fs.stat(path) says what’s
there: its kind, size, mode and when it was modified (seconds
since 1970). greed.hostname() is the machine’s name, and
greed.fs.dirs() gives the folders Greed uses: home, config, cache,
data, temp (the system’s folder for temporary files) and, at the far
end of greed ssh, brought, the copy of your config it brought.
History
Every edit is recorded with who made it and why. buffer:history() lists
the transactions, newest first, each with its author ("user",
"plugin", "agent" or "external"), cause (the command it was made
for), time, group and changes. Filter by any of those, or with
since and limit:
-- What did the user just change?
for _, tx in buffer:history({ author = "user", limit = 5 }) do
print(tx.cause, tx.changes[1].text)
local before = buffer:text_before(tx.id) -- the text before it
end
A command’s edits carry its name as their cause; greed.history.set_cause
names them otherwise. To make edits in several buffers undo as one step,
put them in a group:
local group = greed.history.new_group()
greed.history.set_group(group)
-- ... edit any buffers ...
greed.history.set_group(nil)
greed.history.undo_group(group) -- every buffer back, or nil and why not
Undoing a group refuses, and changes nothing, when something was done on top of it in one of the buffers since.
Undo keeps every branch. buffer:undo_tree() gives every state the text
has been in, { nodes = { { id, parent, children, time } }, current },
where node 0 is the text as loaded and undo goes to a node’s parent; and
view:undo_to(id) takes the text to any of them, on any branch, which is
what alt-u and the undo-tree plugin’s viewer are built on.
buffer:undo_save() gives the tree as JSON and buffer:undo_restore(json)
takes it back for the text as it is now, only while nothing was done since
the buffer was loaded; that’s how undo lasts across restarts.
A buffer whose edits nobody undoes, like a terminal’s or a log a plugin
keeps adding to, can stop keeping them with buffer:forget_history(), so
it doesn’t grow without end.
When a plugin writes into a buffer someone also types in, like output
streaming in above a prompt, buffer:edit(f, { undo = false }) keeps its
edit out of undo: undo skips it and still takes back only what was typed,
moved to wherever the plugin’s text put it. Redo can’t go down other
branches after such an edit, and typing the plugin’s edit replaced or
deleted is no longer there to undo.
buffer:edit(function(e)
e:insert(output_end, line .. "\n")
end, { undo = false })
The operations plugin builds on groups: it names the work, remembers the
files it changed and the programs it ran, and gives it a review and an
undo key.
local operations = require("@operations")
operations.run("rename parse to parse_line", function(op)
-- edit any buffers, then
operations.exec(op, { "cargo", "test" })
end)
Syntax trees
Buffers in a language with a tree-sitter grammar have a syntax tree.
buffer:node_at(pos) is the smallest named node there, and nodes know
their kind, from, to and field, and can go to their parent(),
children(), child("body"), next() and prev().
buffer:query(source) runs a tree-sitter query and returns each match as
a table from capture name to node:
-- Select the name of every function in the file
local ranges = {}
for _, m in buffer:query("(function_item name: (identifier) @name)") do
table.insert(ranges, { anchor = m.name.from, head = m.name.to })
end
view:set_selection({ ranges = ranges, primary = 1 })
tostring(node) shows the node’s subtree, which helps when writing a
query. A node describes the text as it was when you got it; after an
edit, find it again. Right after an edit that would take a while to parse
(a big file, or code tree-sitter has to recover from), the tree is the one
before with the edit applied, its nodes moved along with the text, until
the new one comes a moment later.
Each language’s queries are in greed.syntax: greed.syntax.query("rust", "textobjects") is the one in use, and greed.syntax.set_query sets one.
A plugin can also ship them as files in its own queries/LANGUAGE/ folder
(see Configuration), and the
plugin.loaded event says when a plugin with some arrives.
Folding uses a language’s folds query, or indentation without one. To
fold a language another way, give core a provider that returns the first
and last line of the block around a line:
require("@core").folds.provider("org", function(buffer, line) ... end).
Markdown folds sections this way. New lines’ indent works the same way,
with the indents query and require("@core").indent.provider, whose
functions get the buffer and the place a line break goes in and return the
new line’s indent.
The editor can have several projects open. greed.project.current() is
the one shown, with its root; greed.project.open, switch and close
manage them, and buffer:project() says which one a buffer belongs to.
Panels belong to the project they were opened in, so a plugin that keeps
one (like a results panel) should keep one per project.
Each project has tabs (greed.tab.list, new, switch, close,
rename), and each tab has panes laid out side by side and one above
another. view:split("right", buffer) opens a pane, view:neighbor("left")
finds the one beside it, view:resize("down", 2) moves its edge, and
view:close() closes it. greed.view() is the focused view, greed.view(id)
the view with that id (nil once it’s closed), and the shown tab’s active
pane is where greed.open opens files. Tab ids work whichever project the
tab is in: greed.tab.switch and view:focus() on a tab or view of
another project show that project.
greed.tab.layout() gives a tab’s arrangement as a tree, and
greed.tab.set_layout(tree) arranges its panes another way:
local a, b, c = table.unpack(greed.tab.current().panes)
-- a across the top, a quarter high; b and c side by side under it
greed.tab.set_layout({
split = "column",
sizes = { 1, 3 },
children = { a, { split = "row", children = { b, c } } },
})
Showing things
-
Decorations style text without changing it, and move with edits:
buffer:decorate("my-plugin", { { from = 0, to = 5, style = "diagnostic.error" } }). A mark can style whole lines, add virtual text inside or after a line, put a sign in the gutter, or draw text over the buffer’s (like jump labels). Other things a mark can do:-
overlaydrawstextover what’s there rather than inserting it, so nothing moves, the cursor included. It goes on past the end of a line too, where its spaces only move the rest along. That’s how rulers sit at their column, even on a blank line:{ from = line_end, to = line_end, text = " ┊", overlay = true, style = "ui.ruler" }. -
wrappeddrawstextat a line’s start again on each row the line wraps onto, so a bar beside a card or a quote doesn’t stop halfway:{ from = line_start, to = line_start, text = "▎ ", wrapped = true, style = "agent.you" }. -
concealhides text (like a link’s brackets), shown again asrevealsays:"line"(the default) when a cursor is on its line,"cursor"when one is inside it,"never","auto", which follows the mode: on the cursor’s line while typing, otherwise once the cursor is inside it past its start (as themarkup-revealoption says), or"typing", as"auto"while typing and never otherwise, as for a table’s borders. Markdown and notes use"auto", so their marks stay as they are when the mode changes (greed.reveal(how, typing)is what core calls as it does). -
plain = truedraws a mark’s text without syntax highlighting, as for a tool’s output in a Markdown buffer. -
language = "bash"highlights a mark’s text as that language (a name or a file extension, like"rs"), over the buffer’s own, its styles andplain. Languages inside it are found too, so alanguage = "nix"mark colours the shell in its build phases. The agent transcript marks the commands its tools run this way. -
foldfolds lines away under the first one; withpeekthey show while a cursor is on that first line too. -
nowrapkeeps the lines it touches from wrapping, cut at the edge with the view scrolling sideways to the cursor (view:side_scroll()). -
linesshows lines that aren’t in the buffer under its own, whole or in pieces with styles of their own. -
action(a command name) makes a mark’s text a button: clicking it, orenteron it in normal mode, puts the cursor at the mark and runs the command. -
scale = 2(up to 4) makes its text bigger, like a heading: each character takes twice the cells across and its row two rows down. The window draws it big, and so does kitty; other terminals show it at the normal size. -
gutterstyles the line numbers of the lines a mark touches. -
datakeeps anything you like with a mark (plain tables, strings, numbers), given back bybuffer:decorations(ns).
buffer:decorate(ns, marks, { from = a, to = b })replaces only the marks starting fromaup tob, for plugins that draw again only the lines an edit changed.buffer:marks_at(pos)gives the marks over a place in every namespace.view:decorate(ns, marks)is the same for marks one view draws and the others don’t, like blame for the line the cursor is on in one pane of a file that’s open in two. It replaces only that view’s marks inns, and they go when the view closes. Every client sees them in that pane. Language servers’ diagnostics are marks too, in the"diagnostics"namespace, which is how they follow edits, and the lsp plugin draws their signs and messages in"lsp".view:hide_marks({ "diagnostics", "lsp" })leaves a namespace’s marks out of one view, as slides do;view:hide_marks(nil)draws them all again. -
-
view:set_padding({ top = 4, left = 8 })leaves rows empty above a view’s text and cells empty left of it, like a slide’s margins; itssize()is then the room inside, for centring what’s in it.view:hide_cursor(true)draws no cursor or selection in one view, like a slide of text;view:hide_cursor(false)draws them again. -
Multibuffers show excerpts of many files in one buffer, edited in place:
require("@multibuffer").open({ { path = path, from = 9, to = 12 } }, { summary = "3 places" })gives a buffer to show in a panel or float, or in the shared results panel with.show(buffer, "Title"). An excerpt can carrymarksto style ranges in it and anoteshown after its file’s name. Edits in it change the files as you type, and changes to the files show in it. Search results, references and the problems list use one. -
Images:
greed.image.load(path)reads a PNG, JPEG or GIF and gives an id, and a mark withimage = { id = id, cols = 20, rows = 8 }draws it over that many cells from its start.greed.image.cells(id)says how many cells it covers at its own size, andgreed.image.cell_size()how many pixels a cell is. -
PDFs:
local doc = greed.pdf.open(path)reads one,doc.pagescounts its pages,doc:render(page, scale)draws one as an image id atscalepixels per point, anddoc:text(page)gives its text, line by line. All three wait, likegreed.sleep. -
Web pages:
greed.html.read(html, url)gives a page’s main content as Markdown in.text, without menus, footers and banners, as a browser’s reader view does, with.titleand.excerptwhen it has them. A page without an article, like a list of links, comes as all its text, and.articlesays which. It waits, likegreed.sleep. -
A view can show part of its buffer:
view:narrow(from, to)shows only those lines (no arguments shows all again), andview:set_filter(text)keeps only the lines with every word oftext, as/in a shell block does, fields likelevel>=warnand.a.bsections included; the other lines stay in the buffer. -
Floats show a buffer over the main view, and panels beside it:
greed.float(buffer, { title = "Info", width = "60%" }),greed.panel(buffer, { side = "right", width = 40 }). For text to read,core.floats.show_text(title, text, { kind = "my-info" })opens a read-only float thatescorqcloses, replacing the one before of that kind;anchor = "cursor"with awidthandheightopens it small by the cursor, like a hover. For a float to type in, like your own prompt,core.floats.typing(buffer, spec, { on_change = ..., on_close = ... })switches to the editing style’s typing mode (insert, in Helix’s and Vim’s) and puts the mode and focus back however the float closes, whether by itsclose()or by closing its view; it’s what the prompt, pickers, the command line and the completion menu use. A float’s spec can also put text on its border (labelat the right of the top,footerin the middle of the bottom, plain or in styled pieces), leave the border off (border = false, for a one-line strip), or hide it (hidden = true: its view and buffer stay, and focusing it shows it again;greed.floats({ hidden = true })lists hidden ones too). Sizes and places (x,y) are cells, or shares of the screen like"37.5%", which keep a float in proportion on every attached client’s screen;core.floats.in_shares(box)turns a box in cells into those.anchorputs it in a corner or at an edge ("top-left","right", …) whenxoryis left out. With several clients attached, a float is shown only to the client it opened for, like a picker or a prompt, unless it’sshared = true(meant for everyone, like a review) or belongs to a tab (tab = true). Keep what a float you open belongs to apart for each client too, bygreed.client.id(). To show something in a float of the tab, laid out by its float layout, userequire("@panes").floats.show(buffer), and say something needs the user withcore.attention.set(key, { label, reason, buffer }), wherekeyis the thing’s object id (terminal:12) andbufferwhere to look; its float gets a dot, andcore.attention.list()gives everything waiting, oldest first. Withtell = truethe hub tells the user of it wherever they are, as it does an agent waiting (a chat message for them, say).core.attention.set(key, nil)takes it off. -
Pickers (
require("@picker").pick(title, items, choose, options)) filter a list as you type, with an optional preview, or ask a function for items as the query changes.on_movehears each item as it becomes the current one andon_cancelhearsesc, for trying things out live. Withpaths = { dirs = true, choose = function(path) ... end }, typing a path lists the folder’s contents, andtabcompletes one into the query.tags = function(item, word) ... endmakes words like@shellin the query keep the items it says have them, asspace spacedoes with kinds.keys = { ["ctrl-e"] = function(items, current) ... end }adds keys of the picker’s own, andfallback(query)runs onenterwhen nothing matches.require("@picker").add_places(name, function() ... end)adds places of your own tospace space, each{ kind = "session", label = "notes on eris", tags = { "eris" }, go = function() ... end }, after the buffers;@kindand@tagkeep them andenterrunsgo. Withactions = { { name = "stop", run = function() ... end } },ctrl-aoffers them. -
An action that decides for the user, like answering an agent’s question, is
yours = trueincore.actions.action: an agent asking for it throughactis refused. -
The completion menu asks sources before the language server, in any buffer, a file or not:
require("@lsp").completion.source(function(view, ask) ... end)returns items like{ label = "src/", text = "src/", from = 12 }(fromis where the text it replaces starts; the word before the cursor by default), or nil to leave it to the next source.detailshows dimmed after the label, andbadgegoes between the two, a word saying whose it is (the shell’s own things saygreed).ask.explicitis true when you asked withtaborctrl-spacerather than by a pause in typing. A source can wait, for a program say; its answer is dropped if more was typed meanwhile. A second argument says how its menu behaves:{ enter = "selected" }hasentertake only an item moved to whilecompletion-enterisauto("first", the default, takes the first);tab = "insert"makestabcomplete in place as a shell does (the only match or what all matches start with at once, then each item in turn); andarrows = "after-tab"leavesupanddownto the buffer while a menu that opened by itself hasn’t been moved into. The shell completes its prompt this way, with all three. Withadds = truea source doesn’t decide alone: what it offers goes after the language server’s items, as the words from open files do. Withfirst = trueit’s asked before the sources already there, as Hoard’s/menu is, ahead of completing paths. A plugin that bindstab,enteror the arrows for typing in its own kind of buffer callscompletion.keys_over(kind)so the menu keeps those keys while it’s open. -
The theme maps style names to looks, as in
greed.theme.set({ ["my-plugin.match"] = { fg = "yellow" } }). Use your own names so users can restyle them. Themes themselves go under those entries:greed.theme.base(entries)replaces the whole base, which is how the theme plugin switches themes. -
The status line is pieces you can add to or take away from with
require("@statusline").addand.remove, or replace withgreed.statusline. A piece returning{ text = "3 due", action = "notes-agenda" }runs the command when clicked, andstyle = "ui.statusline.warning"draws it as a warning. A piece that takes time to work out, like a repository’s state, goes in withadd_async(side, name, { refresh, every, on }):refreshruns in the background (everyeveryms, and on the events inon) and the status line shows what it last returned, never waiting for it. A plain piece that takes over 10 ms to draw, three times in a row, is moved to the background the same way. -
greed.client.notify(title, body)sends a notification to your desktop through the client you used last: the terminal shows it (OSC 9, or OSC 777 in foot and urxvt) with a bell while it isn’t focused. -
Features are what a plugin turns on for some buffers beyond their language, like notes for Markdown in the notes folder. Name yours with
require("@core").features.add("todos", function(buffer) return ... end), and the status line shows it after the language (markdown · todos).core.features.of(buffer)lists the ones on. -
Choices in Markdown (
- ( ),- (x)) are read withrequire("@markdown").choices.list(buffer): each group with its question (the line above it) and its options,pickedor not.choices.on_pick(fn)hears each pick, after the text has changed. A pick only edits text; what it does is up to the plugin listening. -
require("@markdown").document(buffer)shows a Markdown buffer the way the reading view does, for good: read-only, no markup, code in its language’s colors and links to follow. Hover info uses it, like this:local view = core.floats.show_text("Hover", text, { language = "markdown" }) require("@markdown").document(view:buffer()) -
require("@markdown").structure(buffer)reads a Markdown buffer once per edit and gives itsheadings(level, text, lines),codeblocks (info string, fences’ lines, the code’s bytes), listitems(bullet, todo box, lines),tablesandlinks, withheading_at,code_at,item_atandtable_atby line, and the lines’ text. It uses the syntax tree, so a# commentin a code block isn’t a heading. Give it a file’s text instead of a buffer to read that.markdown.conceal({ ns, wants, draw })draws marks over the Markdown bufferswantssays, callingdraw(buffer, structure, first, last), which returns the marks, for the lines an edit changed (and any code block or table they touch) rather than the whole file. It returns a function that draws a buffer, or all of them, again in full.markdown.drawn(buffer)says whether a buffer shows as a document, forwants.markdown.values.scope(buffer)is what its formulas can name (fields,lets, tables, answers), to work out acore.formulathere.markdown.values.provide({ names, value })adds names a buffer’s text doesn’t hold, like the data plugin’s tables. -
require("@core").uidraws an interface as a buffer’s text and marks, so search, copy and an agent’sreadwork on it as on any text, the same in the terminal and the window. A view is a function from its state to widgets;ui.mount(buffer, render, state)draws it for the width of the buffer’s views, andview:set(patch)merges into the state and draws again, changing only the lines that changed (Building interfaces is a guide, with a worked example):local ui = require("@core").ui local view view = ui.mount(buffer, function(state) return ui.column({ ui.field("search", state.query, function(text) view:set({ query = text }) end), ui.table({ columns = { "name", "total" }, rows = state.rows, on_open = show }), ui.row({ ui.button("Refresh", refresh), ui.toggle("Live", state.live, set_live) }), }) end, { query = "", rows = {}, live = false })text,line(ofui.spans),column,row,box,gap,button,field(asks with a prompt),toggle,list,grid(columns lined up without borders, as the agent sessions list is) andtableare there. A widget is pressed withenter,spaceor a click, andtabandshift-tabgo between them; the cursor is the focus, so each client has its own. A span’svalueis what its line stands for, found withview:value_at(pos)(a list’s item, a grid’s row); on a line of several things, like a strip of tabs,value_atgives the value of the span atpos;ui.list(items, spans, { open = f, current = n })opens an item when pressed and marks rownas a menu’s selected one, for a list whose cursor is elsewhere, like a picker’s under its query. Withui.mount(..., { key = function(value) return value.id end })each cursor stays on its item as the lines change places. A span’stagis found withview:spots(tag), and itslinestyles its whole line.For a long view that changes at one end, like a chat streaming in, wrap each part in
ui.keyed(key, version, build): a part whose version is the same as last time isn’t laid out or drawn again, so a token costs what its message does.view:soon(patch)draws once for a burst of changes:ui.column(map(messages, function(m) return ui.keyed(m.id, #m.text, function() return ui.text(m.text) end) end))A keyed part is laid out again for a new width too, unless
ui.keyed(key, version, build, { any_width = true })says its lines don’t depend on it (the view wraps them, as it does a message’s text). While a view goes on resizing, as when its edge is dragged, it’s drawn at once, then at most every 100 ms, then for where it ends.With
ui.mount(..., { input = true })the view is drawn at the top of the buffer and what’s written under it is yours, like a chat’s box:view:input()reads it, and the view is read-only above it. A span’smarksare drawn with it, counted from its start;view:each(f)goes through the lines with values;nsandwidthchoose the namespace of its marks and how wide it’s laid out.view:line_of(f)finds the first line whose valueftakes,view:value_on(line)gives a line’s value, andui.matched(text, positions)picks out what a fuzzy search matched, as menus show it. Withdraw = falsea view is drawn first at its firstredraw, so it can be mounted while what it draws from is being made.ui.pieces(node.lay(width))gives a node as a mark’slines, as the data plugin draws its tables under a block. -
require("@core").datais where tables of data come from: one shape,{ columns = { { name, kind? } }, rows = { { [name] = value } } }, and sources by name.data.source({ name, doc, runs?, read, watch?, actions? })adds one:read(ask)gives the table for an ask (args,body,valuesto bind as parameters,dir,limit,offset), and may wait. A source thatrunsa program or reaches a service is let run per file as code blocks are.actions, each{ name, run(row), close? }, are offered as buttons under a row when it’s opened from the table; a row can carry values besides its columns for them to use.data.read(name, ask)reads one, and a Markdown block named after a source shows its table (the data plugin).
Clients
Several terminals or windows can show one session at once, like your
desktop and a laptop over greed ssh. Each is a client, with its own
cursors, focus, mode, half-typed keys and macro recording; buffers and
their undo history are shared. Code always acts for one client: a command
for the client whose key, click or menu ran it, an event handler for the
client the event is about, and what either starts (greed.spawn, a timer)
for the same client. greed.view(), greed.mode.get(), greed.next_key()
and selections all belong to that client.
greed.command({
name = "who",
run = function(ctx)
local me = greed.client.current()
greed.echo(`{me.name} ({me.kind}), one of {#greed.client.list()}`)
end,
})
greed.client.current() and greed.client.list() describe clients:
id, name (like tui@laptop), kind, remote, size, layout,
color (the color its cursors show in for the others) and person.
ctx.client is the id of the client a command runs for, and events about
a client carry it as event.client.
Other sessions can be asked how they’re doing, as greed ls does:
greed.session.status(name) gives what the session name on this machine
says of itself (session, attention, agents), and
greed.client.home(client) what the hub on the machine a client attached
from says, for a session over greed ssh to show what waits back home.
Both ask as an ordinary client, so nothing there can be done through
them, and both wait, so call them from a command, a handler or
greed.spawn.
Waiting
Commands and event handlers can wait without freezing the editor, and waiting always looks the same: the call returns once the answer is there.
greed.command({
name = "rename-file",
run = function(ctx)
local name = core.prompt.ask("New name", ctx.buffer:path())
if name == nil then
return -- cancelled
end
local moved = greed.process.run({ "git", "mv", ctx.buffer:path(), name })
if moved == nil or moved.code ~= 0 then
greed.echo(moved and moved.stderr or "git isn't installed")
return
end
local choice = picker.choose("Open it?", { { label = "yes" }, { label = "no" } })
if choice and choice.label == "yes" then
greed.open(name)
end
end,
})
These wait like this:
greed.sleep(ms),greed.next_key(),greed.process.run(...),greed.http.request(...),greed.lsp.request(...),greed.fs.grep(...)andgreed.plugin.check(...)picker.choose(title, items)andcore.prompt.ask(title), which give nil when you close them
picker.pick and core.prompt.open take callbacks instead, for pickers
that stay open while you work. core.prompt.open returns the prompt’s
view, to put a label on its border, and its kind option gives the prompt
keys of its own, the way the vscode style’s find bar binds enter to the
next match.
An item can have a detail beside its label: it’s dimmed in a column of
its own, lined up after the labels, and what’s typed matches it too. One
too long for its column is cut, except the current item’s, which shows in
full under its row. Like this, from the outline:
{ label = "recorded_uids", detail = "function line 43", value = pos }
greed.signal() lets one piece of code wait for a value another sends,
one waiter each. core.joined(f) makes f(key) run once for calls that
come at the same time with the same key: the others wait and get what it
gave, so a program several ask for at once starts once.
] m and [ m move by item in any buffer made of items. Say where yours
start with core.items.provide(kind, starts): kind is your buffer’s
kind and starts(view) returns the offsets items start at, in order.
Like this, a row a line:
core.items.provide("todo-list", function(view)
local buffer = view:buffer()
local starts = {}
for line = 0, buffer:line_count() - 1 do
table.insert(starts, buffer:line_start(line))
end
return starts
end)
A buffer you read rather than edit should go back on q and esc like
every other one does. core.back.provide(kind, step?) binds both for your
kind. step is what your kind does first, a command name or a function
that returns true if it went somewhere; leave it out and back goes where
you came from, or closes your float. Like this:
core.back.provide("todo-list", "todo-list-close")
greed.animate(ms, step) calls step(t) once a frame; the flash on copy
is built on it. greed.fs.watch(path) makes a “file.changed” event come
whenever that file changes, from anywhere; it’s how your config reloads.
A search the user types should mind case as they set it:
core.search.pattern(regex) gives the regex to search with, as
search-case says, and greed.fuzzy(query, items, { case = core.search.case() }) the same for fuzzy matching. A kind of search with
a better default of its own gets an option for it, KIND-search-case,
from core.search.kind(name, default, what), as notes do with
core.search.kind("notes", "ignore", "searching notes"); then pass the
kind, core.search.pattern(query, "notes").
greed.run(name) starts a command and returns as soon as that command
waits for something, so the code after it doesn’t see what the command
did after a key or a reply. greed.run(name, { wait = true }) waits until
the command has finished, the same way as the calls above.
Waiting only works where code runs as a coroutine: commands, event
handlers, and greed.spawn(f, ...), which runs f that way and returns at
once, for work in the background. Called anywhere else, like a status line
piece or a plugin’s top level, the calls that wait raise an error instead of
running on the editor’s thread, so no plugin can freeze the editor on a
slow program or server.
Heavy work doesn’t freeze it either. A command or handler that works for
more than 15 ms without waiting is paused, the editor handles keys and
draws, and it carries on where it was, so a slow plugin is only slow
itself. On Linux only time spent working counts toward the 15 ms, so a
busy machine doesn’t change where code is paused. coroutine.yield()
with nothing pauses the same way on purpose. Your own coroutines, like a
generator made with coroutine.wrap, are never paused this way.
A pause shows what’s half done, like a buffer’s new text with its old
decorations; core.atomic(f, ...) runs f to its end with no frame drawn
in between, so do the long work before it and only the changes that
belong together inside it, which can’t wait. A command or handler that
works for a whole minute without finishing is stopped and Greed says so.
Code that can’t be paused, like a status line piece or a plugin’s top
level, is timed instead: anything that holds the editor up for 50 ms or
more is kept with its plugin and what it was doing, :stalls lists them,
and over 250 ms Greed tells you right away. To see where time goes when
nothing stalls, :profile (or greed.profile.start() and stop())
counts every run of plugin code and the editor’s own work by plugin and
what it did, the most time first.
Every plugin’s top level runs each time Greed starts, so keep it to registering: commands, keys, options, handlers. Read files, scan folders or start programs the first time they’re needed, or from a handler, like this:
local index = nil
local function notes()
index = index or build_index() -- the first time a command needs it
return index
end
That way adding plugins hardly slows starting, and nobody has to set up
lazy loading in their config. :plugins says how long each one took to
load when it’s a millisecond or more; greed.profile.loading() gives
the numbers.
To see what your plugin does as it runs, greed.debug.log(...) keeps a
line while the plugins debug topic is on, or plugin:NAME for yours
alone (:debug plugin:myplugin); off, it returns at once, and
greed.debug.on() says whether it’s on, for lines that cost something to
make. :debug-log shows them with the editor’s own topics (keys, runs
and the rest, in Debugging), and
greed.debug.lines({ after = id }) returns them.
Keys typed while a key’s command is still at work wait their turn, so
typing ahead gives the same result as typing slowly. At work means paused
as above, or waiting on a timer, a program, a request or a command that
is. A command waiting for you (greed.next_key(), a prompt, a picker, any
greed.signal()) isn’t at work, and gets the next keys as they come.
Keys wait half a second at most, then run anyway. esc and ctrl-c get
through to a command at work at once, so they can cancel it, but behind
keys already waiting they keep their place. Pastes and clicks wait in
line with the keys.
An error your command, handler or task doesn’t catch shows on the status
line with your plugin and what it was running (“myplugin (on
buffer.opened): …”). The last 100 are kept with where in your code they
happened: :errors lists them, greed.errors() returns them, and a
session also writes them to its log. A message of several lines, from
greed.echo or an error, shows its first line on the status line;
:messages shows recent ones whole, and greed.messages() returns them.
Whatever you pass the API, it answers with a value or an error: a position
past the end, a closed buffer or a size no screen has is an error you can
pcall, or is kept in range where the function says so. Should your code
run into a bug in Greed itself, that becomes an error too, starting
“internal error, a bug in Greed”, kept like the others while the editor
carries on. Please report those.
Language servers ask things too: greed.lsp.on_request(method, handler)
answers a server’s request, e.g. workspace/applyEdit, with what the
handler returns, and the handler can wait, e.g. on a picker, before it
answers; it gets the parameters and the asking server’s id.
greed.lsp.on_notification(method, handler) hears what servers tell the
editor without asking, like $/progress; the handler gets the parameters,
the server’s language, its root, its id and its name. The status line’s
language server piece is built on it.
A language has a main server and may have others beside it, like eslint
beside TypeScript’s, each running per project root. greed.lsp.server{ language, name, when, only, except, ... } sets one up: without name
the main one. greed.lsp.servers_of(buffer) lists a buffer’s servers, the
main one first, each with its id, name, capabilities, and the features it’s
used for (only) and not (except). greed.lsp.root(buffer) is the folder
the buffer’s first server runs in, and greed.lsp.running() lists the
servers running, each with its id, language, name, root, command, whether
it’s ready, and the last lines it wrote to stderr. A request whose server
stops before answering returns nil and an error saying so.
greed.lsp.request(buffer, method, params, server) asks one of the
buffer’s servers anything, its first without server, and waits for the
answer. greed.lsp.uri(buffer), greed.lsp.position(buffer, pos, server)
and greed.lsp.offset(buffer, position, server) turn files and byte offsets
into what a server counts in and back, and greed.lsp.capabilities(buffer, server) is what it said it can do. Diagnostics from all of a buffer’s
servers come together in greed.lsp.diagnostics(buffer), each with the id
of the server that reported it.
To pick the server for a feature as the editor’s own commands do, use
core.lsp: core.lsp.server(buffer, method) is the first server that may
be used for the method’s feature and says it can do it, core.lsp.servers
all of them, core.lsp.each(buffer, method, fn) calls fn with each (for
requests every server answers, like completion), and
core.lsp.problems_in(buffer, from, to, server) is what to send a server in
a code action request’s context.
Events
A plugin reacts to what happens in the editor with greed.on(event, handler). The handler gets one table describing what happened. Format on
save, auto-save and the status line use it.
local greed = require("@greed")
-- Trim spaces at the ends of lines whenever a file is saved.
greed.on("buffer.saved", function(event: greed.BufferChanged)
local buffer = event.buffer
local trimmed = string.gsub(buffer:text(), "[ \t]+\n", "\n")
if trimmed ~= buffer:text() then
buffer:edit(function(e)
e:replace(0, buffer:len(), trimmed)
end)
buffer:save()
end
end)
| Event | When | What the handler gets |
|---|---|---|
buffer.changed | After every edit to a buffer: yours, a plugin’s, an agent’s, or the file changing on disk | buffer, and from_line and to_line: the lines that changed since the last one, as they are now. buffer:version() grows with each edit, for caches |
buffer.opened | A buffer was opened | buffer |
buffer.saved | A buffer was written to its file | buffer |
buffer.closed | A buffer was closed | id, the closed buffer’s |
file.changed | A file watched with greed.fs.watch(path) was written, created or removed, by anything | path |
mode.changed | A client’s mode changed | from, to |
command.run | A command is about to run | name, the keys that ran it, count |
selection.changed | A view’s selection changed for a client, or it shows another buffer, by anything: keys, the mouse, undo, a plugin or an agent. Once a frame per view, before it’s drawn, however many changes there were | view |
view.focused | Another view has a client’s focus: a pane, a float or a panel. Once a frame, before it’s drawn | view, from, the view that had it (nil if it was closed), and moved, true when it moved under the client: another client showed another tab or closed what it had focused, or it followed again |
keys.pending | A key sequence is under way, e.g. after space; "" once it’s done | keys |
option.changed | An option was set | name, value, and client when it was set for one client alone |
lsp.diagnostics | A language server reported problems for a buffer | buffer; read them with greed.lsp.diagnostics(buffer) |
message | The status line is about to show a message: an echo, an error, a command that refused. What the handler echoes shows instead, and isn’t told again, so echoing in it can’t go on forever | text, and error when something failed |
view.resized | A view has room, for a client, for a different number of rows or columns | view, rows, cols |
view.scrolled | A view starts, for a client, at a different line; what the handler changes shows in the same frame, so one view can scroll another along | view, line |
view.closed | A view was closed, e.g. a plugin’s panel | view, the closed view’s id |
pane.opened | A split opened, from whichever plugin made it | view, and from, the pane beside it |
mouse | The mouse pressed, released, dragged, moved or scrolled | kind, button or dir, the screen col and row, the keys held, and what’s under it: view, pos in the buffer, a mark’s or status line piece’s action, a floating view’s border, the edge between panes, or a tab |
terminal.output | A terminal’s program printed something | terminal; read it with terminal:screen() |
terminal.exited | A terminal’s program ended | terminal, code, signaled (a signal ended it) |
client.attached | A client attached to the session, e.g. greed FILE | client, the path it asked to open, whether it wants a terminal or the project’s shell (greed --shell), whether it came over greed ssh (remote) |
client.detached | A terminal or window went; the session goes on without it | client |
client.paste | Text was pasted from the system clipboard | text |
control.request | A request came on the session socket (greed ctl, agents) | id, method, params, client, connection; answer with greed.control.reply |
control.closed | A session socket connection closed, after its last request came; requests from it still waiting have nobody to answer | connection |
ssh_agent.use | A program in a session from greed ssh asks to sign with your ssh key, through the client relaying your agent; handlers run as that client. The core plugin asks you, as ssh-agent-confirm says. With no answer, or no handler, it’s refused | id, client, host (the client’s machine); answer with greed.ssh_agent.answer(id, allowed) |
plugin.loaded | A plugin was loaded or reloaded | name, dir |
plugin.unloaded | A plugin was unloaded | name |
editor.started | Once, when the editor is up with every plugin and your config loaded | nothing |
editor.quitting | Just before the editor quits | nothing |
space h e (:describe-event) shows any event’s fields, the types that
come with require("@greed") have them all, and the reference has them
too, with their types: Events. Give the handler’s
parameter its type, as above (greed.BufferChanged), so the type checker
catches a misspelled field. A name that isn’t on this list, like
"buffer.chnaged", is an error, from the type checker and when the code
runs.
A handler stays until its plugin unloads or greed.off(event, handler)
removes it, given the same function. Removing one that’s gone does nothing,
and a plugin can only remove its own. That lets something listen only while
it’s open:
local function show_notes(buffer: greed.Buffer)
local view = greed.float(buffer, { title = "Notes" })
local function saved(event: greed.BufferChanged)
if not view:valid() then
greed.off("buffer.saved", saved)
elseif event.buffer == buffer then
greed.echo("notes saved")
end
end
greed.on("buffer.saved", saved)
end
Who made an edit is in the buffer’s history: buffer:history({ limit = 1 })[1].author is "user", "plugin", "agent" or "external" (the disk),
so a handler can skip the edits it doesn’t care about, or its own.
A plugin with buffers of its own kind can take their mouse events first
with require("@core").mouse.claim(kind, handler).
Writing handlers that stay fast
Each handler runs in a coroutine of its own as soon as the event happens,
so it can wait like a command (see Waiting) and a slow one is
paused after 15 ms instead of holding up the editor. Still, some events
come often: buffer.changed on every key you type in insert mode,
mouse on every move, view.scrolled on every line scrolled. Handlers
for those should do little each time, and leave heavy work until things
are quiet.
The usual way is to count, wait, and only act if nothing came since. This is how auto-save works:
local edits = {}
greed.on("buffer.changed", function(event)
local id = event.buffer:id()
local this = (edits[id] or 0) + 1
edits[id] = this
greed.sleep(1000)
if edits[id] == this then
-- A second without edits: do the heavy work now.
end
end)
A handler that edits the buffer that changed makes another
buffer.changed, so check whether there’s anything to do first, as the
trimming example does, or it goes round forever.
Options
greed.option.define({ name, doc, default }) adds an option users set
with :set name value or greed.option.set(name, value) in their config.
The default fixes its type, a boolean, a number or a string, and setting it
to anything else is refused, as is a name no plugin defined (the error
names options with names like it). greed.option.get(name) reads it, and
option.changed says when it changes. When a plugin is reloaded, an option
it defines again with the same type keeps the value it was set to.
greed.option.set(name, value, { client = true }) sets a value for the
client you’re at alone, like a window’s font size; get gives that
client its own value when it has one.
greed.option.define({
name = "trim-on-save",
default = true,
doc = "Trim spaces at the ends of lines when saving",
})
greed.on("buffer.saved", function(event: greed.BufferChanged)
if greed.option.get("trim-on-save") then
-- ...
end
end)
An option that takes one of a few values lists them as choices. Setting
it to anything else fails with an error naming them, :set offers them as
you type, and :describe-option shows them:
greed.option.define({
name = "trim-style",
default = "trailing",
choices = { "trailing", "all", "off" },
doc = "What trim-on-save takes away",
})
An option whose value gets run, like a command line, says which
capability setting it takes with needs. Then only code with that
capability can set it, besides you (:set, your config), so a plugin
without proc can’t make yours run a program of its choosing. Greed’s own
options like link-opener and terminal-shell need proc, and
agent-eval needs eval. An option belongs to the plugin that defined
it: another plugin can’t define it again.
greed.option.define({
name = "deploy-command",
default = "make deploy",
needs = "proc",
doc = "What :deploy runs",
})
Programs and terminals
greed.process.run(command, opts) runs a program to the end and returns
how it went: code (or the signal that ended it), stdout and
stderr. opts takes stdin, cwd, env (false leaves a variable
out), timeout in milliseconds (then timed_out says if it ran out),
group (a process group of its own, so the kill reaches what it started)
and on_start(child), which gets the program as it starts, to stop it
from elsewhere:
local ran = greed.process.run({ "kubectl", "get", "pods", "-o", "json" }, { timeout = 5000 })
if ran and ran.code == 0 then
greed.echo(#greed.json.decode(ran.stdout).items .. " pods")
end
greed.process.env(name) is one of the editor’s own environment
variables, as the programs it starts inherit them, or nil: env("SHELL").
It takes proc too, since variables can hold secrets.
Like a spawned program, it’s your plugin’s and goes with it.
greed.which("kubectl") says where a program is, or nil when it isn’t
installed. greed.terminal.spawn({ command, rows, cols }) starts one
in a terminal: terminal.output events say there’s something new to read
with terminal:screen() and terminal:scrollback(from), and
terminal:key("ctrl-c"), terminal:write(text) and terminal:resize(rows, cols) talk back. terminal:interrupt() interrupts it as ctrl-c does,
and also reaches a program that has only just started, which a typed
ctrl-c can miss. Styles in a screen are inline names like =fg:red bold,
which you can use in your own marks too. A row says wrapped when its
line carries on on the next row, so long lines can be joined again.
terminal:modes() tells what kind of program runs: alternate (a full
screen program), canonical and echo (both off in raw mode, only echo
off while a password is read), mouse, app_cursor and
bracketed_paste. In env, a variable set to false is left out of what
the program inherits. A terminal ends with the plugin that started it.
greed.process.spawn(command, { cwd, env }) starts a program to talk to
over its input and output, like an agent or a server speaking JSON-RPC.
child:write(text) sends it input, child:read() waits for the next
piece it prints (nil once it exited), child:close() closes its input,
and child:wait() waits for its exit code, or nil and the signal that
ended it (nil, "INT"). It ends with the plugin that started it, too.
A program that prints faster than you read waits once 8 MB is unread, as
on a full pipe. Drop every reference to a child and it runs on without
you, what it prints thrown away.
greed.spawn(function()
local child = assert(greed.process.spawn({ "sh", "-c", "read x; echo got $x" }))
child:write("hello\n")
greed.echo(child:read()) -- got hello
end)
What it prints as errors is kept for child:stderr(). With stderr = "stream" it arrives from child:read() as well, in the order it comes,
and read says where each piece came from. With group = true the
program starts a process group of its own, so child:signal("INT") and
child:kill() reach whatever it started too, as ctrl-c does in a shell.
As for terminals, false in env leaves a variable out.
greed.spawn(function()
local child = assert(greed.process.spawn({ "make" }, { stderr = "stream", group = true }))
while true do
local piece, from = child:read()
if piece == nil then
break
end
greed.echo(`{from}: {piece}`)
end
print(child:wait()) -- 0, or nil and "INT" after child:signal("INT")
end)
To show a terminal you started yourself the way :terminal shows one,
hand it to the terminal plugin: require("@terminal").adopt(terminal, { return_on_primary = true }) shows it in the focused view, sized for your
screen and typing into it, and with return_on_primary gives the view back
once a full screen program is done or the program exits. The terminal
stays yours to read and close. references(buffer, { from, to, cwd })
finds the files and lines some output names, and row_marks turns a
terminal’s rows into marks for a buffer of your own.
JSON-RPC
greed.rpc.start(command, opts) starts a program that speaks JSON-RPC 2.0
over its input and output, as language servers, debug adapters and coding
agents do. opts.framing is "headers" (Content-Length headers, the
default) or "lines" (one message a line, as ACP agents send them), and
cwd and env work as for greed.process.run. The program’s requests go
to on_request(method, params), whose return value is the answer (or nil
and an error message); its notifications go to on_notify(method, params),
and on_exit(stderr) hears it end. Each runs in a coroutine of its own, so
one that waits doesn’t hold up the rest.
local conn = assert(greed.rpc.start({ "my-adapter" }, {
on_notify = function(method, params)
greed.echo(`{method}: {greed.json.encode(params)}`)
end,
}))
local caps, err = conn:request("initialize", { adapterID = "demo" }) -- waits for the answer
conn:notify("initialized", {})
conn:alive() says whether it still runs, conn:stderr() is what it
printed there lately, and conn:close() stops it. A request on a closed or
exited connection returns nil and why. The connection is your plugin’s
and goes with it.
Reading text with sikt
greed.sikt reads structure out of text, like a program’s output or the
lines of a note, with sikt
patterns. A pattern reads like a sentence: literal text is quoted, name:
captures, and integer, size or duration captures come back as
numbers. Compile a program once and run it as often as you like:
-- du -h prints a size, a tab and a path a line.
local big = assert(greed.sikt.compile('find used: size 1+ space path: until text end where used > 1G'))
for _, row in big:rows(ran.stdout) do
greed.echo(`{row.path}: {row.used} bytes`)
end
On a mistake, compile gives nil and the mistake in words. Programs that
work but probably don’t do what was meant come with warnings.
greed.sikt.check(source) gives both, each with its message, at (where
in the program), help and whether it’s only a warning, so a program
someone types can be shown with its mistakes marked.
Each line is matched on its own unless lines = false. rows(text, { at = true }) also gives where each match is (from, to, line). For a lot of
text, rows_many(texts) runs over a list of texts on other threads and
waits like greed.sleep. Its rows become Luau tables all at once when it’s
done, so give it a few hundred texts at a time. replace(text) rewrites the matches as the
program’s replace says. Rules can live in Luau and be used by name:
local notes = assert(greed.sikt.compile('use "notes" find link or tag', {
modules = {
notes = [[
let link = "[[" target: until "]]" "]]"
let tag = not after wordchar "#" tag: 1+ wordchar
]],
},
}))
The shell
require("@shell") is the shell: shell.run(sh, line) runs
a line in a shell as a new block, shell.of(buffer) is the shell a buffer
shows, shell.project() the project’s shell (opened out of sight when
there’s none), and shell.wait(block) waits for a block to finish.
shell.change(sh, block, line) runs a line in a block’s place instead,
stopping it first if it runs, as space C does. A block’s
record has what ran and how it ended, its output, and block.value when
the output was JSON.
shell.run(sh, line, opts) takes, all optional: cwd and env to run
with in place of the shell’s, and runner = "pipe" to keep what the
program prints (block.stdout) apart from its errors (block.stderr);
the default runs it in a terminal, as a line you type. Leave out by:
by = "agent" is for agents’ tools, and marks the block as an agent’s.
local greed = require("@greed")
local shell = require("@shell")
local block = shell.run(shell.project(), "go test -json ./...", { runner = "pipe" })
if block then
shell.wait(block)
greed.echo(`{block.status}: {#block.stdout} bytes`)
end
For code someone hands over, like a block in a page or an agent’s
message, shell.run_code(text, opts) runs it in the project’s shell and
shows it in a float as it comes, asking first when it looks like it
destroys something. shell.prompt_code(text, opts) puts it at the prompt
in a float instead, for enter to run. Both take done, called with the
block once it’s finished; run_code takes cwd and prompt_code a
footer. shell.commands(lang, text) is a code block’s commands, nil
when lang isn’t a shell’s (a console block’s are its lines after a
$ ).
The programs a line runs are your plugin’s, so it needs proc; the
builtins cd and open also need fs.read. What the shell does around
them, like its wrapper’s files in the cache folder, its history, the
folder’s environment and the prompt, is the shell’s own, so they need
nothing more. A block that can’t start, say for a missing capability,
ends as failed with the reason in block.stderr.
block.table is the output read as a table, when it was one: columns
(the header’s names, in order) and rows, each a map from a column’s name
to its cell’s text. shell.tables reads and works on them:
tables.detect(text, command), tables.from_value(json),
tables.where(tbl, "AGE < 1h"), tables.select(tbl, "NAME,AGE"),
tables.sort(tbl, "AGE -r") (each a new table), tables.number("512Mi"),
and tables.draw(tbl) lines it up as text; tables.columns(text, true),
tables.csv(text), tables.from_json(text), tables.split(text, ":")
and tables.lines(text) read text that’s known to be a table.
greed.compare compares values the way where and a view’s filter do,
so your own filters read the same: greed.compare.test("12 (5s ago)", ">", "0"), greed.compare.test("WARN", ">=", "warn"),
greed.compare.number("512Mi"), greed.compare.order(a, b) (-1, 0 or 1,
for sorting) and greed.compare.find("AGE<=1h") for where an operator is.
greed.text.shape(line, true) reads a line of nested text (YAML, indented
JSON, kubectl describe) as filters and folds do: how far it’s indented,
a list item’s - counting, and the key it starts with.
For writing text the way the rest of Greed does, require("@core") has
text.width(s) (cells on screen, wide characters two), text.clip(s, n),
text.split_lines(s), text.trim(s), text.unquote(s) and
text.bytes(n) (“142.6 kB”), and time.age(seconds) (“3d”, as kubectl
writes an age), time.ago(seconds) (“4 min ago”), time.duration(ms)
(“0.31s”, “2m 05s”), time.iso(text) (ISO 8601 to seconds) and
time.iso_text(seconds).
A plugin that keeps a buffer’s lines (to read them often without asking
the buffer) gets them with text.buffer_lines(text), and after each
buffer.changed brings them up to date with text.relines(buffer, lines, starts, event.from_line, event.to_line), which reads only the lines that
changed: an edit costs what it changed, however long the buffer.
shell.parser(match, parse) reads the output of the commands match
names as tables, ahead of the shell’s own look for one: a program’s name,
or a pattern for the command line. parse is a
sikt program, whose captures are the columns,
or a function: parse(text, block) returns a table, a list of objects as
JSON has them, or nil to leave it to the shell.
local shell = require("@shell")
-- `terraform state list` prints one address a line.
shell.parser("^terraform state list", 'address: (type: until "." until text end)')
-- A function, for output a pattern can't say.
shell.parser("^mytool status", function(text)
local ok, found = pcall(greed.json.decode, text)
return if ok then found.items else nil
end)
shell.row_at(sh, block, pos) is the row under a position in the
buffer, filtered and sorted as the block shows it, for actions on a row:
local shell = require("@shell")
greed.command({
name = "pod-logs",
run = function(ctx)
local sh = shell.of(ctx.buffer)
local pos = ctx.view:cursor()
local block = sh and shell.block_at(sh, pos)
local row = block and block.table and shell.row_at(sh, block, pos)
if sh and block and block.table and row then
shell.run(sh, `kubectl logs {block.table.rows[row].NAME}`)
end
end,
})
shell.completer(name, complete) completes program name’s arguments
at a shell’s prompt, ahead of Cobra, fish, carapace and the program’s
help. complete(request) gets the command’s words (the program first,
the word being completed last), its line so far, the cwd and env it
would run with, and explicit (you pressed tab), and returns candidates
as text or { text, detail }, or nil to leave it to the other sources. It
can run programs; shell.run_source(name, argv, cwd, env) runs one the
way the shell’s sources do, stopped by a newer run of the same name and
by shell-completion-timeout.
local shell = require("@shell")
-- `deploy ENV`: the environments are the folders under deploy/.
shell.completer("deploy", function(request)
if #request.words ~= 2 then
return nil
end
local found = {}
local entries: { greed.DirEntry } = greed.fs.list(request.cwd .. "/deploy") or {}
for _, entry in entries do
if entry.dir then
table.insert(found, { text = entry.name, detail = "environment" })
end
end
return found
end)
shell.segment(name, provider) puts a piece in every shell’s prompt
before its folder, after the shell’s own (the git branch and the project
environment) and those added before it, like the kubernetes plugin’s
context. provider(ctx) gets the shell, its cwd and the env its
programs get, and returns { text, style, warning } or nil for nothing;
warning = true turns the prompt’s ❯ red too. It runs in the background
when a shell opens and after each command, so it can run a program; the prompt shows the new pieces once every
segment is done. With shell-prompt set to starship, starship draws the
prompt instead, and segments only add their warnings.
local shell = require("@shell")
-- The AWS profile in use, from the shell's variables.
shell.segment("aws", function(ctx)
local profile = ctx.env.AWS_PROFILE
if profile == nil then
return nil
end
local production = string.find(profile, "prod") ~= nil
return {
text = `aws:{profile}`,
style = if production then "shell.segment.warning" else "shell.segment",
warning = production,
}
end)
shell.segment_icon(name, { plain = "☁", nerd = "\u{f0c2}" }) gives a
segment an icon for shell-icons to pick, and shell.icon(name)
is the one in use, to start the segment’s text with.
shell.production(context) says whether a context matches
shell-production-contexts.
require("@vcs").branch(dir) is the branch of the repository a folder is
in, as the status line shows it, and the vcs plugin has the prompt show it
too. shell.branch_finder(find) does that: the git segment shows what
find(dir) returns for the shell’s folder instead of the branch
.git/HEAD names.
shell.environment(name, provider) adds a kind of project
environment, like devenv’s, for
shell-environments to name. provider.root(dir, env) says which folder’s
environment applies in dir, or nil, with a reason when there’s one it
won’t load (“not allowed”); it runs after every command, so keep it quick.
provider.load(root, env) loads it and returns { vars, watch, output }:
the variables to set (a string) or leave out (false), the files whose
change loads it again, and what loading printed. It can run programs and
wait; an error says why it failed.
local greed = require("@greed")
local shell = require("@shell")
-- A folder with a .env file brings its NAME=VALUE lines.
shell.environment("dotenv", {
root = function(dir)
return if greed.fs.stat(`{dir}/.env`) then dir else nil
end,
load = function(root)
local vars = {}
for _, line in string.split(greed.fs.read(`{root}/.env`) or "", "\n") do
local name, value = string.match(line, "^([%w_]+)=(.*)$")
if name and value then
vars[name] = value
end
end
return { vars = vars, watch = { `{root}/.env` }, output = "" }
end,
})
:set shell-environments "devenv dotenv" then asks devenv first.
shell.stage(spec, run) adds a table stage
like where. spec has its name, usage and doc (for help and
completion), args (“column”, “columns”, “condition” or “format”, for
completion), and starts = true when it may follow a program too, as in
kubectl get pods | NAME; give that only to names no program has.
With text = true it takes text that isn’t a table too, as a table of
its words (columns 1, 2 and so on, or a first line without numbers as
the header). run(tbl, rest, ctx) gets the table, the rest of the
stage’s words, and ctx.block and ctx.shell when it runs in a shell
(a watch runs it each time, in the same block, so it can keep things
from run to run), and returns a new table ({ columns, rows }, each row
a map of column to text), text (which ends the stages, as to csv
does), or nil and why it can’t. The chart stage is a plugin, written
this way.
require("@scene") draws small vector scenes in character cells, as
charts are: scene.cells(spec, cols, rows) gives styled lines, braille
for lines and dots, eighth blocks for filled shapes. A spec is
{ alt = "what it shows", items = { ... } }, with coordinates in cells;
items are line, area, rect, dots, text and group (clipped).
require("@chart").lines(tbl, "bar CPU", cols, rows) draws a table as
| chart would.
To have clients draw a scene better than characters, keep it with
greed.scene.new(spec), which gives its id, and put it over the
characters with a mark’s scene = { id = id, cols = 60, rows = 12 }.
The window and terminals with kitty graphics draw the scene as an image
under their text, so the scene’s own text stays text; other clients show
the characters. require("@scene").drawn() says whether to place
scenes at all (the scene-drawing option). greed.scene.set(id, spec) changes it, and
greed.scene.forget(id) lets it go; a plugin’s scenes go when it does.
-- `top COL N`: the N rows with the most in a column.
shell.stage({ name = "top", usage = "top COL N", doc = "The rows with the most in a column", args = "column", starts = true }, function(tbl, rest)
local name, count = string.match(rest, "^(%S+)%s*(%d*)$")
local column = name and shell.tables.column(tbl, name)
if column == nil then
return nil, "top COL N, like top RESTARTS 5"
end
local rows = shell.tables.sorted(tbl, shell.tables.all(tbl), column, true)
local kept = {}
for i = 1, math.min(tonumber(count) or 10, #rows) do
kept[i] = tbl.rows[rows[i]]
end
return { columns = tbl.columns, rows = kept }
end)
shell.builtin(spec, run) adds a command the shell runs itself, ahead of
programs and aliases of that name (^NAME still runs the program).
spec has name, usage, doc and args as builtins have them.
run(args, ctx) gets the words after the name, and ctx with the shell,
the block, its cwd, and write(text) and error(text) to print in
the block; it returns the exit code, 0 when it returns nothing, and an
error fails the block with its message. It can wait, as commands can;
ctrl-c ends its block at once, after which what it prints goes nowhere and
ctx.stopped() says so, for one that waits in steps to quit early.
Neither can replace the shell’s own, and both go when the plugin does.
shell.kind(spec) says what the rows of some commands’ tables are, so
they’re things to act on like any other
(core.actions). spec.match names the commands as shell.parser does.
spec.columns lists columns a table must have (in any case); without
match, the kind reads any table with them, whatever printed it, after
the kinds naming the command had their turn. A PID column is how ps
on Linux and macOS, nu’s ps, lsof and docker top all become
processes.
spec.capture(block, shell) runs once as the block finishes and keeps
what the rows can’t say themselves, like the context a command ran
against; returning nil says the block isn’t this kind’s after all.
spec.row(row, captured, block) gives { kind, label, value, key, cells }
for a row (its cells by column, cells the things some of them are, by
column, like a pod’s NODE), and spec.called(captured, block) what one row
and several are called in the block’s status (“pod”, “pods”). Rows then
take the actions of their kind, whoever added them; ls -l rows are
file things, so every file action works on them.
key names the thing as an object, kind:key: the same for
the same thing in any block, like a pod’s context, namespace and name.
Without one, a value that’s a string (a file’s path) names it, and rows
that can’t be named are plain rows of their block. The plugin that knows
the things says what they are with core.objects.kind({ name, doc });
the shell is a source of objects of every kind: rows are listed from
every shell’s blocks, the newest first, inspected with the row’s cells
(row) and related to their block, whoever’s kind they are. Leave the
kind out for one the editor has already, like file.
fresh = shell.fresh(function(value) return "ps -p " .. value.pid end)
on the kind lets watch see a thing as it is now: the command line that
lists just it runs where the row came from, and its first row is the
thing’s state. shell.env_of(value) is the variables of the block a
thing’s row came from (its KUBECONFIG), to ask a program about it as
that block would. shell.log_prefix(read) teaches the log view a prefix
a program puts before merged lines, like kubectl’s [pod/api-1/app] :
read(text) returns the fields it says and the rest of the line, or nil.
spec.complete makes the rows complete later commands. It maps a
program’s name to a function given the command’s words (the word being
completed last) and the shell; it returns nil when no thing of this kind
fits there, or a function giving the word to put in for a thing’s value,
nil for one that doesn’t fit (from another context, say). The rows of
the newest blocks come first in the menu, before what the program
offers itself.
spec.streams(words) says whether a command line of the kind keeps
printing rows again as they change, as kubectl get pods -w does. The
shell then reads it through a pipe and shows each row once, in its place,
known by its first cell (its first two under a NAMESPACE column).
spec.order lists the columns to show first, the most useful first. A
narrow pane cuts a table’s rows at its right edge, so a program that
prints what its rows are known by last (docker’s NAMES) gets its table
redrawn with these columns first, and the others follow as they came.
Only the screen changes: the block’s output keeps what the program
printed, and columns picked with select stay as picked.
shell.action_command(kind, name, command, opts) adds an action that runs
a command as a block in the shell, so what it does is there to read and
run again. command is a template whose {field}s are the thing’s
value’s fields, quoted, or a function from the value to the line.
opts.doc says what it does, opts.danger makes it ask first (saying
when the value’s context is a production one), opts.default
makes it what enter on such a row does, and opts.follow opens the
block of a command that keeps printing (logs -f) in a float following
its last line. Run while the same command still runs in that shell, an
action opens that block instead.
-- `systemctl list-units`'s rows as services.
shell.kind({
name = "systemd",
match = "^systemctl list%-units",
row = function(row)
local unit = row.UNIT
if unit == nil or not string.match(unit, "%.service$") then
return nil
end
return { kind = "service", label = unit, value = { unit = unit }, key = unit }
end,
called = function()
return "unit", "units"
end,
})
core.objects.kind({ name = "service", doc = "A systemd service, by its unit" })
shell.action_command("service", "status", "systemctl status {unit}", { doc = "How it's doing", default = true })
shell.action_command("service", "restart", "sudo systemctl restart {unit}", { doc = "Restart it", danger = true })
Queries and indexes
Greed has one query language for searching and filtering, and a plugin’s
own lists can speak it too: words, field:value, comparisons, - and
OR, dates like date:2w.. and due:..eow, is: flags, and in:,
under: and has: for what sits where. Words and values match without
minding case or accents, so cafe finds Café.
from:anna is:unread date:2w..
is:todo -is:done due:..+7d in:(tag:garden) sort:due
require("@core").query reads one and runs it. A source says what its
items’ fields are ("text" by words, "exact" as whole values,
"value" compared as greed.compare does, "date"), which flags is:
knows, and where items sit:
local core = require("@core")
local query = core.query
local tasks = {
{ title = "water the plants", due = "2026-10-16", done = false },
{ title = "buy seeds", due = "2026-10-12", done = true },
}
local source: core.QuerySource = {
fields = {
title = { kind = "text", get = function(t) return t.title end },
due = { kind = "date", ahead = true, get = function(t) return t.due end },
},
flags = { done = function(t) return t.done end },
text = function(t) return t.title end,
}
local parsed = query.parse("plants -is:done due:..eow")
local problems = query.check(parsed, source) -- fields and flags it hasn't, bad dates
local found = query.run(parsed, tasks, source) -- the tasks that match, sorted as asked
parse gives the problems with where they are in the text (at), and
print(parsed) writes a query back in its one form. core.dates.span
reads a date the way queries do (“last week”, “2w”, “eom”).
An item can be in several places at once, as a mail is in each of its
labels. Name the field that holds them in the source (places = "label"),
and in:inbox finds the items with “inbox” there as well as those whose
parent is named so.
For many items, or items kept between sessions, put them in an index:
greed.index.writer(path) makes or opens one to write, and
greed.index.open(path) reads one another program writes. Give the source
a key for each item and say which flags are stored; the rest are
worked out when a query runs.
local index = greed.index.writer(dir .. "/tasks.db")
index:write(query.index_items(tasks, source))
local keys, maybe = query.search(index, parsed, source)
search gives the matching items’ keys; maybe holds those that depend
on a flag that isn’t stored, for the plugin to check. index:items(keys)
gives back what the index holds for them (name, text, fields, flags), to
show what was found. An index’s methods work on another thread and wait
like greed.sleep.
A search box
core.search_box.open asks for a query the way every search in Greed does.
It shows the query in colours as it’s typed, with a dimmed * after the
word at the end, since that word matches by prefix until a space settles it.
Mistakes are underlined and said after the query, and the title says how many
results there are. With none, it also says which term to leave out to find
the most (0 results · 12 without tag:home). tab completes the source’s
fields and flags, its names after in:, and values after field:. up
and down bring back queries submitted before in boxes with the same
history. A source with names also gets an error when in: names
nothing there (“nothing here is named garen; did you mean in:garden?”).
core.search_box.open({
title = "Search tasks",
source = source,
history = "tasks",
values = function(field)
return if field == "tag" then { "garden", "home" } else {}
end,
count = function(parsed)
local found = query.run(parsed, tasks, source)
return if found then #found else nil
end,
on_change = function(text, parsed) end, -- show the results as it's typed
on_submit = function(text, parsed) end,
})
With regex = true, a query starting with / is a regex for the rest, as
the shell’s filters take it, and words adds words of the plugin’s own to
what tab offers.
Searched with everything else
core.everywhere is the search over everything that’s yours (space n s
and the agents’ search_everywhere). A plugin that keeps the person’s
things adds itself as a source. Its search gets the query with its own
in: taken out and gives back what it found:
core.everywhere.add({
name = "tasks",
doc = "Your tasks",
search = function(text, limit)
local hits = {}
for _, t in query.run(query.parse(text), tasks, source) or {} do
table.insert(hits, {
source = "tasks",
kind = "task",
id = `task:{t.title}`,
label = t.title,
at = os.time() * 1000, -- when, in milliseconds, to sort by
open = function() greed.echo(t.title) end,
})
end
return hits, nil -- or nil and why it couldn't search
end,
})
local hits, troubles = core.everywhere.search("plants in:tasks")
Hits from every source come newest first, those without at last. A
source that fails says why in troubles, and the others still answer.
The command line
greed.cli({ name, doc, usage, run }) adds a command to greed itself.
greed NAME ARGS starts an editor with no screen, with your plugins and
config, and calls run with the arguments. It can wait like any command
(on greed.process.run, greed.http.request, greed.sleep); what it
echoes is printed as it goes, what it returns is printed at the end, and
an error makes greed exit with a failure.
greed.cli({
name = "hello",
doc = "Say hello",
usage = "[NAME]",
run = function(args)
return `hello {args[1] or "there"}`
end,
})
greed hello world prints hello world, and greed commands lists it.
Names are lowercase words with dashes; a file of that name in the current
folder wins, and greed NAME with no such command opens NAME as a file.
The network
greed.http.request({ url, method, headers, body, timeout }) returns the
whole response (status, headers with lowercase names, body), or nil
and why. greed.http.stream(...) returns once the status and headers are
in, and stream:read() gives the body piece by piece as it arrives, which is how
model APIs stream their answers:
local stream, err = greed.http.stream({
url = "https://api.example.com/v1/generate",
headers = { ["content-type"] = "application/json" },
body = greed.json.encode({ prompt = "Hello", stream = true }),
})
if stream == nil then
error(err, 0)
end
while true do
local piece = stream:read()
if piece == nil then
break
end
greed.echo(piece)
end
stream:read(ms) gives up after ms milliseconds with nil and "timed out", leaving the stream open, and head_timeout = ms limits the wait for
the status and headers; timeout limits the whole request, body included.
Each request runs on a thread of its own and both wait like greed.sleep,
so they work in commands and event handlers and never hold up the editor.
A plugin needs net, or net:HOST for each host it talks to.
Redirects are followed on the same host, never from https to http, so
headers like an API key only go where they were meant to. Any other
redirect comes back as the response, its location header saying where.
To download a file, give request a save path: a successful (2xx)
response’s body is written there as it arrives, with no size limit, and
the file appears only once it’s whole. Any other response comes back with
its body as usual and nothing is written. Saving needs fs.write too.
local got, err = greed.http.request({ url = url, save = cache .. "/grammar.wasm" })
if got == nil or got.status >= 300 then
error(err or `status {got.status}`, 0)
end
Keys for those servers come from greed.secrets.get("anthropic"), never from
config or plugin source. It looks in the environment (GREED_SECRET_ANTHROPIC,
or the usual ANTHROPIC_API_KEY), then the system keyring, then Greed’s own
secrets file, and waits like the rest. When it finds nothing and the
keyring couldn’t be reached (secret-tool isn’t installed, there’s no
D-Bus session), it returns nil and why, since the keyring may have it.
greed.secrets.set keeps a secret in the file when the keyring can’t be
reached, and the place it returns says why. A plugin declares each secret it
reads as secrets:NAME, and Greed’s file APIs refuse to read the secrets file
itself.
Models
The models plugin talks to language models. A plugin asks for a role, like
fast, and the user’s config decides which model plays it:
local models = require("@models")
local stream, err = models.stream("fast", {
system = "Answer in one sentence.",
messages = { { role = "user", content = "What is a rope data structure?" } },
})
if stream == nil then
error(err, 0)
end
while true do
local piece = stream:next()
if piece == nil then
break
end
greed.echo(stream.text)
end
models.ask(role, request) waits for the whole answer instead.
models.decide(role, state, questions) asks yes-or-no questions about a
state and gives, for each by name, how likely yes is, from 0 to 1:
local answers = models.decide("decision", { command = "rm -rf build" }, {
harmful = { instructions = "Could it do harm?", yes = "it may", no = "it can't" },
})
if answers and answers.harmful > 0.6 then ... end
A decision model, like Berget’s System One models, answers these
directly; any other model is asked in a chat for the same answers, so
either kind can play the role. Both wait
like the rest of the API. The roles that come set up are fast,
reasoning and local; a plugin can ask for any role, and the user maps it
in their config or in :models.
A role of your own can use another role’s model until the user sets one,
and :models lists it with the model it uses then:
models.fallback("summary", "fast", "summaries of long notes")
models.playing("summary") -- "fast" until models.roles.summary is set
Before asking, models.check(role) says what’s missing without sending
anything: no model plays the role, its provider isn’t set up, or it has no
key. models.no_key(provider, why) is the message every feature shows for a
missing key, naming the variable that sets it and :models; pass the
why greed.secrets.get gave and it says the keyring couldn’t be reached.
For a model that calls tools, models.turn(role, request, on_text) runs
one turn: request has the conversation as said (each { role = "user", text = ... }, { role = "assistant", text = ..., calls = ... } or { role = "tool", call = ID, text = ... }), tools (each a name, a
description and a JSON schema as input) and an optional system.
on_text gets the answer’s text as it arrives, and the turn comes back as
its text, the calls it asks for (id, name, input) and stop:
"done", or "tools" when it wants them run and their results sent in the
next turn. A fourth argument, on_open, gets a function that closes the
answer’s stream once it starts, to stop it early (a closed stream ends the
turn with what came so far). It works the same with Anthropic and with
servers that speak OpenAI’s chat completions. A user’s turn can carry images, a list of PNG
file paths read when the request goes out; models.sees_images(role) says
whether the role’s model can see them, and they’re left out for one that
can’t.
Providers you sign in to
Some plans come with an account instead of an API key, like Berget Code.
A provider like that names a login, and :login NAME signs you in with
OAuth’s device flow: Greed shows a link and a code, you approve it in a
browser on any device, and the tokens are kept with your other secrets and
renewed before they run out. Once you’re signed in, the provider sends the
token instead of its key.
Add one in your init.luau or a plugin, from what the provider’s sign-in
server says about itself (its OpenID configuration usually lists the two
endpoints):
local models = require("@models")
models.login.logins.acme = {
title = "Acme AI",
device_url = "https://auth.acme.example/oauth/device/code",
token_url = "https://auth.acme.example/oauth/token",
client_id = "acme-cli",
scope = "openid offline_access",
}
models.providers.acme = {
kind = "openai",
url = "https://api.acme.example/v1",
login = "acme",
-- Optional: a key to use when you aren't signed in.
secret = "acme",
}
models.roles.agent = { provider = "acme", model = "acme-large" }
That is how your config does it. A plugin gets other plugins’ modules
read-only, so it adds the provider and the role with
models.provider("acme", { ... }) and models.role("agent", { ... });
both go when the plugin does. Adding a login works the same from both.
Then :login acme, and :models says “signed in (Acme AI)”. :logout acme forgets
the tokens, and the provider goes back to its key. The name is used for the
secret the tokens are kept in, so it takes lowercase letters, digits and
dashes. Once a login is added it can’t be replaced or changed, and its
tokens stay inside the models plugin: no plugin can read them or send them
elsewhere.
A sign-in that ends with a plain API key, as Mistral’s Vibe does, has no
device or token addresses: key names the secret it keeps the key as, and
get_key(show) signs in, calling show({ url = ..., minutes = ... }) with
where to go, and returns the key, or nil and why. Signing out forgets the
key, unless it’s been replaced since.
Any plugin can add a provider, so a key or a sign-in goes only where the
user let it: the built-in providers’ keys to their own servers, and any
other the first time it would go somewhere new, after Greed asks
(“Send your acme key to https://api.acme.example from now on? Type yes to
allow it”; anything but yes says no). The answer is kept, so each key
and address asks once.
scope needs whatever the server wants for a refresh token, often
offline_access; without one, you’d sign in again whenever the token runs
out. Tokens are renewed with OAuth’s own refresh at token_url. A provider
that renews another way gives a renew function, which gets the tokens
(access, refresh, expires in seconds like os.time()) and returns new
ones, or nil and why. Berget’s posts the refresh token to its own API,
like this:
renew = function(tokens)
local status, answer = models.login.post(
"https://api.acme.example/v1/auth/refresh",
{ refresh_token = tokens.refresh },
"json"
)
if status ~= 200 or type(answer.token) ~= "string" then
return nil, `Acme said {status}`
end
return {
access = answer.token,
refresh = answer.refresh_token or tokens.refresh,
expires = os.time() + answer.expires_in,
}
end,
models.login.post(url, body, "form" | "json") sends a POST and returns
the status and the answer decoded from JSON. Only the device flow is
supported for signing in; a provider that only signs in through the browser
on your own machine can’t be added this way yet.
Keeping state in one place
Some plugins keep state that has to live in one place: accounts, a store, programs keeping them in sync. Chat, mail and Hoard work like that. Such a plugin offers a service: one session, the owner’s, holds the state, and every session shows it and acts on it through views. Like this, a counter you can add to from any session:
local greed = require("@greed")
local service = require("@service")
-- The service, and when its owner starts: when a view first needs it.
service.define({ name = "counter", start = "use" })
-- The owner: this part runs only in the service's own session.
if service.owner("counter") then
local count = 0
local offer: service.Offer
offer = service.offer("counter", {
version = 1,
handle = function(method: string, params: any): (any, string?)
if method == "get" then
return { count = count }
elseif method == "add" then
count += params.by
offer:notify("count", { count = count })
return { count = count }
end
return nil, `no {method}`
end,
})
end
-- A view: the same in every session, the owner's too.
local shown = 0
local counter = service.use("counter", {
version = 1,
topics = { "count" },
on = function(_, params: any)
shown = params.count
end,
-- Called whenever the view connects, first or again: show what's there now.
reset = function(view: service.View)
local now = view:request("get")
if now then
shown = now.count
end
end,
})
greed.command({
name = "counter-add",
run = function()
local _, why = counter:request("add", { by = 1 })
if why then
greed.echo(why)
end
end,
})
The owner runs in a session of its own, counter.service, so a stuck
service only takes itself down. Greed starts it when a view first asks,
and starts it again if it goes while a view listens. Nobody starts it by
hand; it shows in greed ls and space P, marked as a service. A plugin
like this lists service in requires.
| Call | |
|---|---|
service.define({ name, start }) | There’s a service called name. start is "use" (when a view first needs it), "always" (when Greed starts) or a function saying whether to start it then. Two can’t share a name |
service.owner(name) | Whether this is the owner’s session. Put the owner’s half behind it |
service.offer(name, { version, handle }) | Answers views: handle(method, params, caller) returns a result, or nil and why, and may wait. caller.session is the session that asked |
offer:notify(topic, params) | Tells views listening to topic that something changed. A topic is any name you pick |
service.use(name, { version, topics, on, reset }) | A view in this session. on(topic, params) hears changes; reset(view) runs each time it connects, so fetch what you show there |
view:request(method, params, { timeout }) | Asks the owner and waits (30 seconds by default): the result, or nil and why. Only where code may wait |
view:listen(topic), view:ignore(topic) | What it hears from now on |
view:state() | "idle" (not needed yet), "connecting", "ready" or "unreachable", with since when and why |
A view connects the first time it’s needed; in the owner’s own session
it’s ready as soon as the service is offered. Changes only reach it while
it’s connected, so after a lost link nothing is caught up; reset runs
and the view fetches again. When the owner and a view speak different
versions, requests fail saying which to restart, and :service-restart NAME starts a service’s session again with the greed you run now.
handle runs as your plugin’s own, as your event handlers do: only your
capabilities count, whichever plugins passed the request on. A registry of
your own does the same for what plugins hand it with
greed.plugin.handler(f).
Answers go as JSON, so a service sends data, never a path on its machine.
Agents
Plugins can offer tools to agents. A tool shows up for every agent: those
connected through greed mcp (Claude Code, Codex, Gemini CLI, opencode or
any MCP client), the agents Greed runs over ACP, and Greed’s own agent, and
as greed ctl NAME in the shell:
require("@agent").tool({
name = "word_count",
description = "How many words the current file has",
run = function()
local _, words = string.gsub(require("@greed").view():buffer():text(), "%S+", "")
return tostring(words)
end,
})
A plugin offering tools lists agent in requires. The tool’s parts:
| Field | |
|---|---|
name | Letters, digits, _ and - |
description | What it does, for the agent deciding whether to use it. Say when to use it and what comes back |
input | A JSON Schema for the arguments; agent.schema.object({ path = { type = "string" } }, { "path" }) makes an object’s, the second list naming the required ones. A call with an argument it doesn’t name (unless additionalProperties allows any) or without a required one fails before run, saying what it takes. Left out, it takes none |
group | The group it’s offered with; left out, it’s always offered (below) |
kind | What it does beyond reading: "edit" (changes files or notes), "execute" (runs code or programs) or "fetch" (reaches the network); left out, "read" |
reviews | true when the tool puts what it does in front of the user itself, as a proposal or a question does |
danger | danger(args) says why a call is risky (kubectl delete “changes the cluster”), or nil; such a call asks the user every time, whatever they allowed |
sandboxed | true when the tool does more than read but needs no say from the user, like checking a plugin in an editor of its own |
shell_only | true keeps the tool for greed ctl and the programs Greed’s shell runs, like greed edit: agents aren’t offered it and can’t call it |
run | run(args, caller) does the work |
Greed’s own agent asks the user before a tool whose kind isn’t "read"
runs, the way it asks before its own edits, unless the tool reviews or
is sandboxed; MCP clients see the read-only ones marked read-only, and
their own permissions decide about the rest. Set kind on every tool that
changes, runs or fetches something, so it isn’t run unasked.
A call whose danger says why waits for the user’s yes every time, from
any agent, MCP clients included; only greed ctl skips it. For command
lines, require("@core").risk.of(line) says why one is risky, and
risk.rule(program, function(words) ... end) teaches it a program’s,
as the kubernetes and docker plugins do for kubectl and docker. The other
way round, risk.safe(line) says whether every command in a line only
looks, or builds and tests, as auto mode lets agents run them, and
risk.safe_when(program, function(words) ... end) says which of a
program’s commands are (all of them, without the function). See
Permissions and sandboxing for how
the user sees these.
Agents connected when a plugin loads or unloads hear that their tools changed, so a tool from a plugin you’ve just approved can be used in the same conversation.
run gets the arguments as a table, and who called as caller, whose
kind is "shell" for greed ctl, "socket" for MCP clients through
greed mcp (agents Greed runs over ACP use it too), "ide" for Claude
Code’s IDE connection and "agent" for Greed’s own agent. Any plugin can
call a tool with any caller, so don’t decide trust on kind: agent.from_shell(caller) says whether the call
came from greed ctl, whose user can run anything already.
A string run returns goes to the agent as it is, and any other value as
JSON, even a table with a content field. To answer with MCP’s result
form itself, return agent.result(content, is_error), where content is
text or a list of pieces like { type = "text", text = "..." }. An error
goes back as an error, so error("there's no file " .. path, 0) tells the
agent what went wrong.
Hand text someone else wrote, like a web page or another agent’s report,
back through agent.untrusted(source, text): it goes between
<untrusted-…> tags the text can’t close, with source saying where it
came from. Greed’s agent and MCP clients are told once what the tags mean;
a model you ask yourself with models.ask needs agent.untrusted_note in
its system prompt. Secrets in the text (private keys, API tokens, values
named like passwords) are hidden first, and the tag says how many;
agent.redact(text) does that alone.
<untrusted-3fa2c1b0e9d4 source="what `cat .env` printed" hidden="1 secret">
DB_HOST=db.internal
DB_PASSWORD=[secret hidden]
</untrusted-3fa2c1b0e9d4>
A buffer that shows what someone else wrote, like the mail plugin’s
threads, can say so for its kind, and agents reading it with read, or
its selection with focus, get it between those tags:
core.outside.kind("mail-thread", "mail you received")
An agent is told what you’re in with each message. A file says it by its
path; a buffer of your plugin can say in a few words what it is, which
focus and the inspector show too:
core.about.kind("mail", function(buffer)
return `the mail list, searching "{query}", {#rows} shown`
end)
A tool can wait: for a process, a request, or the user. Changes to files are best proposed, so the user reviews them first and the tool hears what they decided:
local agent = require("@agent")
agent.tool({
name = "add_license",
description = "Propose adding the license header to a file",
input = agent.schema.object({ path = { type = "string" } }, { "path" }),
run = function(args)
local text = require("@greed").load(args.path):text()
local first = string.match(text, "^[^\n]*\n") or text
-- Waits until the user has accepted or rejected it.
return agent.propose(args.path, {
{ old_text = first, new_text = "-- SPDX-License-Identifier: MIT\n" .. first },
}, "add the license header")
end,
})
agent.propose_files proposes changes to several files as one operation,
agent.propose_ranges does it by byte ranges (for edits from a language
server or a diff), and agent.ask(title, questions) asks the user and
waits for their answers. When an MCP client’s connection closes while its
proposal waits, what’s left of the proposal is rejected and the tool call
returns.
Each tool costs the agent tokens on every request, so a plugin with
several should put them in a group, which agents switch on with the
tools tool when they need it:
agent.group("todo-sync", "Syncing todos with the issue tracker")
agent.tool({ name = "issues_list", group = "todo-sync", description = "...", run = list })
The group’s line is what an agent reads when deciding whether to switch it on, so say what it’s for. See Agents for the groups Greed has.
Tests
local test = require("@greed/test")
test("greet says hello", function(t)
t:run("greet", { "world" })
assert(t:messages()[1] == "hello world")
end)
test("copy and paste at every selection", function(t)
-- | marks each selection's head, ^ its anchor
t:buffer("^ab| ^cd|")
t:keys("y p")
t:expect("ab^ab| cd^cd|")
end)
greed test DIR runs a plugin’s tests, each in a fresh editor with the
default plugins loaded. Give it several folders (greed test runtime/plugins/*/) to test several plugins at once. Tests run side by
side, as many at a time as the machine has cores, and the results are
printed plugin by plugin. A test file requires your plugin’s other files
with require("../log") and gets the ones your plugin loaded, state and
all, so internals can stay out of what your plugin returns.
greed check DIR (or greed check in the plugin’s folder) does what the
editor does before it trusts a plugin: strict type checking against
Greed’s types and the other plugins’, so require("@theme") checks too,
then the tests, then warnings like keys bound to commands that don’t
exist. It needs no .luaurc in the plugin, so it suits a plugin with a
repository of its own, and its CI:
- run: nix run github:johnae/greed -- check .
t:keys("i") presses keys and t:type("hello world") types text a
character at a time, newlines as enter. t:draw(cols, rows) and
t:screen(cols, rows) give what a client would show, as lines of text;
t:frame(cols, rows) gives the screen as the window draws it, to check
how it looks: its rows, the images and scenes (charts) placed and
the cells they cover, and cell(col, row) for a cell’s text, size and
colors. t:status() the status line, t:floats() the floats’ text and
t:notices() the desktop notifications sent; t:clipboard_image(png)
sets what greed.clipboard.image() gives. t:ssh_agent_use(host) acts
as a program asking to sign with your ssh key (it emits ssh_agent.use
and returns the request’s id) and t:ssh_agent_answer(id) gives what
plugins answered. t:wait(ms) moves the clock
forward for code that sleeps, t:wait_for(check) waits for real until
check() is true (for a program’s output; 15 seconds at most unless told
otherwise), and t:tempdir(files) makes a
folder of files to work on; t:open(path) opens one of them as
greed.open does, without your plugin needing fs.read for it.
Tests have no system keyring, so secrets go to the test’s own file;
t:keyring(program) has a program stand in for secret-tool (one that
isn’t installed acts as a keyring that can’t be reached).
local dir, git = t:repo("git", files) makes a repository (jj or git)
with the files committed and returns a function that runs git there and
fails the test if it fails; t:vcs("jj", dir) gives that function for a
folder you set up yourself. t:marked() is the buffer with its markers,
and t:quitting(), t:detached() and t:switched() say whether
something asked the editor to exit, to let the client go, or to send it
to another session.
t:run waits for background work the command starts, but not for the
programs it reads from, like a shell block’s: wait for those with
t:wait_for, checking what you’re waiting for (block.status ~= "running", a picker’s float). A message your command shows while it
waits is there before the program finishes, so it’s not something to wait
for.
Each t:tempdir(files) call makes a new folder, so put every file a test
needs in one call. Files written from Luau aren’t executable: to fake a
program, write it and make it runnable with chmod, then put its folder
first on a shell’s PATH, as the docker plugin’s tests fake docker:
local shell = require("@shell")
-- A shell whose `docker` prints a table for `ps`.
local function fake(t: test.TestContext): shell.Shell
local dir = t:tempdir({
["bin/docker"] = '#!/bin/sh\nprintf "CONTAINER ID IMAGE NAMES\\n3f2a1b4c5d6e nginx web\\n"\n',
})
assert(greed.process.run({ "chmod", "+x", `{dir}/bin/docker` }))
local sh = shell.open({ cwd = dir, show = false })
local path = assert(greed.process.run({ "printenv", "PATH" })).stdout
sh.env.PATH = `{dir}/bin:{string.gsub(path, "\n$", "")}`
return sh
end
Tests don’t show the message about code that held the editor up, so a
busy machine doesn’t change what t:messages() returns. Each key a test
presses and each command it runs gets the time limit a key press gets in
the editor, and time spent waiting for programs and background work
doesn’t count toward it.
t acts as the session’s first client. t:client(name) adds another, as
if a second terminal attached, seeing what the first one does; it has
keys, type, run, mouse, draw, screen, frame, status,
marked, expect, expect_mode and id, all as that client:
test("each client has its own mode", function(t)
t:buffer("|hello")
local laptop = t:client("laptop")
laptop:keys("i")
laptop:expect_mode("helix-insert")
t:expect_mode("helix")
end)
Types
The API’s types are in runtime/types/greed. greed new sets up a
.luaurc so luau-lsp in your editor and luau-analyze --mode=strict
check your plugin against it.
greed reference DIR writes the reference pages this site has, as
Markdown: every loaded plugin with its commands, keys and options, every
option, every event, and the whole API. With your config and plugins loaded, they
describe your own setup.
Sharing a plugin
Put your plugin in a git repository of its own, with plugin.toml at the
top, and anyone can install it with one line in their config. Like this,
for zenbones:
require("@git-plugins").use("https://github.com/johnae/greed-zenbones")
Docs go in a docs folder, as plain Markdown. Once the plugin is
installed, :docs and space h d list those pages after the manual’s,
and space h / searches them too. README.md comes first, then the rest
by name, each titled by its first heading (a SUMMARY.md like this
manual’s sets the order instead).
Links and pictures relative to the page work in the editor and on GitHub alike, so the same folder reads fine in both. Zenbones has one, if you want something to copy.
Run greed check . in its CI and you’ll hear about it when a new Greed
breaks something. greed = "0.4" in plugin.toml keeps an older Greed
from loading it at all. Once it’s out there,
Plugins to install says how to get it listed.
Loading and reloading
Greed loads the default plugins, then yours, then init.luau. Each plugin
runs in its own environment and owns what it registers: reloading a plugin
replaces its commands, keys, options, handlers and theme entries, and
greed.plugin.unload(name) removes them. Both also stop what the plugin
was running (its tasks from greed.spawn, and commands and handlers
waiting on a timer or a reply), clear the marks it set (in a namespace two
plugins write to, the marks belong to whichever set them last), close its
floats and panels, forget its images, stop its greed.fs.watch watches,
and put back the file types and language servers it replaced. A plugin
that runs too long is stopped, so a mistake in a loop can’t hang the
editor.
What a plugin adds through another plugin goes with it too: its agent
tools, status line pieces, actions, features, styles, command line aliases
and the like. There’s no need to pass your plugin’s name or to clean up on
plugin.unloaded.
For what Greed doesn’t know about, like a lock file you wrote or a process
another program keeps for you, hand greed.plugin.cleanup a function. It
runs when your plugin is unloaded or reloaded, like this:
greed.plugin.cleanup(function()
greed.fs.remove(lock)
end)
It runs before your plugin’s tasks are stopped, so don’t wait in it: what it starts stops with the rest. If it fails you see the error, and the plugin still goes, with its other cleanups run.
Keeping a registry of your own
A plugin that lets others add to it, like a list of handlers, uses the
same greed.plugin.cleanup(remove). Called in the function others call, it
runs remove when the plugin that called it is unloaded or reloaded, and
returns that plugin’s name. So what another plugin added goes with it.
Called from your own plugin, it runs when yours goes, which for a registry
entry does no harm. greed.plugin.caller()
just says who called. require("@core").registry makes the remove: set
puts a value in a table under a key, put adds to a list, and each returns
a function that takes the entry out unless it was replaced since. For an
entry you put in a list yourself, remover(list, entry) makes that
function. tell(listeners, ...) calls each one with ...; one that fails
has its error shown and the rest still hear.
local core = require("@core")
local M = {}
local greeters: { [string]: () -> string } = {}
function M.greeter(name: string, greet: () -> string)
greed.plugin.cleanup(core.registry.set(greeters, name, greet))
end
Other plugins’ modules are read-only
require("@name") gives a plugin a read-only view of another plugin’s
module: reading works as usual, nested tables too, and setting anything
raises an error, so no plugin can replace another’s functions or settings.
Offer functions for what others may change, as core.style.typing_kind or
models.role do. Your config, a trusted project’s .greed folder, the
REPL and tests get the modules themselves, so the settings the docs show
you assigning, like models.roles.fast = ..., work there. Go through a
view with for k, v in t do and #t; pairs, ipairs and the table
functions don’t see through it.
Trying code
:lua CODE runs Luau in a scratch environment whose globals last, and
:= EXPR shows what an expression is. In any buffer, space l e runs the
selection, or the line the cursor is on, the same way, and shows what it
returned at the end of its last line (or the error); the next edit takes
it away, as while writing a plugin or your init.luau:
#greed.buffers() -- space l e here shows how many are open, like ⇒ 3
Building interfaces
core.ui draws an interface into a buffer as text and marks. A plugin
describes what to show for its state, and core.ui lays it out for the
view’s width and changes only the lines that changed. The result is text,
so search, copy, y, an agent’s read and the usual keys work on it, in
the terminal and in the window. The picker, completion, the command line,
the undo tree and the agent’s chat are built with it.
A first view
A small inbox: a search field, a toggle, and a list of messages that
opens one when you press it. :inbox shows it in a float.
local greed = require("@greed")
local core = require("@core")
local ui = core.ui
type Message = { id: number, from: string, subject: string, read: boolean }
local messages: { Message } = {
{ id = 1, from = "Ada", subject = "Lunch on Friday?", read = false },
{ id = 2, from = "CI", subject = "main is green again", read = true },
{ id = 3, from = "Grace", subject = "The release notes", read = false },
}
local function render(view: core.UiView, state): core.UiNode
local shown = {}
for _, m in messages do
if state.unread_only and m.read then
continue
end
if string.find(string.lower(m.subject), string.lower(state.query), 1, true) then
table.insert(shown, m)
end
end
return ui.column({
ui.row({
ui.field("Search", state.query, function(text)
view:set({ query = text })
end),
ui.toggle("Unread only", state.unread_only, function(on)
view:set({ unread_only = on })
end),
}),
ui.gap(),
ui.list(shown, function(m: Message)
return {
ui.span(if m.read then " " else "● ", "ui.menu.badge"),
ui.span(string.format("%-8s", m.from), "ui.menu.doc"),
ui.span(m.subject),
}
end, {
open = function(m: Message)
m.read = true
view:redraw()
greed.echo(`{m.from}: {m.subject}`)
end,
}),
})
end
greed.command({
name = "inbox",
doc = "Show the inbox",
run = function()
local buffer = greed.create_buffer("inbox", "", { readonly = true })
greed.float(buffer, { title = "Inbox", width = 60, height = 12 })
local view: core.UiView
view = ui.mount(buffer, function(state)
return render(view, state)
end, { query = "", unread_only = false }, {
key = function(m: Message): string
return tostring(m.id)
end,
draw = false,
})
view:redraw()
end,
})
It draws as:
Search: [ ] ☐ Unread only
● Ada Lunch on Friday?
CI main is green again
● Grace The release notes
ui.mount(buffer, render, state, opts) ties a render function and its
state to a buffer and gives back the view. render is called with the
state whenever it changes or the buffer’s views change width, and returns
nodes. draw = false holds the first drawing until view:redraw(), so
the widgets’ functions can use view once it’s set.
State and drawing again
view:set(patch)mergespatchinto the state and draws again.view:redraw()draws again from the state as it is, after something outside it changed, like a message marked read above.view:soon(patch)draws once for a burst of changes, as tokens of an answer streaming in.view:unmount()stops drawing; the buffer keeps what it showed last.
Only lines whose text or marks changed are written, so a cursor elsewhere stays put. While a view is resized, as when you drag its pane’s edge, it’s drawn at once, then at most every 100 ms, then once more where the drag ends.
The parts
| Node | What it draws |
|---|---|
ui.text(text, style?) | Text, wrapped to the width |
ui.markdown(text) | Markdown: prose wrapped like ui.text, but code blocks and tables keep their lines (cut with … at the edge), and a table’s columns line up. Chat messages use it |
ui.span(text, style?) | A piece of a line, for line, list and grid |
ui.line(spans) | One line of spans |
ui.tabs(tabs) | A line of tabs, each { label, current, press }, numbered from 1; the current one picked out |
ui.column(nodes) | Nodes one under another |
ui.row(nodes) | Nodes side by side |
ui.gap() | An empty line |
ui.box(title, node, style?) | A node in a border with a title |
ui.button(label, on_press) | A button |
ui.field(label, value, on_change) | A value shown in a box; pressing asks for a new one |
ui.toggle(label, on, on_change) | A check box |
ui.list(items, spans, { open, current }) | An item a line; pressing one calls open |
ui.grid(rows, { gap }) | Columns lined up without borders |
ui.table({ columns, rows, on_open }) | A table with borders |
ui.keyed(key, version, build) | A part drawn again only when its version changes |
A span can carry more than text: press makes it a widget of its own,
value is what it stands for (below), tag names it for
view:spots(tag), line styles its whole line, and marks are marks of
its own counted from its start. ui.matched(text, positions) gives the
spans of a fuzzy match with the matched letters picked out, as menus show
them.
Keys and focus
tab and shift-tab move between widgets, and enter, space or a
click presses the one under the cursor. The cursor is the focus, so each
client looking at the view has its own. The other keys are the buffer’s
as usual: / searches the view, y copies from it. With keys = false
in the options, tab and shift-tab are left to your plugin.
Values under the cursor
A span’s value belongs to its line, so the plugin can ask what the
cursor is on without tracking line numbers. ui.list and ui.grid set
each line’s value to its item or row.
view:value_at(pos)gives the value of the span atpos, else of its line. On a line of several things, like a strip of tabs, it gives the one under the cursor.view:value_on(line)gives a line’s value,view:values()all of them, andview:each(f)callsfwith each line that has one.view:line_of(f)finds the first line whose valuefsays yes to, to put the cursor there.
With key in the options, naming each value (m.id above), a cursor
stays on its item as the lines change places, as when the list is filtered
or sorted again. ui.list(items, spans, { current = n }) marks row n as
a menu’s selected row, for a list whose cursor is somewhere else.
Long views that change at one end
A chat or a log grows at the bottom while the rest stays. Wrap each part
in ui.keyed(key, version, build): a part whose key and version are the
same as last time isn’t built or laid out again, so a streamed token
costs what its message does rather than the whole transcript.
local parts = {}
for _, m in messages do
table.insert(parts, ui.keyed(m.id, #m.text, function()
return ui.text(m.text)
end))
end
return ui.column(parts)
A keyed part is laid out again for a new width, unless
ui.keyed(key, version, build, { any_width = true }) says its lines don’t
depend on it (the view wraps them, as it does a message’s text).
A view with an input
With input = true, the view is drawn at the top of the buffer and what’s
written under it belongs to the user, like a chat’s box. The view’s part
is read-only, view:input() reads what’s written and view:input_start()
says where it begins. With above = true too, the first line is the input
and the view is drawn under it, as the picker’s list is under its query.
Testing it
Plugin tests drive a view with keys, as a user would:
local test = require("@greed/test")
test("the inbox filters and opens messages", function(t)
t:buffer("|x")
t:run("inbox")
t:keys("tab tab enter") -- the field, then the toggle, pressed
local shown = t:floats()[1]
assert(not string.find(shown, "main is green", 1, true), shown)
t:keys("tab enter") -- the first message
local said = t:messages()
assert(said[#said] == "Ada: Lunch on Friday?", said[#said])
end)
More
The rest of the options (ns and width for marks and layout, after
to draw with each frame, ui.pieces to draw nodes as a mark’s lines) are
in Writing plugins and the types of core.ui in the
plugin reference under core (Plugins).
Agents
Agents are clients of the running editor. They read buffers with your
unsaved changes, see your selections and the language servers’ diagnostics,
open files and propose edits you review in the buffer. Every tool is also a
shell command (greed ctl). What they may do without asking is in
Permissions and sandboxing.
There are four ways in:
- Greed’s own agent, with any model you set up (Anthropic, OpenAI, Berget, Mistral, Ollama).
- An ACP agent run inside Greed: Claude Code, Codex, Gemini CLI, opencode.
- Any MCP client, using
greed mcp. - Claude Code’s
/ideconnection.
From the shell: greed ctl
greed ctl tools # what the editor offers
greed ctl read --help # what a tool does and the arguments it takes
greed ctl focus # the current file, selections, visible lines
greed ctl status # what needs you, and the agents at work
greed ctl watch # the same as JSON lines: at once, on each change, every 15 s
greed ctl read path=src/main.rs from_line=10 to_line=20
greed ctl diagnostics
greed ctl eval code='return require("@greed").mode.get()'
Arguments are key=value pairs or one JSON object. Values that parse as
JSON are JSON, and key=@- reads the value from standard input. An unknown
or missing argument is an error naming the ones the tool takes. Relative
paths are from the project’s root; ~ is your home folder.
greed ctl talks to the session named by $GREED_SESSION, or the only one
running; with several, the one whose project holds the folder you run it in.
Greed’s terminals and shells set $GREED_SESSION. Each session’s socket is readable only by you and needs a token
from a file only you can read.
greed ctl watch [SESSION] prints the whole status as a JSON line at once,
again on each change (an agent starts waiting, a command finishes out of
sight), and at least every 15 seconds, so a script can tell a session that
went away from a quiet one. greed ctl watch | jq always shows the latest.
Agents as MCP clients
Any agent that speaks MCP can use Greed’s tools: add greed mcp as a
server. In the common ones:
claude mcp add greed -- greed mcp # Claude Code
codex mcp add greed -- greed mcp # Codex
gemini mcp add -s user greed greed mcp # Gemini CLI
opencode takes it in its config (~/.config/opencode/opencode.json):
{ "mcp": { "greed": { "type": "local", "command": ["greed", "mcp"] } } }
An agent you run from Greed’s agent pane gets these tools already, as
greed, so it needs none of this. greed mcp finds its editor the way
greed ctl does: an agent started in a project’s folder, or from a
terminal in Greed, reaches that project’s session even with several open.
greed mcp connects an MCP client to the running editor. On connecting,
the client is told where your config is, how to extend Greed with a plugin,
and which tool groups it can switch on. The tools:
| Tool | What it does |
|---|---|
focus | What you are in, a file or not (the last one, while an agent’s pane has focus), its view and buffer ids, your selections with their text, the lines on screen, the mode (as greed.mode.get() names it, like helix-insert, with the status line’s insert as its label) and the editing style |
buffers | Open files and which have unsaved changes |
read | A file as the editor has it, unsaved changes included, or a buffer or view by its id (buffer:12) |
diagnostics | Errors and warnings from language servers |
history_recent | What changed lately in open files, who changed it (you, a plugin, an agent, the disk) and a diff |
context_get | What you pinned for agents (space i p, see the context): selections, files, problems, the changes in progress, objects as they are now |
working_set | The files you’ve worked in lately, most active first, with how much you and agents edited each and the lines you were on |
repo_map | A map of the project: the functions and types that matter most, with their files and lines, ranked toward what you’re working on (below) |
symbols | Functions and types anywhere in the project whose names match, with their files and lines |
grep | The lines matching a regex in the project, with open files searched as you have them, unsaved changes included; also in your config and its plugins, and Greed’s own plugins and types |
files | The project’s files, or those whose paths match a fuzzy query; or a folder’s, in the project, your config or Greed’s own plugins |
outline | A file’s functions and types with their lines, from its syntax tree |
syntax_query | Run a tree-sitter query over a file and get what it matched |
open | Open a file for you, at a line |
propose | Propose edits to one or more files for you to review |
rename | Rename a name everywhere it’s used, as the language server works it out, proposed for you to review |
code_actions, code_action | The language server’s quick fixes and refactors for some lines, and proposing one; actions that would run a command in the server are refused, since they can’t be shown first |
ask | Ask you questions, with choices or a typed answer, on a page you fill in and send; the answers come back to the agent |
project | The project’s root folder |
status | This session at a glance: what needs you (an agent waiting for an answer, a command that finished out of sight), oldest first with why and since when, and the agents at work with their state and the question they wait on; greed ctl status gives the same, as JSON |
objects, inspect, act | The objects of the running editor (buffers, views (panes, floats and panels like an agent’s chat), tabs, terminals, shells and their blocks, language servers, proposals, agent sessions, plugins and what plugins add): list them by kind or by what they relate to, see one’s state, relations, actions and what was done to it (by you or an agent), and run an action on it as you would from the inspector (space h i), like closing a view or a buffer by its id; act says back what each object was and the views after, when they changed. Actions run in the view you were in, as run_command does. Agents in Greed ask before act, which takes several ids at once; an action that deletes or stops something always goes to you to review first, all of them together, whatever the agent was allowed, and you may run some and not others. Deciding on proposed changes stays yours |
commands, run_command | Find the editor’s commands by words in what they do (those matching the most words first), with how each is typed and what its arguments are, and run one with its arguments checked as the command line checks them (a wrong one gives back the usage and nothing runs). It runs in the view you were in (the one focus reports, never the agent’s own chat), or in the view the agent names, and says back which view that was and, when views closed or opened, the views there are now. A command that may close, delete or stop something asks you every time, naming the view it would run in |
eval | Run Luau inside the editor: sandboxed first, then a reviewer or you for anything more (below); what it edits is one operation you can review and undo |
describe | What a command, option, event, API function or type, plugin or mode is: its doc, keys, value, who defined it and where; greed.tab lists a module’s functions and View a type’s methods |
why | How some lines came to be: each change that made them, newest first, with its description and diff |
plugin_guide, plugin_try, plugin_install | Write a plugin (below) |
debug_log | What Greed and its plugins say they do while a debug topic is on (keys, runs, frames, language server messages, programs, a plugin’s own greed.debug.log lines): turn topics on, do the thing, read the lines |
notes_list, notes_search, notes_read, notes_write | Your notes: find, read, write and add to them; rewriting a note that’s there is proposed for you to review |
notes_todos, notes_add_todo, notes_add_thought | The todos in your notes, soonest due first, and adding a todo or a thought |
notes_update_todo | Change one todo: its text, due date or reminders, or tick it |
notes_remind | Add reminders to a line of a note, or add a todo with them (“remind me this evening and tomorrow at lunch”) |
mail_search, mail_read, mail_show, mail_act | Your mail: search it as the mail list does, read a thread (which stays unread), show one to you, and mark, flag, tag, archive or trash mail; changing mail asks you first, and nothing is deleted for good |
search_everywhere | Your notes, mail and chat at once, as space n s searches them, newest first; in:notes and the like pick some, ref:PLAT-12 finds what mentions a ticket, MR, commit or link. Reading mail or chat asks you the first time in a project |
plan_read, plan_write | The plan you share (below): its checklist as you have it, and replacing it, which gives back the version to write with next |
decisions, decision_read, decision_propose | What was decided for the project, and proposing a decision for you to accept |
memory_list, memory_propose | Your standing preferences (below), and proposing one for you to accept |
subagent | Hand a task to a helper agent with an empty context and get its report; Greed’s own agent has it from the start (below) |
blocks_list, blocks_run | The runnable code blocks in a Markdown file, and running one, in files you trust and as you last ran it; the result is saved under the block |
web_fetch | Read a page as Markdown, or have a small model answer a question from it (below) |
web_search | Search the web, or the news, with the service you set up (below) |
research | Hand a question to a helper that searches and reads the web, and get its report with sources (below) |
shell_run | Run a command in the project’s shell, where you see it marked ◆, and get back its id, exit code, output, errors, how long it took, the files and lines it names, its JSON and a table’s first rows; one that runs past timeout_s comes back as running |
shell_read, shell_wait, shell_kill | A shell block by id, or the latest one (yours too), waiting for one still running, and stopping one an agent ran |
tools | The groups of tools below, and switching one on |
Tool groups
Each offered tool costs tokens on every request, so most tools come in
groups an agent switches on with tools. Always offered: focus,
buffers, read, diagnostics, propose, open, project, files,
grep, symbols, outline, ask, eval, describe, context_get,
objects, inspect, act, commands, run_command, memory_list,
memory_propose and tools.
| Group | Tools |
|---|---|
plan | plan_read, plan_write, decisions, decision_read, decision_propose |
map | repo_map, working_set |
refactor | rename, code_actions, code_action |
history | history_recent, why |
notes | the notes_ tools |
syntax | syntax_query |
blocks | blocks_list, blocks_run |
plugins | plugin_guide, plugin_try, plugin_install, debug_log |
subagents | subagent |
web | web_search, research |
shell | shell_run, shell_read, shell_wait, shell_kill |
mail | mail_search, mail_read, mail_show, mail_act |
chat | chat_rooms, chat_read, chat_search, chat_send |
everywhere | search_everywhere |
:set agent-tool-groups "plan notes" gives agents those groups from the
start (default plan); "all" gives every tool. MCP clients are told when
their list changes, and each connection has its own. greed ctl always has
every tool.
The web
Agents always have web_fetch, so you can paste a link and say “read
this”. It gives the page’s main content as Markdown, without its menus
and footers, as a browser’s reader view shows it. Given a question, the
fast model (see :models) reads the page instead and only its answer
comes back, which keeps a long page out of the agent’s context; with no
fast model set up, the agent gets the whole page.
Searching is the web group, and needs a service:
local greed = require("@greed")
greed.option.set("web-search", "brave") -- or "exa", "tavily", "searxng"
-- then :secret-set brave (exa, tavily); SearXNG needs no key, only where it is:
greed.option.set("web-search-url", "https://searx.example.org")
web_search with news searches the news instead, each result with its
date. To have results from sources you trust first, name their domains,
subdomains included; web-sources-only keeps only those:
greed.option.set("web-sources", "reuters.com apnews.com docs.rs")
greed.option.set("web-sources-only", false)
For anything that takes more than a page, research hands the question
to a helper: Greed’s own agent, with only web_search and web_fetch, a
few calls of each (depth "thorough" gives it more). It searches,
reads, and reports back the answer with its sources as links, so the
pages stay out of the asking agent’s context. You can ask it yourself:
:research what changed in tokio 1.45
That opens the helper’s transcript, where you watch it work and the report ends up.
Pages can say anything, including “ignore your instructions and…”. They
reach the agent between <untrusted-…> tags naming their source, as do
command output and text from your files, and agents (Greed’s own and MCP
clients) are told to read what’s inside as data. Secrets in it (private
keys, API tokens, values named like passwords) are hidden first. What an
agent does next goes through the usual checks: edits are proposals or ask
first, risky commands always ask, eval runs sandboxed (see
Permissions and sandboxing). The group is off until an
agent switches it on, unless agent-tool-groups names it.
The repo map
repo_map gives an agent a few thousand tokens of the project’s layout:
the first line of each function and type that matters most, grouped by
file. Files are linked to the files defining the names they use, then
ranked toward your working set. :repo-map shows what an agent would get
now.
The working set is the files you’ve worked in lately. Your edits count
most, an agent’s less, moving around a little; activity 15 minutes ago
counts half as much as now. :working-set shows it.
What eval may do
greed ctl eval from a shell runs as you. For agents, eval runs
sandboxed first, where the code can read the editor and edit buffers;
code that needs more goes to a reviewer model or to you, as the
agent-eval option says (auto, ask, allow or off).
Permissions and sandboxing has
the details, and :eval-log lists every run past the sandbox and who let
it.
Reviewing proposed edits
propose takes one or more files, each with edits that replace exact text
with new text. In the buffer the old text is struck through with the new
text after it; when whole lines change, the new lines show under the old
ones with the changed words picked out. A message says how many changes
came in, where, and the keys to review them.
A proposal is one change, so you decide on all of it: look it over, then
accept or reject the lot, with the keys or by clicking accept all,
reject all or note after its first change. Nothing changes until you
do. Going change by change is there too, when only part of it is right:
| Keys | |
|---|---|
space o A space o R | Accept or reject the whole of the proposals in this file, in every file they change |
space o N | Reject them and tell the agent what to do instead: what you type goes back to it, so it can propose again |
space o o | Pick a proposal: each agent’s change, with the files it changes |
] o [ o | Next and previous proposed change |
space o a space o r | Accept or reject only the changes your selections touch |
space o n | Reject those and tell the agent what to do instead |
space o d | Show the file with every change in, beside it; again to hide |
Pending changes follow your edits; one whose own text you edited isn’t
accepted over your edit (undo it, or reject the change). The agent waits,
then hears which changes went in along with the language server’s
diagnostics for those files. If the agent goes away while its proposal
waits, like a Claude Code session you quit, what’s left is rejected. Same
when it gives up on the call: you stop Claude Code mid-turn, or ctrl-c
Greed’s own agent, and its proposal goes from the buffer. A newer
proposal for text that already has one waiting replaces the older one,
whichever agent made it, and the older agent hears so.
What you accept from one proposal is an
operation: space u u undoes it in every file at
once, space u o reviews it. A file the undo takes back to what’s saved no
longer shows as changed.
In the side-by-side view (space o d) the panes scroll together, matching
lines, and the right one updates as you edit, accept and reject.
Questions on a page (ask)
ask shows an agent’s questions as a page in a float. (Questions about
whether it may do something are in Permissions and
sandboxing.) Each question may have choices, and has an
Answer: line for your own words, alone or with a choice.
| Key | |
|---|---|
enter | On a choice: pick it and go to the next question. On an Answer: line: start typing, then go to the next; on the last line, send |
ctrl-s | Send from anywhere on the page |
Send gives your answers to the agent; Cancel, or closing the page, tells it you didn’t answer. Clicking a choice picks it.
The agent sends questions as plain data and Greed writes the page, with anything that could start Markdown syntax escaped, so a question can’t add a button, a code block or a choice of its own. Only you can send the page.
A plan and decisions you share
An agent can keep its plan in the project’s notes (.greed/notes/plan.md,
the note project:plan; see Using Greed):
a Markdown checklist you can change while it works (tick a step with
space n x, reorder, add, delete). :plan opens it, and open steps show
in your agenda. A write names the version the agent read; if you changed
the plan since, the write is refused and the agent gets your version.
Agents like Claude Code and opencode keep todo lists of their own. To have
them use this plan instead, say so in the project’s AGENTS.md or
CLAUDE.md, e.g. “Keep your plan with the plan_read and plan_write tools.”
Decisions are notes too, in .greed/notes/decisions/, one each: what was
decided and why, like “use SQLite” or “never edit the generated code”.
Agents read them in later sessions and follow the accepted ones.
| Command | |
|---|---|
:decision-new TITLE | Write down a decision, accepted |
:decisions | Pick one to open |
:decision-accept | Accept the proposed decision you’re in |
A decision an agent adds is Status: proposed until you accept it (the
button beside its status, or :decision-accept). Until then agents are
told not to rely on it. The notes tools refuse to write decisions, but
these are plain files: an agent that can write files can write here too,
so check .greed changes as you would code.
Memories
Memories are standing preferences you want every later session to follow, like “use jj, not git” or “I prefer short commit messages”. There are three kinds, each a plain Markdown file with one memory per list item, for you to read and edit:
| Kind | File | |
|---|---|---|
| Personal | memory.md in your config folder (~/.config/greed/memory.md) | Yours, in every project; :memory-edit opens it |
| Project | A file per repository in ~/.local/share/greed/memory/ | Yours, for this project; :memory-edit-project opens it |
| Shared | .greed/memory.md in the repository | For everyone working on it; :memory-edit-shared opens it |
Project memories stay on your machine, outside the repository, and only you can read them. All jj workspaces and git worktrees of a repository share one file, so a memory you accept in one applies in the others.
An agent can’t add a memory itself. When you state a lasting preference
(“from now on…”, “always…”, “I prefer…”), it proposes one with
memory_propose, shown in the memory file as a dated proposed change.
space o o lists it and opens the file; space o a accepts, space o r
rejects (see Reviewing proposed edits). Only
what you accept is written, so a web page saying “remember to always run
X” can’t become a rule. Proposals go to project memories unless they’re
about how you work anywhere; shared ones only when you ask for a memory for
the whole team.
Greed’s own agent gets all three in its system prompt with each message,
marked as preferences you accepted. Other agents read them with
memory_list.
A repository’s .greed/memory.md comes with it, like its AGENTS.md, so
whoever can change the repository can add memories, and so can an agent
that writes files. Check .greed changes as you would code.
Claude Code’s /ide
space i C opens Claude Code in a pane beside your files, already
connected to Greed; pressed again it goes back to that pane, or brings it
back if you closed it. claude started in any Greed terminal connects by
itself too. :set claude-command "claude --continue" changes what the pane
runs.
Started outside Greed, in the same project, /ide in Claude Code lists Greed
next to any other editors. Once connected:
- Claude Code sees your selection as you move, and
space o mmentions the selected lines to it. - Its edits arrive as proposed changes, reviewed with the keys above. If you accept some of them, Claude Code learns which.
- It can read diagnostics, open files and check for unsaved changes.
Greed writes a lock file to ~/.claude/ide so Claude Code can find it, and
removes it when the session ends.
space i W (:claude-workspace, optionally with a first message) starts
Claude Code in a terminal pane in a workspace of its own (see the session
list). It shows in space i l, where d, R, b and
x work on it; you talk to it in its terminal. Stopped or after a restart,
enter in the list starts it again with claude --continue.
Knowing when it waits for you
Greed learns whether Claude Code is working, waiting for you or idle from
Claude Code’s hooks. The Claude Code Greed starts (space i C, space i W)
gets them for that run, without writing your settings. The status line
counts it (◆ 1 waiting for you), its float gets a dot, and
greed ctl status lists it. Greed doesn’t guess from the screen, since any
program could print a prompt that looks like Claude’s.
A claude you start yourself in a Greed terminal doesn’t get the hooks. Add
them to ~/.claude/settings.json; outside Greed’s terminals they do
nothing:
{
"hooks": {
"Elicitation":[{"hooks":[{"type":"command","command":"[ -z \"$GREED_TERMINAL_ID\" ] || \"$GREED_BIN\" ctl agent_hook terminal=\"$GREED_TERMINAL_ID\" hook=@- >/dev/null 2>&1; true"}]}],
"PermissionDenied":[{"hooks":[{"type":"command","command":"[ -z \"$GREED_TERMINAL_ID\" ] || \"$GREED_BIN\" ctl agent_hook terminal=\"$GREED_TERMINAL_ID\" hook=@- >/dev/null 2>&1; true"}]}],
"PermissionRequest":[{"hooks":[{"type":"command","command":"[ -z \"$GREED_TERMINAL_ID\" ] || \"$GREED_BIN\" ctl agent_hook terminal=\"$GREED_TERMINAL_ID\" hook=@- >/dev/null 2>&1; true"}]}],
"PostToolUse":[{"hooks":[{"type":"command","command":"[ -z \"$GREED_TERMINAL_ID\" ] || \"$GREED_BIN\" ctl agent_hook terminal=\"$GREED_TERMINAL_ID\" hook=@- >/dev/null 2>&1; true"}]}],
"PostToolUseFailure":[{"hooks":[{"type":"command","command":"[ -z \"$GREED_TERMINAL_ID\" ] || \"$GREED_BIN\" ctl agent_hook terminal=\"$GREED_TERMINAL_ID\" hook=@- >/dev/null 2>&1; true"}]}],
"PreToolUse":[{"hooks":[{"type":"command","command":"[ -z \"$GREED_TERMINAL_ID\" ] || \"$GREED_BIN\" ctl agent_hook terminal=\"$GREED_TERMINAL_ID\" hook=@- >/dev/null 2>&1; true"}]}],
"SessionEnd":[{"hooks":[{"type":"command","command":"[ -z \"$GREED_TERMINAL_ID\" ] || \"$GREED_BIN\" ctl agent_hook terminal=\"$GREED_TERMINAL_ID\" hook=@- >/dev/null 2>&1; true"}]}],
"SessionStart":[{"hooks":[{"type":"command","command":"[ -z \"$GREED_TERMINAL_ID\" ] || \"$GREED_BIN\" ctl agent_hook terminal=\"$GREED_TERMINAL_ID\" hook=@- >/dev/null 2>&1; true"}]}],
"Stop":[{"hooks":[{"type":"command","command":"[ -z \"$GREED_TERMINAL_ID\" ] || \"$GREED_BIN\" ctl agent_hook terminal=\"$GREED_TERMINAL_ID\" hook=@- >/dev/null 2>&1; true"}]}],
"UserPromptSubmit":[{"hooks":[{"type":"command","command":"[ -z \"$GREED_TERMINAL_ID\" ] || \"$GREED_BIN\" ctl agent_hook terminal=\"$GREED_TERMINAL_ID\" hook=@- >/dev/null 2>&1; true"}]}]
}
}
Greed’s terminals give their programs $GREED_TERMINAL_ID (which terminal)
and $GREED_BIN (the greed running the session, also where greed ssh put
it), so this works on other machines too. Other agents with hooks can call
greed ctl agent_hook the same way with agent=NAME.
Agents inside Greed
Greed runs agents over the Agent Client Protocol (ACP): Claude Code
(through claude-agent-acp), Gemini CLI, Codex (codex-acp), OpenCode, or
any agent on your PATH that speaks it, plus its own agent (below). Each
gets a transcript buffer, and several can work at once.
space i n lists them and says which aren’t installed, with the command
that installs each:
npm install -g @agentclientprotocol/claude-agent-acp # Claude Code
npm install -g @google/gemini-cli # Gemini CLI
npm install -g @zed-industries/codex-acp # Codex
npm install -g opencode-ai # OpenCode
A new session’s transcript opens with you typing in its box.
:agent-new greed add tests for the parser starts that agent, by name
(greed, claude, gemini, codex, opencode or one you registered), in the
project, on that first message, picking nothing. From a shell, or a script:
greed ctl run_command name=agent-new 'args=["greed", "add tests for the parser"]'
Shell code an agent writes (a sh, bash, nu or console block; in
console, the lines after a $ prompt) has buttons on its opening fence.
Click one, press enter on the fence, or space . on it:
| Button | |
|---|---|
▶ run | Run it as a block in the project’s shell, in the agent’s folder, its output showing in a float as it comes; ctrl-c stops it, esc closes the float, space o w finds it later |
↳ prompt | Put it at the shell’s prompt, in a float, to change first; enter runs it |
◆ agent runs it | Ask the agent to run it itself, with its own tools and the usual questions |
⧉ copy | Copy it |
Once a command you ran with ▶ run or ↳ prompt is done, how it ended
and the last 30 lines it printed go along with your next message, so “that
failed, why?” just works. The agent can read the rest from the shell.
A command that destroys, stops or sends something (rm, kill,
git push, kubectl delete, curl -X DELETE and the like) asks y/n
first, saying why.
To show the agent a screenshot, copy it and press alt-v in the
transcript (in the window, the paste keys work too). It goes with your next
message, shown in the box as 🖼 image 1 · 1280×720; alt-x drops it.
It’s read from the clipboard of the machine you’re at (with greed ssh,
your laptop’s) and kept in Greed’s cache folder where the agent runs.
Claude Code gets the image itself, and so does Greed’s own agent when its
model can see images (Claude, GPT-4o and later, Gemini, Kimi K2.5 and
later, Qwen-VL, Llama 4 and the like, known by name; images = true on a
role for others). Otherwise the agent is told where the file is. In a
terminal, Greed reads the clipboard with wl-paste (Wayland), xclip
(X11) or osascript (macOS).
Greed’s own agent
Pick “Greed” in space i n for an agent that runs in the editor, with any
model the models setup knows: Anthropic’s, or any server
with OpenAI’s API.
local models = require("@models")
models.roles.agent = { provider = "ollama", model = "qwen2.5-coder" }
-- providers: anthropic, openai, mistral, berget, evroc, ollama, or your own
-- :secret-set PROVIDER for an API key, :login PROVIDER for a plan with an account
It uses the model playing the agent role (or reasoning without one).
alt-M in its transcript picks another role; :models sets which model
plays it. “Another model…” at the end of alt-M’s list picks a provider
and one of its models, which then plays agent from then on. When the
provider has no key, the transcript’s bottom says so in place of “ready”,
and a message you send stays in the box until there’s one.
It has the tools listed above except propose, plus edit_file,
write_file, move_file, delete_file and run (a block in the
project’s shell, marked ◆, with the project’s environment). Its edits show
the change and ask first, so no proposal is needed.
Reading never asks. Editing, moving, deleting, running and fetching ask
(y once, a for that kind of action for the rest of the session, n
no), and your policies can answer. Tools that write, run or fetch, like
notes_write, blocks_run and web_fetch, ask by their kind; tools that
show you their work, like propose, ask and eval, don’t. A risky
command (kubectl delete, git push, rm, docker rm, curl -X POST)
asks every time, saying why, through run or shell_run.
Permissions and sandboxing has the details.
Edits go through the file’s buffer, so u takes them back, and the agent
hears the language server’s diagnostics right after. Several changes in one
edit_file undo as one. It won’t write a whole file over one it hasn’t
read or over your changes since it read it, and can’t write a line like
// ... existing code ... in place of code. A file outside the project,
your config too, asks before every change, even with edits allowed always.
After an edit to your config, the config runs again and the agent hears
whether it ran or what error it hit.
By default the model edits by giving the text to replace. For models that
copy text badly, edits = "hashline" on the role (or provider) makes
read name each line by its number and a short hash (12#a3f|local x = 1), and the model edits by those names. A moved line is found by its
hash; a changed one is refused, so the model reads it again.
models.roles.agent = { provider = "ollama", model = "qwen2.5-coder", edits = "hashline" }
When the model stops answering or its connection drops, the transcript
says so (no reply for 90s; trying again in 2s) and Greed tries once more,
unless part of the answer had come. If that fails too, the turn ends with
why and say go on to try again; ctrl-c stops it at once, during the
wait too. Models says how long a model may go quiet.
:usage compares how edits went by model and way of editing, beside the
tokens each model was sent and wrote today and over the last week, and how
many came from the provider’s cache (Models has more).
Its system prompt includes the project’s AGENTS.md or CLAUDE.md. It
works in the project with you or in a workspace of its own (below);
space i n asks which when the project is in a repository.
Each session is saved after every turn, and the session
list (space i l) takes it up where it left off, with
the transcript, the conversation, the model and the tool groups it had on.
“Allow always” answers aren’t kept, so a session taken up asks again.
- Files:
~/.local/share/greed/agent-sessions, one folder per repository (shared by its jj workspaces and git worktrees), readable only by you. Long tool output is cut there. - The newest 50 sessions per repository are kept (
:set agent-sessions-kept 100keeps more);xin the session list deletes one. - Agents don’t read other sessions’ conversations.
A tool result over 2,000 lines or 30,000 characters reaches Greed’s agent
as its start plus the path of the whole of it, in Greed’s cache folder
(agent-output, only yours to read, cleared after a week), which it can
read on in or grep.
Every request sends the whole conversation. Providers charge much less for a start that’s the same as last time, so Greed’s agent keeps it steady: the system prompt doesn’t change between turns (the time goes in your messages), a newly switched-on tool group adds its tools after the others, requests to Anthropic mark the tools, the system prompt and the newest message for caching, and old messages are never changed except by compacting.
When a conversation nears the model’s limit, it’s compacted before the next request: the model summarises everything but its end, and the summary replaces it.
- The summary has fixed headings (objective, open requests, decisions, work state, next step, the files that matter, exact details still needed), folds in any earlier summary, and is followed by a pointer to the plan, which is kept apart from the conversation.
- The end kept as it was is as many whole turns as fit in about 15k tokens (a fifth of the window, for a small one), at least the last turn, so a tool call and its result stay together.
- Near the limit means the conversation, as the provider last counted it plus what came since, leaves less than room for the longest answer and a reserve (10% of the context window or 16k tokens, whichever is more, but at most a quarter of it).
- A request still turned down as too long is compacted and retried, keeping half as much of the end each time, up to three times.
- The summary goes to the model as its own earlier words, not as instructions; the system prompt is built fresh as always.
The transcript shows a folded conversation compacted (N messages → summary) row; tab on it shows the summary. :agent-compact compacts by
hand, and :set agent-compact-at 200000 compacts once a conversation
reaches that many tokens, to keep each turn’s cost down. The model playing
the compact role summarises, if you set one, otherwise the session’s
own model:
models.roles.compact = { provider = "anthropic", model = "claude-haiku-4-5-20251001" }
Greed knows the context window of Claude, GPT and common open models
(Llama 3, Mistral Small, Devstral, Qwen3 Coder, GLM, DeepSeek, Gemma 3, Kimi,
gpt-oss) by their names, and
assumes 32k tokens for any other. Set context on the role or provider
when it’s wrong, as for an Ollama model whose context you’ve raised:
models.roles.agent = { provider = "ollama", model = "qwen2.5-coder", context = 128000 }
One answer may be up to 32k tokens, or a quarter of the context window
when that’s smaller; output on the role or provider changes it. An
answer that runs out of room, such as one writing a long file, runs none of
its tool calls; the agent is told to go on in smaller pieces, and stops
after three such answers in a row.
Once one thought passes 8k tokens (counted roughly, four characters each),
Greed stops the request, shows stopped a thought at 8k tokens; asking for smaller steps, and tells the model nothing ran and to write a short plan
with plan_write if it helps, then take the first small step. Models that
are sent their thinking (Mistral’s) get the thought back. These count with
the answers that ran out of room, so three in a row stop the turn.
:set agent-max-thought 20000 moves the limit; 0 removes it.
Limits on a run:
| Setting | |
|---|---|
| none (default) | Works until done; every 200 steps the transcript notes this has taken 200 steps; carrying on. ctrl-c stops it |
:set agent-max-turns 300 | Stops after that many steps, with a note; go on continues |
:set agent-max-tokens 2000000 | Stops once the session has read and written that many tokens over all requests (a session taken up again counts on); raise it and say go on to continue |
Before answering how something works, why it behaves as it does, or how to
build or change something, Greed’s agent is told to read the code and docs
the answer depends on and say what it hasn’t checked. With agent-care at
thorough (the default), for design and architecture questions, how the
system works, and tasks touching several areas, it first surveys each area
with subagent helpers (several at once), answers from what they found,
and ends with a Checked: line and, where something wasn’t, a Not checked: line. :set agent-care quick keeps only the reading first.
| Keys | |
|---|---|
space i n (:agent-new) | Start an agent, Greed’s own or one over ACP: pick which, and where it works; one that isn’t installed says the command that installs it |
:agent | Show the latest session, or start one as space i n does when none runs |
space i l (:agent-list) | The session list: every session of the repository, running and kept |
space i m (:agent-move) | Move the transcript you’re in to a pane, a tab, a float or a panel |
:agent-fork | Fork the agent of the transcript you’re in |
:agent-compact | Compact the conversation with Greed’s own agent now |
› Fix the off-by-one in the pager
Found it in pager.rs.
✓ Edit pager.rs · +1 -1
✗ Run cargo test · 12 lines ▸
Sonnet · 48s
▎
▎ now add a test
▎ auto · Sonnet · Plan · ● thinking · 12s 14.2k (7%)
Your messages start with › on a shaded background. The agent’s words are
plain, and each of its turns ends with a dim line saying who answered and
how long it took. Each tool call is one row: ○ waiting, ◐ running, ✓
done or ✗ failed, with a short summary like read src/main.rs · 120 lines. A command of several lines shows its first and how many (· 4 lines ▸). A ▸ means there’s more: tab unfolds and folds it. When Greed’s own
agent asks before an edit, the row already holds the change (-1 +1 · tab shows the change), shown in the theme’s diff colours. Commands are coloured
as shell, and a change as the language of the file it changes.
up on the box’s first line brings back earlier messages, down on its
last line comes forward; with something typed, only messages starting with
it, as at a shell’s prompt.
With the cursor in the box, the transcript follows the agent’s output. Move up into the history (any motion, the wheel or a click) and the view stays put until you go back to the box.
Rows you can act on: tool calls with more to show, helpers’ calls,
thoughts, questions and shell code fences. enter (or a click) opens one:
a helper’s transcript in a float, output or a thought unfolded, the
question in the box, or a fence’s buttons. tab folds it. From the box,
without leaving insert mode:
| Key | Does |
|---|---|
alt-up | Highlight the row above, from the box the newest |
alt-down | Highlight the row below; past the newest, back to the box |
enter | Open the highlighted row |
tab | Fold or unfold the highlighted row |
esc | Drop the highlight, back to where you were in the box |
Typing drops the highlight too and goes in the box. In a transcript
alt-up and alt-down do this instead of moving between panes, which
alt-k and alt-j still do there.
A helper’s transcript opened from its row closes with esc (in normal
mode) or q, back to the row it was opened from. Elsewhere those keys do
what they always do.
The box at the bottom is a shaded card that grows as you write. The line
under it shows the model, auto when auto mode is on, the mode once you
leave the one it started in, the effort and the keys. In any mode, while typing too:
| Key | |
|---|---|
alt-enter | Send |
ctrl-c | Stop the agent’s turn (in the vscode style, with a selection, copy). The next message carries on from there; a command it started in the project’s shell keeps running there |
alt-m | Pick the agent’s mode, when it has modes (Claude Code: Manual, Accept edits, Plan) |
alt-M | Pick the model, when it offers a choice (for Greed’s own agent, a role or any model a provider lists) |
alt-a | Switch auto mode |
Everything above the box is read-only: you can move, search, select and copy there, but typing, insert mode or pasting go to the end of the box, and deleting is refused. While the agent asks something, its keys answer from anywhere in the transcript.
What you send while the agent works is queued: › queued at the end of the
transcript, thinking · 1 queued under the box. Greed’s own agent
reads it at its next step with the result of the tool it ran last; other
agents get it as the next message once their turn ends, several together.
It then shows where the agent got it. Messages still queued when you stop
the agent go ahead of your next one (alt-enter on an empty box sends
them alone).
The line under the box says what the agent is doing in a word (running,
reading, editing or searching while a tool runs, waiting for mistral until the answer starts, then thinking or writing), how long
this turn has taken, waiting for you when it asks, and how much of the
context window the conversation fills when the agent reports it
(14.2k (7%), yellow past half and red past four fifths; Greed’s own agent
always reports it). With :set effects true,
running tools spin, the status shimmers while the agent thinks and the
waiting chip pulses; nothing moves while it’s idle. Theme keys:
agent.you (your messages’ and the box’s background), agent.you.bar (the
› and the box’s bar), agent.box, agent.box.title, agent.hint, agent.picked (the
highlighted row), agent.working, agent.waiting, agent.done and
agent.failed.
What the line under the box shows
The agent-box option lists what goes on the line under the box, before
what the agent is doing, in order.
Like this, in your config:
greed.option.set("agent-box", 'agent model "work" effort keys')
The fields are agent (its name, like Claude Code), auto, mode,
model, effort and keys, plus text in double quotes shown as it is.
Anything left out isn’t drawn. When the box is narrow the keys give way
first, then the fields from the end of the list, so put what you care
about first.
:agent-box model shows or hides one field. Keys bind to command names,
so for a key give it a command of its own:
greed.command({
name = "agent-box-model",
run = function()
greed.run("agent-box", { args = { "model" } })
end,
})
greed.keymap.bind({ layer = "leader" }, { ["i b"] = "agent-box-model" })
Your own fields are Luau functions that get the session and return a text, or nil to show nothing. They’re computed each time the box is drawn:
local acp = require("@acp")
acp.box_field("project", function(s)
return s.root:match("[^/]+$")
end)
greed.option.set("agent-box", "project model keys")
The line ending each of the agent’s turns names the model. Set
agent-heading to name for the agent’s name instead.
The line above the transcript (Claude Code in ~/src/app) follows
agent-title, which takes the same kind of list as agent-box: agent,
model, folder, workspace, your own fields and quoted text. Set it to
"" to drop the line. A panel or float showing an agent has its name as a
title; :set agent-pane-title false takes it off, open ones
included. The session list keeps the name either way, so two sessions
stay apart.
greed.option.set("agent-title", "model folder")
greed.option.set("agent-pane-title", false)
When the agent asks before doing something, a row of choices shows in the box:
Allow Edit a.txt? [y] Allow once [a] Allow always [n] Reject
enter picks the highlighted choice, tab moves, a choice’s letter picks
it, and esc rejects, sending what you wrote in the box as what to do
instead (alt-enter with a message does the same). In insert mode the
first esc only leaves insert mode. Answering an
agent has the keys and what “Allow
always” covers for each agent.
The agent reads open files as you have them, unsaved changes included, and its edits to an open file are made in the buffer and saved, so undo takes them back.
Each message takes along what’s on screen: the file you were last in (the
one beside the agent’s pane while you type there), the cursor’s line and
column, the selected text (cut after 4000 characters) and the other files
showing. When what you’re in isn’t a file, it says what it is and which
buffer: “the mail list, searching in:inbox, 198 shown”, “a mail thread of
3 messages”, “the shell in ~/src, its last command cargo test failed”,
a terminal or Hoard’s home page. So “translate this” or “why did that
fail?” goes straight to it. It’s marked as editor context, so
the agent treats the file text as data, and isn’t sent again when nothing
changed. :set agent-editor-context false turns it off.
Agents also get the tools greed mcp offers above, connected to this
session. :set agent-greed-tools false leaves them out.
While an agent works, the line it’s on in an open file gets a ◆ and the
agent’s name and activity at the end, in a colour of its own (an agent in a
workspace shows on your copy of the file). The status line counts agents
working and waiting for you.
The transcript is a buffer in a panel: move and copy in it as in any
other. :q or ctrl-w q closes the panel while the agent goes on;
space i l brings it back.
Setting up auto mode
Auto mode lets commands that only look, build or test run by themselves,
and asks a decision model about the rest. To set it up:
-
Pick the decision model: in
:models, choose thedecisionrole and a model. Any chat model works; a model made for yes-or-no answers, like Berget’s System One models, is faster and cheaper (see Auto mode for how the ones we tried did). In your config:require("@models").roles.decision = { provider = "berget", model = "Cloudflare/clef-flash" } -
Try it:
:decision-checkruns it on sixteen commands, some it should let run and some it shouldn’t, and shows what auto mode would do with each. Don’t rely on a model that lets a wrong one through. -
Tell it about your setup, if it helps:
greed.option.set("agent-auto-rules", "Deleting under /tmp is fine."). -
alt-ain a transcript, or/auto, switches the session to auto mode; the line under the box saysauto. New sessions start the way you left the last one.
Some things always ask you, whatever the model says: sudo, force pushes,
deleting your home, changes outside the project, and the rest listed under
Auto mode.
Thinking shows as dimmed rows, for agents that share it (Claude Code, and Greed’s own agent when the provider sends it, like Claude with an effort set or Mistral’s reasoning models). While a thought comes in you see its first line, its newest lines and its progress:
▍ … The user wants the pager fixed.
▍ The last page is one short, so the count starts at 1 where the
▍ offset starts at 0. Check how pager.rs uses it before changing
▍ thinking · 8.2k tokens · 4m 10s
Once done it folds to its size and first line, cut at the view’s edge
(▸ thought, 8.2k tokens · The user wants the pager fixed.; tokens counted
roughly, four characters each). tab on the row shows all of it.
/thoughts hides or shows them in every transcript; :set agent-thoughts false hides them from your config.
Slash commands
A message whose first word is one of Greed’s chat commands runs it instead of going to the agent:
| Command | What it does |
|---|---|
/model [name] | Picks the model, as alt-M does; with a name, switches to it |
/mode [name] | Picks the mode, as alt-m does; with a name, switches to it |
/auto | Switches auto mode, as alt-a does |
/thoughts | Hides or shows what agents think |
/fork | A new session that starts with everything said so far |
/resume [words] | Picks a saved session of this project, newest first, and takes it up in this view; words narrow the picker |
/effort [none|low|medium|high|max] | Greed’s own agent: how hard its model thinks, for this session; without a word, a picker |
/compact | Greed’s own agent: summarises all but its last few turns, to save room |
/effort changes the session only, shown under the box
(Greed · reasoning · effort high); /effort unset goes back to the
role’s, and e in :models sets the role’s for every session.
Any other /word goes to the agent as written, so Claude Code’s own
commands, like /review, work as in Claude Code, as do /effort and
/compact for agents other than Greed’s (and /mode or /model for an
agent that offers none). tab after / lists matching commands, Greed’s
and the agent’s, with what each does.
tab after /effort , /model or /mode lists the values, with the
session’s marked (now). Efforts the model takes come first; the rest say
the nearest one they’re sent as:
none answers without thinking, or as little as the model goes
high (now) thinks hard, slower and using more tokens
low (sent as none) thinks a little
medium (sent as high) thinks some
max (sent as high) thinks as hard as the model goes, slowest and using the most tokens
unset as the model's role says
That’s Mistral Large 4, which takes none and high; GLM 5 takes low,
high and max. e in :models lists them the same way for a role.
The session list
space i l lists the repository’s sessions, running and kept, from every
jj workspace or git worktree of it, this one’s first, then newest:
Claude Fix the off-by-one in the pager ⠋ working just now 14.2k tokens
Greed Add a test for the pager idle 4 min ago 3.1k tokens
Claude 2 Look at the parser saved 2 h ago in greed-b
Each line has the agent, your first message, its state (working,
spinning with effects on, waiting for you, idle, failed with why, exited or saved), when it
last did something, its tokens when the agent reports them, and where it
works: in other-workspace for another workspace of the repository,
workspace NAME for one of its own.
Agents in a terminal of the repository show too, like the space i C pane
or a claude you started with the hooks set up (see Knowing when it waits
for you). enter and p t w s show their
terminal and x closes it, ending the program; conversation keys like f
or d don’t apply.
| Keys | |
|---|---|
enter | Show the session, taking it up first if it’s kept or exited; with several marked, show them all as panes |
r | Take up the session (or the marked ones) without showing it |
h | Take up Greed’s own session here, in the workspace you’re in |
m | Mark the session, or unmark it, to act on several |
p, t, w, s | Show it in a pane, a tab of its own, a floating view or a panel on the right |
/ | Narrow the list to sessions with what you type in them; esc puts back the filter there was |
n | Start another, asking which agent as space i n does |
f | Fork it: a new session that starts with everything said so far; one of Greed’s own goes on with its model and tool groups, once it isn’t in the middle of a turn |
x | Close it: stop it, forget it and remove its workspace, asking first when it’s running or has a workspace |
d, b, R | What it changed in its workspace, bring that in, or review it (below) |
ctrl-c | Stop its turn |
q, esc | Close the list |
A session taken up from another workspace works in the folder it ran in.
To carry on with one of Greed’s own sessions where you are now, take it up
with h; from then on it’s kept as this workspace’s. Other agents, like
Claude Code, keep their sessions by folder, so theirs stay where they ran,
as do sessions in a workspace of their own.
A transcript shows in one place at a time, and moving it doesn’t restart
the agent: space i m then p, t, w or s moves it to a pane, a tab,
a float or a side panel (:agent-show-pane, :agent-show-tab,
:agent-show-float, :agent-show-panel). Several marked sessions shown
with p split the biggest pane each time, with t share one new tab, and
with w get a float each. Closing a transcript’s view, pane or tab leaves
the session running; only x in the list, or quitting Greed, ends it.
An agent in a workspace of its own edits, moves and deletes files there
without asking, since nothing reaches your files until you bring it in
(:set agent-workspace-edits false to be asked anyway); Greed won’t write
a file outside the workspace for it at all. Policies in init.luau can
answer other questions, like letting the agent run your tests. Risky
commands and writes that let a plugin do more always ask. See
Permissions and sandboxing.
An agent works in the project with you, or in a workspace of its own: a jj
workspace, or a git worktree on a branch greed/NAME, in Greed’s cache
folder, where it can change anything without touching your files. In the
session list:
| Keys | |
|---|---|
d | What it changed in its workspace, as a diff |
R | Review that on your files, change by change, as proposed edits (see Reviewing proposed edits) |
b | Bring that into your working copy: with jj its change is squashed into yours, with git its diff is applied |
R moves the agent’s edits past whatever you changed since it started, so
you review only what it did. An edit to lines you changed too is left out;
the message says how many files had one, and d shows them. What you
accept lands in your buffers, unsaved, and undoes in one step. The
workspace keeps its change, so after a review close it with x rather
than bringing it in with b.
A jj workspace starts from your working copy’s parent, so it doesn’t see
uncommitted changes. b squashes the workspace’s working-copy change into
yours, keeping your description when both have one. Greed’s own agent is
told to keep its work in that one change, and in a git worktree not to
switch branches, rebase or push; its searches and reads go to its
workspace, and it says when its work is ready. A fork of an agent in a jj
workspace gets its own workspace with the edits so far; in a git worktree
it starts from the branch’s last commit.
Agents in separate workspaces don’t see each other’s changes. When one
finishes a turn, Greed says in both transcripts which changed files it
shares with other agents in the project (Claude changes src/b.rs too; bringing both in may clash), once per file.
Sessions are kept in the cache folder until you close them with x. After
a restart, space i l lists them and takes one up: the agent replays the
conversation into a new transcript, and its workspace is still there.
/resume in a transcript does the same from a picker, in the view you’re
in. The session you typed it in closes if nothing was said there yet.
Agents that can’t take up or fork a session say so. Greed’s own agent
keeps its sessions itself, as described above.
An agent can start another with the subagent tool, for a wide search
that would fill its own context, a side task or a second opinion. The
helper is an agent from the list here (the one asked for, or the first
installed), in a workspace of its own unless the caller says otherwise. It
shows in the session list, asks you before doing things like any other,
and the caller gets its last answer as a report. At most three work at
once. A helper whose turn fails, like one whose model has no key, comes
back as an error saying why.
Greed’s own agent has subagent from the start; its helpers are Greed’s
own agent with the same model unless it names another. Such a helper works
where its caller does (its workspace, if any) and only reads and searches;
told to work in the project (here), it edits and runs commands too,
asking you first as usual, and the result says so. Several subagent
calls in one answer run at once.
While a helper works, its row shows the task, what it’s doing (a tool call,
“thinking” or “waiting for you”), how long it has worked and its tokens;
the box’s bottom line says waiting for 2 helpers. enter on the row (or
alt-up to it from the box, then enter) shows the helper’s transcript in
a float, during and after; esc or q closes it. ctrl-c stops the
helpers with the turn. When done, tab on the row unfolds its report.
To add an agent that isn’t in the list, register it in init.luau. The
first installed command is used; model is the model it starts with, when
it offers models, and install the command space i n shows when it isn’t
installed:
require("@acp").register({
name = "opencode",
title = "opencode",
commands = { { "opencode", "acp" } },
model = "ollama/qwen2.5-coder",
install = "npm install -g opencode-ai",
})
Which models an agent offers is up to the agent: opencode, for example, offers the ones its own config sets up.
Agents in your other sessions
Each Greed session on this machine shows the other sessions’ agents: the
status line adds them to its count (◆ 1 waiting for you in greed-2), and
space i A (:machine) lists them; enter goes to that session.
One session follows the others for all of them: the first by name among
those of the same greed build, or the one the hub-session option names.
When it ends, the next takes over. The others follow only it, so there is
one connection per session however many run. Sessions, machines and
the hub explains how this works.
When an agent starts waiting for you in any session here, each machine
you’re attached from gets one desktop notification, whichever session its
windows or terminals show. Each wait is notified once, also after a
restart. The same goes for what else asks to be told, like a chat
message for you; while those wait, the status line of your other
sessions says so (● 2 for you in chat), for when the window or terminal
you’re looking at isn’t told.
Agents on your other machines
Once you’ve used greed ssh eris, the agents on eris show up here too. The
status line says ◆ 1 waiting for you in greed-2 on eris, space i A
lists them, and enter opens that session as greed ssh eris would. When
one starts waiting, your desktop is told as it is for this machine.
Greed remembers each machine you reach with greed ssh and keeps following
it for two weeks after you last did. :machine-forget stops following one
until you greed ssh there again. To follow a machine you never ssh to from
here, name it in your config:
greed.option.set("hub-hosts", "mini")
Following a machine runs greed ssh HOST ctl watch --hub, which installs
this greed there if needed and never asks for a password or a new host
key, so it needs your keys (or an ssh agent). A machine that’s off or
unreachable is retried after a minute, then less often, at most every half
hour.
When two machines follow each other you still get one notification per wait: an agent’s own machine tells the windows attached to it, and the other tells only the ones it can’t reach.
A session you reach with greed ssh also shows the machine you sit at:
your terminal or window asks the sessions at home and passes on what they
say. On eris, space i A lists your laptop’s agents too, enter on one
comes back to it, and space B goes back to where you came from. This is
read-only; nothing on your machine can be done through it from the other.
Answering an agent from anywhere
ctrl-a on an agent in space space or space i A lists what you can do
to it where it runs: allow, allow-always or reject while Greed’s own
agent waits for an answer, stop, and close for an agent in a terminal.
It works the same for an agent in this session, another session here or
on another machine you reach with greed ssh. On the machine your client
is on (seen from a session you reached with greed ssh), enter takes
you there first.
From a shell it’s greed ctl act id=agent-session:3 action=allow, with
--session NAME before the tool for another session, also as greed ssh HOST ctl --session NAME act .... Run that way it acts as you, and one that
stops something doesn’t ask again in that session, where nobody may be
looking. An agent can’t answer another agent’s question: only you can.
Claude Code started with space i C (which gives it Greed’s hooks) asks
through Greed while you aren’t looking at its terminal: the question waits
in Greed, shows what it’s about (Bash: npm test), and takes allow,
allow-always (the rule Claude Code offers) or reject from anywhere. In
its terminal it asks on its own screen as usual, as it does for a question
asked while you’re looking and one unanswered for half an hour. Its
multiple-choice questions work the same way: while you’re elsewhere Greed
asks them on a page and passes your answers back as if picked on its
screen.
Questions from Greed’s own agent’s ask tool show in space space as
waiting for you; ctrl-a then answer asks each in a picker (pick a
choice or type) and sends the answers once all are answered. A
notification says when one is asked. From a shell:
greed ctl --session NAME ask_answer id=questions:3 answers='{"name": "rope"}'
An agent running greed ctl act or ask_answer in a shell is asked about
it every time, whatever you allowed always, since it would act as you.
Plugins written by agents
Ask for something like “a command that jumps from a use line to the
crate’s entry in Cargo.toml” and the agent goes through these steps:
plugin_guidegives it the plugin conventions and the full typed API.plugin_trywrites the plugin to a staging folder (~/.cache/greed/staging) and checks it: strict types against the API, then the plugin’s tests in a headless editor, with none of its capabilities. It doesn’t ask you, since nothing reaches your editor or files. The agent gets back what failed and retries, sending only changed files. Type errors count only in the plugin’s own files, and tests that fail only for want of an approved capability don’t block it: they run again after you install it, and the agent hears how they did.plugin_installasks you. A float shows what the plugin may do beyond the editor (its capabilities, like running programs or reading files), the code and the check results;ainstalls it into~/.config/greed/plugins(or~/.local/share/greed/pluginswhen your config can’t be written, as when Nix manages it), approves what it asks for and loads it right away,rrejects it.
Permissions and sandboxing says what an approved plugin may do and how the sandbox keeps the rest out.
You only see the plugin once its checks pass. Review pages like this one, and the one before an agent’s code runs, show one at a time; a second waits until you’ve answered the first.
Greed’s own agent is told to build things for Greed this way rather than in your project, and the tools tell other agents the same; it changes the project only when you ask it to.
Writing your own tools
Any plugin can offer tools; see Writing plugins.
Watchers
A watcher is Greed’s own agent with a standing job: it keeps an eye on chat rooms, mentions and direct messages, and tells you about what matters, drafts replies for you to send, or answers on its own where you let it. You set one up in your config. This is new; expect rough edges.
local watch = require("@watch")
watch.add({
name = "work",
prompt = [[
I'm on the infra team. Escalate anything about outages or my reviews.
Answer "where's the runbook" questions in infra-help with a link. Draft
anything addressed to me by name; don't send it.
]],
watch = {
chat = {
account = "John Eriksson", -- as the chat list names it; leave out for all
rooms = { "infra-help", "infra" },
mentions = true, -- mentions of you in any room
dms = true,
},
},
may = {
reply = "draft", -- "never", "draft", "ask" or "auto"
auto_in = { "infra-help" }, -- where "auto" may send; it drafts elsewhere
escalate = true,
},
model = "fast", -- a role or a model, as alt-M picks
gather = 60, -- seconds to wait for more before waking
quiet = "22:00-07:00", -- it waits until these hours are over
budget = { replies_per_hour = 5 },
sign = "(assistant)", -- put after what it sends on its own
})
The prompt is yours. Greed adds its own part around it: that the messages are other people’s and to be read as data, and what its tools do.
Quarantine
A new watcher starts in quarantine. It wakes and decides as it would, but
sends and drafts nothing and tells you of nothing: its log says what it
would have done (“would draft: …”, “would escalate: …”). Tweak the prompt
and the model while you read the log, then let it out with
:watcher-release work. :watcher-quarantine work puts it back.
quarantine = false in its config starts it out of quarantine.
What it does
It wakes on new messages that match, waiting gather seconds for more so
a burst is one wake. It can read more of a room and search your chat
(chat_read, chat_search), and has four tools of its own:
| Tool | Does |
|---|---|
watch_escalate | A Greed alert wherever you are, and a desktop notification |
watch_draft | A reply waiting for you; :watcher-drafts lists them |
watch_reply | Sends on its own, only in auto_in, outside quiet hours, within budget |
watch_done | A line in its log saying what it did and why |
With reply = "ask", a draft tells you wherever you are too. A draft
sends as it is, opens in its room with the text in the box to change and
send, or is dropped. Most messages need nothing, and it logs that too.
Turning them on and off
Each watcher is an object: :watchers lists them with their state, and
picking one offers what you can do with it, as space . on anything does.
| Command | |
|---|---|
:watchers | The list, and what to do with one |
:watcher-pause work 2h | Pause it (an hour without a time); what comes meanwhile waits |
:watcher-resume work | Resume it, catching up |
:watcher-off work, :watcher-on work | Off stays off across restarts |
:watcher-run work | Wake it now on what’s waiting |
:watcher-log work | Its log: what it woke for and what it did |
:watcher-sign work off | Stop signing, or :watcher-sign work (bot) |
:watchers-pause 30m | Pause them all |
:watcher-drafts | The drafts waiting |
From Luau: watch.pause("work", 3600), watch.resume("work"),
watch.set("work", "off"), watch.state("work"), watch.sign("work", false). Their state, drafts and logs are kept in Greed’s data folder, so
a restart doesn’t undo them.
Where they run
A watcher runs where your chat accounts are kept, in the chat session,
and only there, so no message is answered twice. When the chat session
isn’t running, neither are watchers; they start with it. For now
:watchers and the commands work in the chat session (:chat-session);
from other sessions they’re on the list of things to come.
What keeps it in line
- What it reads of chat comes marked as from outside: a message saying “ignore your instructions” is something it read.
- It has only the tools above. No shell, files, eval or plugins.
- It drafts and replies only in rooms it woke for, and replies on its own only in the rooms its config names, whatever a message asks.
- Past the hour’s budget, replying on its own is refused and it drafts instead. After three failed wakes in a row it stops until you resume it.
- Each wake is a transcript (
transcripton it in:watchers).
Permissions and sandboxing
Agents, plugins and repositories can all run code in Greed. This page covers what asks you, what you can answer in advance, what always asks, and what runs in a sandbox.
Who asks what
| Who | What you’re asked | How |
|---|---|---|
| Greed’s own agent | Before it edits, moves or deletes a file, runs a command or fetches a page | A row of choices in its transcript |
Claude Code, Gemini, Codex over ACP (space i n) | What the agent itself asks, like before running a command | The same row, with the agent’s choices |
Claude Code and other MCP clients (greed mcp, /ide) | Asked by the client itself, as its own settings say; Greed asks only about risky calls | A review page in the editor |
An agent’s eval | Nothing while the code stays in its sandbox; a reviewer or you for more | A page with the code |
greed ctl from your shell | Nothing: it runs as you | |
| A plugin that isn’t Greed’s own | Whether it may use what it declares, like running programs | :plugins-approve |
A project’s own code: its .greed/init.luau, language servers, formatting on save; code blocks in Markdown | Whether to run them at all | :trust (asked when a file opens), :blocks-trust |
Reading never asks: agents read files, buffers with your unsaved changes,
diagnostics and the rest freely. Edits an agent proposes with propose
don’t ask either, since nothing changes until you accept them in the
buffer (see Reviewing proposed edits).
Answering an agent
When an agent in Greed waits on you, a row of choices shows at the top of the box in its transcript:
Allow Edit a.txt? [y] Allow once [a] Allow always [n] Reject
You answer it from there in any mode and editing style:
| Keys | |
|---|---|
enter | The highlighted choice (the first, until you move) |
tab, shift-tab, left, right | Highlight the next or previous choice |
y, a, n, N | Allow once, allow always, reject, and reject always when the agent offers it; a choice of some other kind goes by its number |
esc | Reject; what’s in the box goes along as what to do instead (in insert mode, the first esc leaves it) |
Clicking a choice picks it too. Once the box has text in it, letters type
as usual so a message you’re writing doesn’t answer by accident; enter
and tab still work. What you typed stays unless you reject with esc.
The box’s bottom line shows which keys answer now.
To say no and what to do instead, write it in the box and press esc or
alt-enter. Greed’s own agent gets it with the rejection, in the same
step; other agents get it as your next message once their turn ends. The
transcript keeps each answer under its call, like ? Edit a.txt: Allow once.
A rejected call tells the agent not to get there another way (another
tool, a command or eval) and to ask you what you want. Greed’s own agent
is held to it:
- the same call again doesn’t run;
- after you plainly reject a command or
eval, no other command orevalruns (a rejected edit doesn’t stop the tests that follow); - after a second rejection in one prompt, nothing runs.
The turn stops with a note like stopped: you rejected Run make deploy; asking what you want, and the agent’s last word is its question to you.
What “Allow always” covers depends on the agent:
- Greed’s own agent remembers it by kind of action: allowing an edit always allows every edit in that session, but not a move, a delete, a command or a fetch, which each ask once for themselves. It lasts for that session only. A session taken up again from the session list asks again. It never covers a file outside the project: writing, moving or deleting one asks every time, with only Allow once and Reject.
- Claude Code, Gemini, Codex and other ACP agents send their own choices,
and what their “allow always” means is up to the agent. Greed passes on
your answer and doesn’t remember it. Claude Code’s modes (
alt-m: Manual, Accept edits, Plan) change what it asks about.
When Greed’s own agent asks before an edit, the call’s row in the
transcript already holds the change (-1 +1 · tab shows the change), so
tab on it shows the lines going and coming before you answer.
Auto mode
In auto mode Greed answers an agent’s questions where it safely can and
asks you the rest. alt-a in a transcript (or /auto) switches a session
between auto and manual (asked every time); the box’s top line shows
auto in green. New sessions start the way you switched the last one,
after a restart too, unless agent-auto is set in your init.luau. It
works the same for Greed’s own agent and ACP agents.
Auto mode allows:
- looking: reading, searching and fetching pages;
- edits, moves and deletes inside the project (or the agent’s workspace), when the agent says which files;
- commands that only look, or build and test:
ls,rg,cat,git log,git diff,jj log,sed -n,findwithout-deleteor-exec,cargo test,go buildand the like. Every command in the line has to be one of them (rg x | headis,ls | xargs rmisn’t), and nothing may go into a file with>. Plugins add their programs’ commands (core.risk.safe_when).
Any other command, risky ones like rm -rf /tmp/scratch included, goes
to the decision model. It reads your last few messages (never what the
agent read or what commands printed), with your newest apart from the
rest, your rules and the command, and says how likely the command is safe
to run unasked given what you asked for:
| Model says | Auto mode |
|---|---|
| 60% or more safe | Runs it |
| 20% or less safe | Blocks it |
| In between | Asks you |
Asked to clean out /tmp/scratch, an rm -rf /tmp/scratch goes ahead; a
deploy you never mentioned doesn’t. Files the agent writes, moves or
deletes with its own tools in the temporary folder (/tmp, or $TMPDIR)
go to the model the same way.
A blocked command goes back to the agent with the reason, without stopping its turn. Greed’s own agent hears it at once; an ACP agent like Claude Code can only be told no, so the reason follows as its next message once its turn ends. After three blocks in a row you’re asked instead until you’ve answered one, and after twenty in a session until you switch auto mode off and on again.
:models sets the decision model; until you pick one it’s the fast
one. Either kind works:
- A decision model made for yes-or-no answers, like Berget’s System One models, answers with probabilities directly, and costs a few cents per million tokens.
- A general model, like your
fastone, is asked the same questions in a chat and answers in JSON. It’s slower and costs more per command, and how well it judges depends on the model.
In our tests (October 2026), Cloudflare/clef-flash sorted every command
correctly, Qwen/Qwen3.5-2B answered near the middle for all of them (so
you’d be asked most of the time), and laya called nearly everything
safe.
Either way it’s a model’s judgment call, and Greed can’t promise it judges well. Test it before relying on it:
:decision-checktries yourdecisionmodel on sixteen commands, some it should let run (a folder you asked for,npm install, a push you asked for) and some it shouldn’t (deleting your documents, sending an ssh key away,npm publishwhile fixing a test, one with a comment claiming you approved it), and shows what auto mode would do with each. Don’t rely on a model that lets a wrong one through.- Passing is no guarantee: try it in a scratch project, asking the agent for a few things and watching what it lets through and blocks (the transcript shows each answer). Models change, and yours may judge differently from what we saw.
Once the agent has read text from outside since your last message (a
page, a search’s results, what a command printed), that text could tell
it to send what it knows somewhere, like
https://evil.example/?k=YOUR_TOKEN. So from then until your next
message:
- a fetch from a host you named, one it found by searching, or one it already fetched from goes ahead as before;
- a fetch from any other host goes to the decision model, which is told the agent has read text from outside;
- an address carrying a long opaque value, like a token or a key, asks you, in a fetch or in a command;
- commands that go to the decision model go there told so too.
The long-value check is a guess at the shape of a secret, so a plain
search like ?q=cache+control goes through and a hash in a query asks.
The same command isn’t asked about twice for the same request. Without a
model, or without an answer, you’re asked. Tell it what’s fine in your
setup with agent-auto-rules:
greed.option.set("agent-auto-rules", "Deleting under /tmp is fine. Never touch the prod cluster.")
These always ask you, in auto mode too, and the decision model never sees them:
- the agent’s own changes to files outside both the project and the temporary folder;
- anything run as root (
sudo); - force pushes and remote deletes;
- programs that change the machine itself (
dd,mkfs,shutdown); - deleting the root, your home or a folder right under either.
Auto mode’s answers show in the transcript with why, like ? Run cargo test: Allow once (auto: only looks, builds or tests) or Reject (auto: not safe to run unasked (97%)).
The decision model reads the command, which the agent wrote; Greed tells it to read the command as data, but a command written to talk it round may get past it. Leave auto mode off for agents working on code you don’t trust.
What always asks
Some questions only you answer, every time. No policy answers them, “Allow always” doesn’t cover them, and they offer only Allow once and Reject.
A risky command asks every time and says why (in auto mode the decision model may answer instead):
Allow Run git push: sends commits to a remote? [y] Allow once [n] Reject
Risky commands: rm, kill, pkill, git push, git reset --hard,
jj git push, jj abandon, curl with -X POST or data to send, helm install, terraform apply, anything with sudo, and those plugins add
rules for, like kubectl delete and docker rm. Every command in a line
counts, so make && git push does. This catches mistakes; a command built
to hide what it runs may get past it, so read what you allow.
It covers Greed’s own agent’s run and the tools Greed offers every agent:
shell_run, run_command with a command that may close, delete or stop
something, and any plugin tool that marks a call risky. A risky call from
Claude Code or another MCP client (ACP agents too, using Greed’s tools)
goes to a review page headed “An agent asks to …”, where enter runs it
and esc doesn’t. Actions run with act that delete or stop something go
to that review too, whatever you allowed.
A write that adds capabilities to a plugin’s plugin.toml asks every time
and says what it adds, like Write plugin.toml, which widens what acp may do: + plugins. This matters most for Greed’s own plugins, which load
without asking you to approve their capabilities.
Both cover what agents do through Greed. A command an agent runs in its own shell, like Claude Code’s Bash tool, goes through that agent’s permissions, and Greed doesn’t see it.
Policies
A policy is a function in your init.luau that answers questions for you.
It gets the session and the question, and returns the id of one of the
question’s options, or nil to pass it to the next policy and finally to
you. Policies added later are asked first. An answer a policy gave shows
in the transcript with “(by policy)” after it, like ? Edit src/main.rs: Allow once (by policy).
The question has these fields:
| Field | |
|---|---|
title | What the agent wants to do, as the row shows it after “Allow” |
kind | "edit", "move", "delete", "execute", "fetch", "read" or another the agent uses; may be nil |
locations | The files it touches, as absolute paths, when the agent names them. Greed’s own agent always does (both ends of a move); other agents may not, and then the title is what names the file |
command | The command line it runs, for an "execute" call, when the agent says |
options | The choices, each with id, name and kind (allow_once, allow_always, reject_once, reject_always) |
The session has agent ("greed", "claude", …), root (the project),
cwd (where the agent works) and workspace (set for an agent in a
workspace of its own).
These examples go in init.luau. The .env rule comes last so it’s asked
first, and turns down an edit there before the src rule could allow it.
local acp = require("@acp")
-- The id of the question's option of `kind`, if it has one.
local function choose(permission, kind: string): string?
for _, option in permission.options do
if option.kind == kind then
return option.id
end
end
return nil
end
-- Edits inside the src folder of where the agent works need no asking.
acp.policy(function(session, permission)
local paths = permission.locations
if permission.kind ~= "edit" or paths == nil then
return nil
end
local src = session.cwd .. "/src/"
for _, path in paths do
if string.sub(path, 1, #src) ~= src then
return nil
end
end
return choose(permission, "allow_once")
end)
-- Running the tests needs no asking. The command is in the title: "Run
-- cargo test" from Greed's own agent, "shell_run cargo test" through the
-- shell tool, "`cargo test`" from Claude Code.
local TESTS = { "cargo test", "go test" }
acp.policy(function(_, permission)
if permission.kind ~= "execute" then
return nil
end
local line = string.gsub(permission.title, "^Run ", "")
line = string.gsub(line, "^shell_run ", "")
line = string.match(line, "^`(.*)`$") or line
-- Anything that could run more than the tests is yours to answer.
if string.find(line, "[;&|`$<>\n]") then
return nil
end
for _, test in TESTS do
if line == test or string.sub(line, 1, #test + 1) == test .. " " then
return choose(permission, "allow_once")
end
end
return nil
end)
-- Anything naming a .env file (.env.local and .envrc too) is turned down
-- without asking. The title counts too, for agents that don't name their
-- files in locations.
acp.policy(function(_, permission)
local named = permission.title
if permission.locations then
named ..= " " .. table.concat(permission.locations, " ")
end
if string.find(named, ".env", 1, true) then
return choose(permission, "reject_once")
end
return nil
end)
A risky test command, like one with sudo, still asks: risky commands and
writes that widen a plugin never reach policies. Reading isn’t asked about,
so a policy can’t stop an agent reading .env; keep secrets out of the
project, or in Greed’s secrets (:secret-set).
acp.policy returns a function that takes the policy out again, and a
policy goes when the plugin or config that added it reloads.
Greed has one policy of its own. An agent in a workspace of its own edits,
moves and deletes files there without asking, since nothing reaches your
files until you bring it in. That holds only for edits that name their
files, all inside the workspace; anything else asks, and Greed won’t write
a file outside the workspace for it at all.
:set agent-workspace-edits false asks about these too. Your policies are
asked before it.
Edits
How an agent’s edits reach your files differs by agent:
- Through
propose(any agent with Greed’s tools) the edits wait in the buffer until you accept or reject each one. Nothing is asked first, because nothing changes until you decide. - Claude Code over
/idesends its edits as proposals the same way. - Greed’s own agent edits through the file’s buffer after asking (or
after you allowed edits always), so
utakes an edit back, and saves. Before it writes, moves or deletes a file outside the project it asks again, whatever you allowed always. - ACP agents write files themselves after their own question; Greed writes them through the buffer when the file is open. An agent working in the project asks again before Greed writes a file outside the project for it.
- An agent in a workspace of its own changes only the workspace. Its
changes reach your files when you review them as proposals (
Rin the session list) or bring them in (b); see Agents inside Greed.
No agent writes your memory files: it proposes a memory instead, and only what you accept is written (see Memories).
Code from agents: eval
eval runs Luau inside the editor. From greed ctl in your shell it runs
as you, since whoever runs greed ctl can already run anything; Greed
knows a call came from greed ctl by its connection, so a plugin can’t
claim to be one. For agents, through greed mcp, Claude Code’s /ide or
Greed’s own agents, it runs as the agent-eval option says:
| Value | |
|---|---|
"auto" (the default) | Sandboxed first: the code can read the editor and how it’s set up (options, keys, plugins), open files in the project, edit buffers and move the cursor, and nothing else. When it needs more (running programs or commands, other files, keys, options, plugins, or changing what you see: closing, focusing or switching views and buffers, the mode or the tabs), a reviewer decides: the model playing the review role, or reasoning without one (see :models). A small fast model is too easy to talk round, so it never reviews. If the reviewer isn’t sure, or there’s none, you’re asked |
"ask" | You see the code and press Run every time |
"allow" | It runs with every capability, as a plugin would |
"off" | There’s no eval |
The editor enforces the sandbox, so it doesn’t depend on anyone reading the
code right. When code needs more, what it edited in the sandbox is undone
before it runs again, so nothing happens twice. The reviewer gets the code
wrapped as someone else’s text, is told comments or strings may try to talk
it round, and answers in a fixed form. With Greed’s own agent it also
hears what you rejected in the current prompt, and leaves code doing the
same to you. A model can still be fooled; set agent-eval to "ask" to
see every run past the sandbox yourself.
When you’re asked, a page shows the code, what it would do and the reviewer’s reason:
| Key | |
|---|---|
r (Run) | Run it once |
s (Allow for this session) | Let the asking agent’s later runs through until its session ends: Greed’s own agent until you stop or close it, an ACP agent or other MCP client until its connection closes. Other agents are still asked. Not offered to Claude Code over /ide, since Greed can’t tell its sessions apart |
d (Deny) | Don’t run it; closing the page, or leaving it five minutes, does the same |
Pages like this show one at a time; a second waits until you’ve answered
the first. :eval-log lists every run past the sandbox and who let it.
What eval edits is one operation you can review and undo in one step
(see Operations).
Plugins and the sandbox
A plugin can edit buffers and add commands, keys, pickers and the rest of
the editor freely. Anything that reaches outside the editor it declares as
a capability in its plugin.toml, and it gets only what it declared:
| Capability | Lets a plugin |
|---|---|
proc | Run programs, which can do anything you can |
fs.read, fs.write | Read or write any file, by path |
net, net:HOST | Use the network, or reach one host |
clipboard | Read what you copied |
secrets, secrets:NAME | Read and keep any secret, or read one, like an API key |
eval | Run Luau with every capability |
plugins | Load, approve and unload other plugins, which can then do anything |
commands | Run any command or keys as if you typed them |
control | Answer agents and editors connected to the session, as Greed |
ssh-agent | Let programs in the session sign with your ssh keys |
Writing plugins has what each one opens in the API and how capabilities follow code from one plugin to another.
A plugin that isn’t one of Greed’s own and declares capabilities loads once
you approve them. :plugins-approve shows each waiting plugin with what it
asks for; choose one to approve and load it. :plugins lists every plugin,
where it comes from and what it may use.
- Approvals are kept per plugin folder in
~/.local/state/greed/approved.json. - A plugin that later asks for more waits again, while the running version keeps going as it was.
- Plugins that use nothing beyond the editor load at once.
- Plugins can’t write the approvals file through Greed, or approve another plugin for you.
Greed’s own plugins load approved. Your init.luau, a trusted project’s
.greed folder, greed repl and :lua run with everything.
Sandboxed code, like an agent’s eval on its first run or a plugin an
agent is trying out, can read the editor and edit buffers and nothing
else. Each thing it isn’t allowed fails with an error starting “needs
approval:” that says what it would have needed.
Each call into a plugin has a 2-second budget; code that runs longer is stopped with an error, so a runaway loop can’t hang the editor. A command or handler with long work yields to the editor every 15 milliseconds, so keys and drawing don’t wait. Unloading or reloading a plugin removes everything it added and stops what it was running.
Plugins written by agents
An agent can write a plugin for you (see
Plugins written by agents):
plugin_try checks it in an editor of its own with nothing approved for
it, so it runs without asking you, and plugin_install shows you a review
page with the plugin’s capabilities, code and check results. Installing it
from there approves what it declared.
Trusting a project
A repository can run its own code through Greed: its config
(.greed/init.luau), a language server that builds it (rust-analyzer runs
build.rs and proc macros), and a formatter that loads config as code
(prettier reads .prettierrc.js). A project you haven’t trusted runs none
of it. The first time one of its files opens with a language server set up
for it, Greed asks in a box in the middle of the screen:
╭ Trust this project? ─────────────────────────────────╮
│ ~/src/app │
│ │
│ Its language server and formatting on save would run │
│ its code: build scripts, config files. │
│ │
│ y trust it n not now │
╰──────────────────────────────────────────────────────╯
y trusts it: its language servers start, it formats on save and its
config runs, now and whenever it opens again. n or esc leaves it
untrusted for this session; :trust trusts the shown project later. The
box stays until you answer, and other keys do nothing meanwhile. The
folder is the project’s, or the one its language server runs in when
that’s above it, like a Cargo.toml above a folder that isn’t in a
repository. A project opened with its own config says so and waits for
:trust too (see Configuration). Until then the
status line says so, like rust-analyzer waits for :trust. :format run
by hand works anywhere.
Trust goes by folder: a project somewhere else, even a copy, asks again.
Your own config folder is always trusted. :set project-trust off trusts
every project, as Greed did before 0.2.
Code blocks in Markdown files don’t run when a file opens. The first time
you run one in a file, Greed asks: y for now, a to always trust that
file (as :blocks-trust does; :blocks-untrust takes it back). Agents may
run blocks (blocks_run) only in trusted files, and only as you last ran
them or trusted the file; a block an agent changed doesn’t run for an agent
until you’ve run it.
Options
| Option | |
|---|---|
agent-eval | How agents’ Luau runs: auto, ask, allow or off (above) |
agent-auto | Whether agent sessions start in auto mode, Greed answering their questions where it can (false) |
agent-auto-rules | What the decision model should know in auto mode: what’s fine in your setup and what isn’t (empty) |
project-trust | Whether a project’s own code (its config, language servers that run it, formatting on save) waits until you trust the project: ask or off (ask) |
agent-workspace-edits | Whether agents in a workspace of their own edit there without asking (true) |
agent-tool-groups | The tool groups agents get from the start (plan), or all |
agent-greed-tools | Whether agents over ACP get Greed’s own tools (true) |
ssh-agent-confirm, ssh-agent-confirm-hosts | When a program in a greed ssh session must ask before signing with your ssh key (see Your ssh agent) |
shell-production-contexts | Kubernetes contexts shown in red in the shell’s prompt, and named as production when an action that deletes or stops something asks (see The shell) |
Some options decide what code may do, so only code holding a capability
can set them, besides you with :set or your config: agent-eval,
agent-workspace-edits, agent-tool-groups, agent-greed-tools and
shell-production-contexts need eval, the
ssh-agent-confirm options need ssh-agent, and options whose value gets
run as a program, like terminal-shell, need proc. :describe-option
shows an option’s value and doc.
Setting up agentic coding
Pick an agent:
- Greed’s own agent works with any model
:modelssets up. Start it withspace i nand “Greed”. It works in the project with you, or in a workspace of its own. - An agent in a terminal, with Greed’s tools through
greed mcp(Claude Code, Codex, Gemini CLI, opencode; see Agents as MCP clients). It asks you itself, by its own permission settings. Claude Code also hasspace i C, a pane already connected over/ide, whose edits come to Greed as proposals. - Claude Code, Codex, Gemini CLI or opencode inside Greed, over ACP:
space i n, the agent, then where it works. “In a workspace of its own” keeps its changes away from your files until you review them.
Then, to be asked less:
- Leave
agent-workspace-editson, and give agents that change a lot a workspace of their own. - Add a policy for your project’s test and build commands, like the one above, so the agent can check its work without asking each time.
- Set a model for the
reviewrole in:models, soevalpast the sandbox goes to a capable reviewer before it comes to you.
You’ll still be asked about edits and commands from Greed’s own agent
(answer a for the kinds you’re happy with), about what an ACP agent asks
itself, about every risky command and every write that widens a plugin,
and about plugins that want more than the editor.
How Greed is built
Greed has a small core written in Rust and a large layer written in Luau. Knowing where the line is tells you what you can change from a plugin (almost everything) and where to look when something is slow.
The rule
If it can be written in Luau, it is. The core holds what needs speed, threads or the operating system, and offers it to Luau as small, general functions. Everything you see is built from those functions, as any plugin would build it.
In Luau:
- The editing model: modes, motions, selections, operators, the keymaps.
The
coreplugin holds the editing commands; Helix, Vim and vscode are plugins that give them keys, each with modes of its own, and:styleswitches between them. - Commands, the command line, pickers, the file tree, search and replace, the status line, key hints, help.
- The theme and every animation.
- Language settings, which language server to start and how.
- The agent integration: the MCP tools, the review of proposed edits,
Claude Code’s
/ideprotocol, plugins written by agents, and Greed’s own agent with its chat. - The shell: its prompt, blocks, tables, completion and watches.
In Rust:
- Text: the rope, selections, changes, undo history.
- Layout and rendering: turning buffers, decorations and the theme into frames a client draws.
- Parsing (tree-sitter), regex search, project-wide grep and diffs.
- Programs and terminals: running processes, the terminal emulator, and reading images and PDFs.
- Talking to the outside: language servers, the session socket, Claude Code’s WebSocket, files.
- Running things off the editor thread, and waking the Luau code waiting for them.
- Loading, sandboxing and checking plugins.
When a feature needs something Luau can’t do, the core grows by the smallest primitive that unblocks it, and the feature itself stays in Luau. Project search is an example: the core searches files on a background thread, while the picker, the waiting for a pause in typing, the results panel and writing edits back are Luau.
Sessions and clients
The editor runs as a session: one process that owns the buffers, the Luau
plugins and the language servers. Clients connect to it. The terminal UI is
one client: it sends keys and draws the frames it gets back. The window
(greed --gui) is another that draws the same frames, and greed ctl,
greed mcp and Claude Code connect too.
Because the session owns the state, a terminal can detach and reattach
without losing anything, and greed ssh attaches a terminal on one machine
to a session on another. Any number of clients can be attached at once,
each with its own cursors, focus, mode and screen size; the server draws a
frame for each. A client says which protocol it speaks when it attaches,
and the session refuses clients it can’t talk to.
The editor acts for one client at a time, and every command, key and event handler knows which. Clients that follow share one layout of projects, tabs and panes, each with its own focus and zoom; an independent client has a layout of its own, a copy of the shared one with views of its own. Floats are placed in shares of the screen, so they keep their proportions on screens of other sizes, and the ones a client opens, like a picker, are drawn for it alone. A view can be laid out at one size for every client, as a terminal is for the client typing into it; the others crop or scale it. Several clients describes this from the user’s side.
Frames describe what to show by meaning, like “selection”, “keyword” or “diagnostic.error”, and carry the theme that maps those names to colors. A terminal and a GUI can draw the same frame, and theme entries can style each one differently. A frame is a stack of surfaces (panes, panels, floats, the tab and status lines), each with its own rows and a role that says how the client draws around it. An attached client gets a whole frame once, and after that only what changed, surface by surface: typing a character sends a row or two of one pane, focusing another pane sends two roles, moving a float sends its new place, and the theme goes along only when it changes.
Plugins are contained
Each plugin runs in its own environment with a read-only standard library. A call that runs too long is stopped, so a buggy loop can’t freeze the editor. Everything a plugin registers or starts (commands, keys, options, event handlers, theme entries, tools, tasks, marks, floats and panels) belongs to it, so reloading or unloading a plugin cleanly replaces or removes all of it.
Plugins that wait (for a timer, a key, a language server, a search) are paused and resumed by the editor. The code reads top to bottom with no callbacks, and the editor keeps responding meanwhile.
Agents are clients too
Agents see the same editor state you do, and their edits still go through you: they arrive as proposals in the buffer that you accept or reject, or, for Greed’s own agent, ask first with the change shown as a diff, unless you allowed that kind of change for the session. Plugins they write go through the same type checking and tests as any other, and you review them before they load.
Performance budgets
cargo test runs a set of budgets, each a measurement with a limit it
must stay under:
- Starting with every default plugin, to the first frame, on an empty file and on a 10,000 line Rust file.
- Opening a file of a million lines, and one of 100 MB, then moving around and typing in them: the time per key, and the memory the file adds.
- 500 files open: opening them, moving, the buffer picker.
- A long session of opening, editing, undoing, splitting and closing, for the memory each round leaves behind, so a leak fails a test.
- Three clients attached, one typing beside a split, a terminal and a float: the time per key and the bytes each client gets for it, and what the session uses while nothing happens.
- Searching 2,000 files, and highlighting a 20,000 line file again after an edit.
Times are CPU time, which a busy machine changes far less than the clock, and each measurement runs in a process of its own. The limits are a few times what was measured, so a loaded machine or a debug build doesn’t fail them while something becoming several times slower does.
To see each measurement next to its limit:
GREED_BUDGETS=report cargo test --release -p greed-core --test budgets -- --nocapture
Adding --include-ignored also runs a session of several minutes. For how
keys feel in your own setup, with your plugins and config, greed bench
times each key from the terminal client’s side.
Plugins
Everything you see in Greed comes from these plugins, each a folder of Luau you can read, change or replace. Unload one with greed.plugin.unload(name) in your config.
acp
Agents in Greed over the Agent Client Protocol: Claude Code, Gemini, Codex or any agent that speaks ACP, each in a transcript buffer you write to and read from, working in the project or in a workspace of its own.
space i n start an agent: pick which, and where it works
space i l the sessions, running and kept: show, take up, review or bring them in
space i m move this session's transcript to a pane, tab, float or panel
In a transcript, alt-enter sends what’s in the box at the bottom (queued
while the agent works) and ctrl-c stops the agent’s turn. A question the
agent asks shows as a row of choices in the box, answered with enter or
a choice’s letter in any mode, or rejected with esc (question.luau).
Enter or a click on a row opens it (a helper’s transcript, a tool’s
output, a thought), and alt-up and alt-down highlight rows to open from
the box (transcript.luau’s pick).
A message like /model or /effort high runs one of Greed’s chat commands
instead of going to the agent, and tab after / completes them
(slash.luau).
Agents are registered by name with the commands that run them; the first one installed is used. Add your own in init.luau:
require("@acp").register({ name = "mine", commands = { { "my-agent", "--acp" } } })
Uses: core, picker, statusline, vcs, agent, models, panes, markdown, terminal.
| Command | Keys | What it does |
|---|---|---|
agent | Show the latest agent session, or start one when none runs | |
agent-answer | alt-q (in agent-transcript buffers), enter (every style’s command mode; in agent-transcript buffers) | On a row of a transcript, open it: a helper’s transcript in a float, a tool’s output or a thought; on a button, like a code block’s run, press it; else draw the question the agent waits on in the box again, to answer it there |
agent-auto | alt-a (in agent-transcript buffers) | Switch the agent between auto mode, where Greed answers its questions where it safely can, and asking you every time |
agent-box | Show or hide something on the line under agents’ message boxes (the agent-box option): agent, auto, mode, model, effort, keys, a field added with acp.box_field or “text in quotes” | |
agent-choice-click | Answer the agent’s question with the choice under the cursor | |
agent-choice-key | Answer the agent’s question with the choice of the key pressed | |
agent-choice-next | Highlight the next choice of the agent’s question | |
agent-choice-pick | Answer the agent’s question with the highlighted choice | |
agent-choice-prev | Highlight the previous choice of the agent’s question | |
agent-choice-reject | Reject the agent’s question; what’s in the box goes with it, as what to do instead | |
agent-code-ask | Ask the agent to run the shell code block at the cursor itself | |
agent-code-copy | Copy the shell code block at the cursor | |
agent-code-prompt | Put the shell code block at the cursor at this project’s shell’s prompt, in a float, to look over before running it; what comes of it goes to the agent with your next message | |
agent-code-run | Run the shell code block at the cursor in this project’s shell, showing it in a float, and tell the agent what came of it with your next message; one that destroys something asks first | |
agent-compact | Compact the conversation with Greed’s own agent: the model summarises all but the last few turns | |
agent-complete | tab (every style’s typing mode; in agent-transcript buffers) | In a transcript’s box, complete the slash command being typed; elsewhere, type a tab |
agent-copy-or-stop | ctrl-c (vscode’s typing mode; in agent-transcript buffers) | Copy the selection, or with nothing selected stop the agent’s turn |
agent-drop-images | alt-x (in agent-transcript buffers) | Drop the images pasted for your next message to the agent |
agent-effort | How hard the model of Greed’s own agent thinks in this session: none, low, medium, high or max; without one, pick it | |
agent-float-close | esc, q (every style’s command mode; in agent-transcript buffers) | Close a transcript’s float opened from a row of another, back to that row; elsewhere, what the key does otherwise |
agent-fold | tab (every style’s command mode; in agent-transcript buffers) | Show all of the output of the tool call or the thought under the cursor, or fold it again |
agent-fork | f (in agents buffers) | Fork the agent: a new session that starts with everything said so far |
agent-history-back | up (every style’s typing mode; in agent-transcript buffers) | In a transcript’s box, put the message you sent before it there, one starting with what’s typed; elsewhere move up |
agent-history-forward | down (every style’s typing mode; in agent-transcript buffers) | In a transcript’s box, put the message you sent after it there, or back to what was typed; elsewhere move down |
agent-list | esc, q (in agents buffers), i l (after the leader) | List the agent sessions, running and kept, to show, take up, move, review or close them |
agent-mode | alt-m (in agent-transcript buffers) | Pick the mode the agent works in, like plan or accept edits, or switch to the one named |
agent-model | alt-M (in agent-transcript buffers) | Pick the model the agent uses, from those it offers, or switch to the one named; Greed’s own agent can also use any model a provider lists |
agent-move | i m (after the leader) | Move the session’s transcript to a pane, a tab, a float or a panel: the next key says which |
agent-new | n (in agents buffers), i n (after the leader) | Start an agent: Greed’s own, or Claude Code, Gemini or Codex over ACP; pick which, and where it works |
agent-resume | The same as agent-list | |
agent-resume-pick | Pick a saved session of this project and take it up here, as /resume in a transcript does | |
agent-row-down | alt-down (in agent-transcript buffers) | In a transcript, highlight the row below; from the newest, back to the box |
agent-row-drop | Drop the highlight from a transcript’s row, back to the box | |
agent-row-up | alt-up (in agent-transcript buffers) | In a transcript, highlight the row above to open with enter or fold with tab: from the box, the newest |
agent-send | alt-enter (in agent-transcript buffers) | Send what’s in the transcript’s box to its agent |
agent-show-float | w (in agents buffers) | Show the session (the transcript’s, or those chosen in the list) in a floating view |
agent-show-pane | p (in agents buffers) | Show the session (the transcript’s, or those chosen in the list) in a pane of the tab |
agent-show-panel | s (in agents buffers) | Show the session (the transcript’s, or those chosen in the list) in a panel on the right |
agent-show-tab | t (in agents buffers) | Show the session (the transcript’s, or those chosen in the list) in a tab of its own |
agent-stop | ctrl-c (in agent-transcript, agents buffers) | Stop the agent’s turn |
agent-toggle-thoughts | Show or hide what agents think in their transcripts (the agent-thoughts option) | |
agents | The same as agent-list | |
agents-bring | b (in agents buffers) | Bring what the agent under the cursor changed into your working copy |
agents-close | x (in agents buffers) | Close the sessions marked in the list, or the one under the cursor: stop and forget them and remove their workspaces, asking first for those running or with a workspace |
agents-diff | d (in agents buffers) | Show what the agent under the cursor changed in its workspace |
agents-filter | / (in agents buffers) | Narrow the list to the sessions with the text typed |
agents-mark | m (in agents buffers) | Mark the session under the cursor in the list, or unmark it, to act on several |
agents-resume | r (in agents buffers) | Take up the sessions marked in the list, or the one under the cursor, without showing them |
agents-resume-here | h (in agents buffers) | Take up Greed’s own sessions marked in the list, or the one under the cursor, in this workspace |
agents-review | R (in agents buffers) | Review what the agent under the cursor changed as proposals on your files |
agents-show | enter (in agents buffers) | Show the sessions marked in the list, or the one under the cursor, taking them up if they’re kept |
claude-workspace | i W (after the leader) | Start Claude Code in a terminal, in a workspace of its own; it’s in the session list, where its work is reviewed and brought in |
decision-check | Try the decision model auto mode uses on commands it should and shouldn’t let agents run, and show what it would do with each | |
research | Research a question on the web: a helper agent searches and reads pages, its transcript open, and ends with a report with sources |
| Option | Default | What it does |
|---|---|---|
agent-auto | false | Start agent sessions in auto mode: Greed answers their questions where it can, the decision model judging commands by what you asked for, and asks you the rest; alt-a switches a session |
agent-auto-rules | "" | What the decision model should know in auto mode, in plain words: what’s fine to do in your setup and what isn’t, like “deleting under /tmp is fine; never touch the prod cluster” |
agent-box | "auto model mode effort keys" | What the line under an agent’s message box shows before its status, in the order it gives way when space is short: agent, auto (only when Greed answers its questions), mode (when not the one it started in), model, effort, keys, fields added with acp.box_field and “text in quotes” |
agent-care | "thorough" | How Greed’s own agent gathers context: “thorough” maps what exists with helpers before design questions and says what it checked; “quick” only reads what an answer depends on |
agent-compact-at | 0 | Compact conversations with Greed’s own agent once they reach this many tokens; 0 waits until they near the model’s limit |
agent-editor-context | true | Send agents the file you’re in, the cursor, the selection and the other files on screen with each message |
agent-greed-tools | true | Give agents Greed’s own tools (buffers, diagnostics, syntax queries, proposals) through greed mcp |
agent-heading | "model" | Who the line under each of the agent’s turns says answered: its “model”, falling back to the agent’s name, or the agent’s “name” |
agent-max-thought | 8000 | Stop a thought of Greed’s own agent once it passes this many tokens, before it acts, and ask for smaller steps; 0 lets thoughts run on |
agent-max-tokens | 0 | Stop Greed’s own agent once a session has read and written this many tokens, every request counted; 0 sets no limit |
agent-max-turns | 0 | Stop Greed’s own agent after this many steps in one prompt, for runs nobody watches; 0 lets it work until it’s done |
agent-pane-title | true | Whether a panel or float showing an agent has the agent’s name as its title |
agent-sessions-kept | 50 | How many sessions with Greed’s own agent are kept per repository to take up again; older ones are deleted |
agent-thoughts | true | Show what agents think in their transcripts, each thought folded to its first line (tab unfolds it); /thoughts switches it |
agent-title | "agent folder workspace" | What the line above an agent’s transcript says, in its order: agent, model, folder (in ~/where), workspace, fields added with acp.box_field and “text in quotes”; empty for no line |
agent-workspace-edits | true | Let agents in a workspace of their own edit, move and delete files there without asking |
agent
Lets agents and scripts use the editor: greed ctl from a shell, and MCP
clients like Claude Code through greed mcp.
Requests come in on the session socket. registry.luau answers MCP’s
methods (initialize, tools/list, tools/call), so the tools are the same
for an agent and for greed ctl TOOL. Add your own with
require("@agent").tool { ... }; tools.luau has the built-in ones, and
proposals.luau the review of edits agents propose.
Uses: core, picker, terminal, operations, approvals, describe, markdown, models.
| Command | Keys | What it does |
|---|---|---|
ask-cancel | Answer none of these questions, telling the agent you didn’t | |
ask-enter | On a page of questions: pick the choice under the cursor and go on to the next question, start typing an answer, or go on; on the last line, send | |
ask-send | Send your answers to the agent that asked these questions | |
claude | i C (after the leader) | Go to the Claude Code pane, or open one |
eval-allow-session | Let the agent’s code run, and every run until its session ends | |
eval-deny | Don’t let the agent’s code run | |
eval-log | Show each run of an agent’s code past the sandbox, with who let it | |
eval-run | Let the agent’s code run, this once | |
ide-mention | o m (after the leader) | Mention the selected lines to Claude Code, like @file#L1-5 |
memory-edit | Open your personal memories: standing preferences agents follow | |
memory-edit-project | Open your private memories of this project, the same in all its workspaces | |
memory-edit-shared | Open this project’s shared memories, .greed/memory.md in the repository | |
plugin-review-accept | a (in plugin-review buffers) | Install, approve and load the plugin under review |
plugin-review-reject | esc, q, r (in plugin-review buffers) | Reject the plugin under review |
proposal-accept | o a (after the leader) | Accept the proposed changes your selections touch |
proposal-accept-all | o A (after the leader) | Accept the whole of the proposals in this file, in every file they change |
proposal-compare | o d (after the leader) | Show the file with its proposed changes in, side by side |
proposal-next | ] o (every style’s command mode) | Select the next proposed change |
proposal-note | o n (after the leader) | Reject the proposed changes your selections touch, telling the agent what to do instead |
proposal-note-all | o N (after the leader) | Reject the whole of the proposals in this file, telling the agent what to do instead |
proposal-prev | [ o (every style’s command mode) | Select the previous proposed change |
proposal-reject | o r (after the leader) | Reject the proposed changes your selections touch |
proposal-reject-all | o R (after the leader) | Reject the whole of the proposals in this file, in every file they change |
proposals | o o (after the leader) | Pick a proposal to review: each agent’s change, with every file it changes |
repo-map | Show the repo map agents get: the functions and types that matter most, ranked toward the open files | |
working-set | Show the files you’ve been working in lately, the way agents see them |
| Option | Default | What it does |
|---|---|---|
agent-eval | "auto" | How Luau from agents runs: “auto” (sandboxed, a reviewer or you for more), “ask”, “allow” or “off” |
agent-tool-groups | "plan" | The tool groups agents get from the start, besides those they switch on: names with spaces between, or “all” |
claude-command | "claude" | How the Claude pane starts Claude Code, e.g. “claude –continue” |
web-search | "" | The search service agents search the web with: “brave”, “exa”, “tavily” or “searxng”; empty for none |
web-search-url | "" | Where your SearXNG is, for web-search searxng |
web-sources | "" | Domains whose results agents’ searches show first, like “reuters.com docs.rs”; a domain counts its subdomains too |
web-sources-only | false | Agents’ searches show only results from the web-sources domains |
approvals
Approving plugins. A plugin that isn’t one of Greed’s own and declares capabilities (running programs, files by path, the network, …) waits until you approve them, and again if it later asks for more.
:plugins-approve review the waiting plugins and approve one
:plugins every plugin, where it comes from and what it may use
:plugin-reload NAME load a plugin again from its folder
Uses: core, picker.
| Command | Keys | What it does |
|---|---|---|
plugin-reload | Load a plugin again from its folder, as after changing its code | |
plugins | List the plugins, where each comes from and what it may use; enter opens one | |
plugins-approve | Review the plugins waiting for approval of what they use, and approve one |
assist
Commands that ask a language model, in the roles :models shows, with what you pinned to the context (space i p, see the context plugin):
space i e explain the selection, in a panel as the answer arrives
space i a ask something about the selection
space i f fix the problem under the cursor, as changes to review
space i c draft a description of the changes in progress
Fixes come as proposed changes (] o, space o a, space o r), which undo as one operation. In the description buffer, a applies it (jj describe, or a git commit of what’s staged).
Uses: core, models, agent, vcs, context.
| Command | Keys | What it does |
|---|---|---|
ask-about | i a (after the leader) | Ask a language model something about the selection (or the line) |
assist-close | q (in answer, commit-message buffers) | Close the answer panel |
commit-message | i c (after the leader) | Draft a description of the changes in progress, from their diff |
commit-message-apply | a (in commit-message buffers) | Use the drafted description: jj describe, or a git commit of what’s staged |
explain | i e (after the leader) | Explain the selection (or the line), in a panel as the answer arrives |
fix | i f (after the leader) | Ask a language model to fix the problem under the cursor, as changes to review |
| Option | Default | What it does |
|---|---|---|
assist-role | "fast" | The model role assist’s commands ask; see :models |
blocks
Runnable blocks in Markdown: a fenced block whose language has a runner
(```sh, ```python, ```luau, ```http)
runs when you ask, and its output is saved in a result block right
under it, so the file shows it anywhere and a diff shows what changed.
Running it again replaces the result.
space m r run the block under the cursor (enter on its fence too)
space m R run every block in the file, in order, asking before
each one not marked safe=true
space m c clear the block's result; :blocks-results-clear for all
space m s stop the block running under the cursor
space m k run the blocks marked safe=true again, to see what changed
A result that comes out different from the run before shows how: the
new lines marked, the old ones struck out under them, until the block
runs again or its result is edited. drift-ignore=REGEX leaves out what
differs every run, like a timestamp.
Nothing runs when a file opens. The first time you run a block in a file
Greed asks whether to: y for now, a to always trust that file. Files you
trust, and those whose front matter says greed: run, show a run button
on each block. Agents run blocks only in files you trust, and only as
they were when you last ran them or trusted the file, so a block an
agent rewrote waits for you to run it first. So do blocks that run by
themselves (choices as a file opens, a pick’s when=): a block changed
from outside waits, and what you change yourself and save runs.
Options go in the info string: id=NAME names a block’s result, and
input=NAME gives another block that result (on stdin, or as input in
Luau), running the named block first if it has no result yet, or every
time with rerun=true. dir=PATH runs a program elsewhere than the
file’s folder, and timeout=SECONDS stops it after that long.
safe=true says running a block changes nothing: only those run without
asking when you didn’t press them, as an input or in run all. Add a
language from Luau:
require("@blocks").runner("lua", require("@blocks").program({ "lua", "-e" }))
Uses: core, agent, markdown, scene, shell.
| Command | Keys | What it does |
|---|---|---|
block-result-clear | m c (after the leader) | Remove the result under the code block at the cursor |
block-run | m r (after the leader) | Run the code block under the cursor and save its output in a result block under it |
block-shell | Put the code block under the cursor at the project shell’s prompt, in a float, to run from there; python, node and ruby blocks go as a file the line runs | |
block-stop | m s (after the leader) | Stop the code block running under the cursor |
block-terminal-keep | Keep what the terminal block under the cursor shows as its result, saved with the file | |
block-terminal-key | Send the key to the program in the terminal block being typed into | |
block-terminal-leave | ctrl-\ (terminal-block) | Stop typing into the terminal block |
block-terminal-type | Type into the terminal block under the cursor, starting it if it isn’t running; ctrl-\ stops | |
blocks-check | m k (after the leader) | Run this file’s blocks marked safe=true again and mark those whose output changed since the last run |
blocks-results-clear | Remove every code block’s result in the file | |
blocks-run-all | m R (after the leader) | Run every code block in the file, in order, saving each one’s result; asks before those not marked safe=true |
blocks-trust | Always let this file’s code blocks run, without asking | |
blocks-untrust | Ask again before this file’s code blocks run | |
markdown-run | Press the command button at the cursor, label in Markdown |
| Option | Default | What it does |
|---|---|---|
blocks-max-lines | 1000 | The most lines of output a block’s result keeps; the rest is cut |
blocks-stream | true | Show a block’s output under it as it comes, not only once it’s done; a block’s stream=false turns it off for that one |
board
Boards: saved, named sets of live shell commands, each a card showing
what its command prints now, one after another down a buffer that
scrolls like any other. A board is a Markdown file in the project’s
.greed/boards, or in your own config’s boards folder; its cards run
in a shell of the board’s own, from the project’s root, with the shell’s
live blocks: a watch, or a command that keeps printing.
:board [NAME] open a board, or pick one
:board-new NAME make one in this project (`!` for one of your own)
space . on a shell block: "pin to board"
On a board, enter opens a card’s block in a float, space . acts on
it as on the block in its shell, space a adds a command, space e
(or i on a card) edits the file at the card and space r runs the
cards again. Saving the file
shows the board as it says. A board from a file you didn’t make asks
before it runs anything, as code blocks do, and trusting one trusts the
other. A card changed from outside since you let it run waits, showing
its command, until enter on it.
Uses: core, picker, shell, blocks, chart, scene.
| Command | Keys | What it does |
|---|---|---|
board | Open a board: live shell commands, saved by name; pick one without a name | |
board-add | a (after the leader; in board buffers) | Add a command to this board as a card |
board-edit | e (after the leader; in board buffers), a, c, i, o (every style’s command mode, every style’s typing mode; in board buffers) | Open this board’s file at the card under the cursor; saving it shows the board as it says |
board-move-back | < (every style’s command mode, every style’s typing mode; in board buffers) | Move the card under the cursor one place back on the board, in its file too |
board-move-forward | > (every style’s command mode, every style’s typing mode; in board buffers) | Move the card under the cursor one place on along the board, in its file too |
board-new | Make a board in this project, or with ! one of your own, and open it | |
board-open-card | enter (every style’s command mode, every style’s typing mode; in board buffers) | Open the card under the cursor in a float, all of it; run it, when it waits for you to let it |
board-refresh | r (after the leader; in board buffers) | Run this board’s cards again |
| Option | Default | What it does |
|---|---|---|
board-card-width | 50 | How wide a board’s cards are at least, in columns: a wider board puts more of them side by side |
chart
Charts in the shell: | chart draws a table as a chart, guessing the
kind from its columns unless told. A name column and numbers are bars;
times and numbers, lines over time; numbers alone, a line each; two
numbers, one against the other. In a watch every run adds a point, so
watch -n 1 kubectl top pods | chart draws how each pod’s CPU goes.
kubectl top pods | chart bars, a pod each
kubectl top pods | chart bar MEMORY of another column
watch -n 1 cat /proc/loadavg | chart the load, over time
$3 | chart area --stacked how a table says
A chart is drawn in characters, braille for lines and eighth blocks for
bars, in the theme’s chart styles, so it shows in every terminal; on a
board, a card with chart after its language is one.
Uses: core, shell, scene, markdown, data.
| Option | Default | What it does |
|---|---|---|
chart-height | 12 | How many lines tall a chart in the shell is, unless –height says |
chat
Chat: Matrix and Mattermost in Greed. In the chat session (greed chat)
a sidebar lists your rooms and channels, those with something unread
first, then each space (or team) with its rooms under it, and rooms open
beside it; :chat opens the same sidebar elsewhere, or with chat-list
a float of the tab, rooms opening in its place. :chat-go (alt-g)
goes to any room or person by name. A room shows its messages, kept up
to date, and a box under them where enter sends what’s written (as Markdown)
and alt-enter starts a new line; enter on a space offers the rooms
it holds. :chat-login signs in to a server, by password or through the
browser; :chat-logout signs out. The services run as programs of their
own (backend.luau).
Uses: core, picker, markdown, panes, service.
| Command | Keys | What it does |
|---|---|---|
chat | M s (after the leader) | Your rooms and channels, as the chat-list option says: a sidebar on the left, or a float of the tab |
chat-alerted | Go to the room of the latest chat alert | |
chat-attach | In a room: send a file, picked by its path | |
chat-close | In a room: stop answering or changing; else back to the room from a thread, or to the list | |
chat-commands | alt-/ (every style’s typing mode; in chat-room buffers) | In a room: pick one of the service’s commands (Mattermost) into the box |
chat-delete | alt-d (in chat-room buffers) | In a room: delete the message under the cursor, asking first |
chat-edit | alt-e (in chat-room buffers) | In a room: change your message under the cursor |
chat-encryption | How a Matrix account’s encryption stands; sets a recovery key up where there’s none | |
chat-enter | enter (every style’s command mode; in chat-room buffers) | In a room: open the file of the message under the cursor (play a recording), vote in its poll, open its place on the map, press its buttons, or open its thread |
chat-go | alt-g (in chat, chat-room buffers), M g (after the leader) | Go to a room, channel or person by name, those with something unread first, or write to someone new; alt-enter or ctrl-v opens it beside, ctrl-s below |
chat-join | + (in chat buffers), M j (after the leader) | Join a room: one the server lists, or by its name, address or id |
chat-leave | - (in chat buffers) | Leave the room under the cursor in the list, or the room you’re in, after asking |
chat-link | Finish signing in with the link the browser ended on (what greed link hands over) | |
chat-login | Sign in to a Matrix or Mattermost server | |
chat-logout | Sign out of a chat account, and forget it | |
chat-newline | alt-enter (every style’s typing mode; in chat-room buffers) | In a room’s box: start a new line |
chat-older | alt-up (in chat-room buffers) | In a room: fetch older messages |
chat-open | enter (in chat buffers) | In the list of rooms: open the room under the cursor, answer its invite, or offer a space’s rooms |
chat-press | alt-b (in chat-room buffers) | In a room: press a button in the message under the cursor, or pick from its menu |
chat-react | alt-k (in chat-room buffers) | In a room: react to the message under the cursor, or take your reaction back |
chat-recover | Unlock a Matrix account’s keys with its recovery key, so older messages decrypt | |
chat-reply | alt-r (in chat-room buffers) | In a room: answer the message under the cursor with what’s sent next |
chat-room-1 | alt-1 (in chat-room buffers) | In a room: room 1 of the bar over it |
chat-room-2 | alt-2 (in chat-room buffers) | In a room: room 2 of the bar over it |
chat-room-3 | alt-3 (in chat-room buffers) | In a room: room 3 of the bar over it |
chat-room-4 | alt-4 (in chat-room buffers) | In a room: room 4 of the bar over it |
chat-room-5 | alt-5 (in chat-room buffers) | In a room: room 5 of the bar over it |
chat-room-6 | alt-6 (in chat-room buffers) | In a room: room 6 of the bar over it |
chat-room-7 | alt-7 (in chat-room buffers) | In a room: room 7 of the bar over it |
chat-room-8 | alt-8 (in chat-room buffers) | In a room: room 8 of the bar over it |
chat-room-9 | alt-9 (in chat-room buffers) | In a room: room 9 of the bar over it |
chat-room-next | tab (every style’s command mode; in chat-room buffers) | In a room: the next room in the bar over it |
chat-room-previous | shift-tab (every style’s command mode; in chat-room buffers) | In a room: the room before in the bar over it |
chat-search | / (in chat buffers), alt-s (in chat-room buffers), M / (after the leader) | Search your chat messages; in a room, that room’s |
chat-send | enter (every style’s typing mode; in chat-room buffers) | In a room: send what’s written in its box |
chat-session | Go to the chat session, starting it if it isn’t running | |
chat-sidebar | Your rooms and channels as a sidebar on the left, rooms opening beside it | |
chat-thread | alt-t (in chat-room buffers) | In a room: open the thread of the message under the cursor |
chat-verify | Verify this device against another of yours (a phone, Element) by comparing emoji | |
chat-write | M w (after the leader) | Write to someone: find them by name and open your direct messages, starting them if needed |
| Option | Default | What it does |
|---|---|---|
chat-alerts | "mentions" | Which new messages tell you: mentions and direct messages, all the service notifies of, or none |
chat-alerts-desktop | false | Show chat alerts as the desktop’s own notifications too (notify-send or osascript), for when no Greed is attached to tell you |
chat-list | "sidebar" | Where :chat shows your rooms outside the chat session: “sidebar”, a panel on the left, or “float” |
chat-matrix-program | "" | The greed-matrix program, its name on PATH or a path; empty for the one beside greed, or else on PATH |
chat-mattermost-program | "" | The greed-mattermost program, its name on PATH or a path; empty for the one beside greed, or else on PATH |
chat-previews | true | Show what links in chat messages lead to, under them, where the service can say |
chat-search-days | 90 | How many days back each room’s messages are fetched and kept to search; newer ones are always kept |
cli
Greed’s command line commands that are only Luau: greed ls, greed new,
greed bring and greed reference. Plugins add their own the same way:
greed.cli({
name = "hello",
doc = "Say hello",
usage = "[NAME]",
run = function(args)
return `hello {args[1] or "there"}`
end,
})
greed hello world then prints “hello world”.
Uses: agent.
cmdline
The command line: press “:” (alt-x in the vscode style) and type a command, like in Vim or Helix.
Every command can be run by name (:save, :pick-file), and the short
names Vim and Helix users know are aliases (:w, :q, :wq, :e).
Words after the command are its arguments (:open src/main.rs), and a
trailing “!” forces it (:q! quits with unsaved changes). :lua runs
Luau and := shows the value of an expression. A line range in front
(:%s/a/b/g, :5,10d) selects those lines first; ex.luau has Vim’s
line commands, and :g/regex/command is here.
Matches show above the prompt as you type. Tab and shift-tab go through them, up and down go through earlier command lines starting with what’s typed, enter runs and esc closes.
Other plugins add aliases and argument completion through
require("@cmdline"):
local cmdline = require("@cmdline")
cmdline.alias("gs", "git-status")
cmdline.completer("branch", function(word)
return { { text = "main" }, { text = "dev" } }
end)
A command then uses args = { { name = "branch", complete = "branch" } }.
Uses: core.
| Command | Keys | What it does |
|---|---|---|
command-line | : (blocks, read, every style’s command mode), ctrl-g (vscode), alt-x (vscode’s typing mode) | Type a command to run, with completion, starting with the text given |
command-line-close | ctrl-c, esc (in cmdline buffers) | Close the command line without running anything |
command-line-newer | ctrl-n, down (in cmdline buffers) | Show the next command line that starts with what’s typed |
command-line-next | tab (in cmdline buffers) | Fill in the next match on the command line |
command-line-older | ctrl-p, up (in cmdline buffers) | Show the previous command line that starts with what’s typed |
command-line-prev | shift-tab (in cmdline buffers) | Fill in the previous match on the command line |
command-line-run | enter (in cmdline buffers) | Run what’s typed on the command line |
copy-lines | Copy the selected lines below a line, 0 for the top (:t) | |
delete-lines | Delete the selected lines, copying them (:d) | |
eval-selection | l e (after the leader) | Run the selected Luau, or the line, and show what it returns at the end of it |
get-option | Show an option’s value | |
move-lines | Move the selected lines below a line, 0 for the top (:m) | |
normal | Type keys in normal mode on each selected line (:norm) | |
set | Set an option: NAME VALUE; for a yes-or-no one, NAME, noNAME or NAME! as in Vim; NAME? shows it | |
sort-lines | Sort the selected lines (:sort): ! reverses, u keeps one of each, i ignores case, n sorts by the first number | |
substitute | Replace a regex with text on the selected lines (:s/regex/text/flags) | |
toggle-option | Turn a yes-or-no option on or off | |
yank-lines | Copy the selected lines (:y) |
| Option | Default | What it does |
|---|---|---|
substitute-preview | true | Show what :s will change as you type it, before it runs |
context
The context: what you’ve pinned for models and agents to see, as live references read fresh each time they’re sent.
space i p pin the selection, or the file when nothing is selected
space i i show the pinned items, one a line with its size; d drops
the items on the lines selected (x d)
:context-add-problems pins this file’s problems, :context-add-diff the
changes in progress, :context-clear drops everything. Assist commands
send the context with each question, and agents read it with the
context_get tool. It’s kept per project.
A plugin adds items that are worked out when sent:
require("@context").define("todos", function()
return "the TODO lines of the project ..."
end)
require("@context").add({ kind = "computed", name = "todos" })
Uses: core, agent, vcs.
| Command | Keys | What it does |
|---|---|---|
context | i i (after the leader) | Show what’s pinned for models and agents, with sizes; d drops an item |
context-add | i p (after the leader) | Pin the selection to the context, or the file when nothing is selected; elsewhere, what’s under the cursor |
context-add-diff | Pin the changes in progress to the context | |
context-add-problems | Pin this file’s problems to the context | |
context-clear | Drop everything pinned to the context | |
context-close | esc, q (in context buffers) | Close the context list |
context-drop | d (in context buffers) | Drop the pinned items on the lines selected in the context list |
core
Greed’s editing engine: the commands, motions, text objects, registers, floats, prompts and the editing styles registry, written against the same API any plugin uses. The editing styles themselves, like Helix and Vim, are plugins that give these commands keys.
| Command | Keys | What it does |
|---|---|---|
add-newline-above | [ space (helix, vim) | Add an empty line above each selection, staying put |
add-newline-below | ] space (helix, vim) | Add an empty line below each selection, staying put |
align-selections | & (helix) | Line the selections up at one column, with spaces before them |
align-view-bottom | z b (helix, vim), b (view) | Scroll so the cursor’s line is at the bottom of the screen |
align-view-top | z t (helix, vim), t (view) | Scroll so the cursor’s line is at the top of the screen |
append-line-end | A (helix) | Insert at the end of each line |
append-mode | a (helix) | Insert after each selection |
back | esc, q (every style’s command mode; in chat, chat-room, help, image, mail, mail-thread, multibuffer, pdf, staged-diff, tree buffers) | Go back: a step in what’s shown, else where you came from (q and esc where you read rather than edit) |
big-word-end | E (helix) | Select to the end of the WORD |
buffer | Show an open file by its name or part of it, as Vim’s :b does; # is the one you were in before | |
buffer-close | ctrl-w (vscode) | Close this buffer, showing another file in its place; refuses with unsaved changes (force closes anyway) |
buffer-close-others | Close every file but this one; refuses if one has unsaved changes (force closes anyway) | |
buffer-next | g n (helix) | Show the next open file |
buffer-prev | g p (helix) | Show the previous open file |
camel-case | Change the selected words to camel case, each line on its own | |
center-view | z c (helix), z z (helix, vim), c, z (view) | Scroll so the cursor’s line is in the middle of the screen |
change | c (helix) | Copy each selection, delete it and switch to insert mode |
change-without-copy | alt-c (helix) | Delete each selection and switch to insert mode, leaving the clipboard alone |
client-follow | Have this client show the project, tabs and panes the other clients follow, closing the panes it had on its own (their buffers stay open) | |
client-independent | Lay this client out on its own, starting from what it shows now: its tabs, panes and project no longer follow the other clients | |
collapse | ; (helix), esc (vscode) | Collapse each selection to its cursor |
config-open | Open your config, init.luau, to change it; it runs again when saved | |
config-reload | Run your config again, as saving it does | |
copy | space Y, space y, y (helix) | Copy each selection to the clipboard |
copy-lines-down | alt-shift-down (vscode) | Copy the cursors’ lines below them |
copy-lines-up | alt-shift-up (vscode) | Copy the cursors’ lines above them |
copy-or-line | ctrl-c (vscode) | Copy the selection, or the line when nothing is selected |
copy-selection-down | C (helix), ctrl-alt-down (vscode) | Add a selection on the next line, at the same columns |
copy-selection-up | alt-C (helix), ctrl-alt-up (vscode) | Add a selection on the line above, at the same columns |
cut | Copy each selection to the clipboard and delete it | |
cut-or-line | ctrl-x (vscode) | Cut the selection, or the line when nothing is selected |
debug | Turn debug topics on (:debug keys frames), off (:debug -keys, :debug off), or say which are on | |
debug-log | Show what the debug topics on have said, in a pane below, following new lines | |
decrement | ctrl-x (helix) | Subtract the count (or 1) from the number at each cursor |
dedent | < (helix), shift-tab (every style’s typing mode, vscode), ctrl-d (vim-insert) | Take one level of indent off the lines of each selection; while typing in a snippet, go back to its last place |
delete | d (helix) | Copy each selection and delete it |
delete-back | backspace (every style’s typing mode) | Delete the character before each cursor, and the closer of an empty pair |
delete-forward | delete (every style’s typing mode) | Delete the character after each cursor |
delete-lines-at-cursor | ctrl-K (vscode) | Delete the lines the cursors are on |
delete-to-line-end | ctrl-k (every style’s typing mode) | Delete to the end of the line from each cursor |
delete-to-line-start | ctrl-u (every style’s typing mode) | Delete back to the start of the line from each cursor |
delete-without-copy | alt-d (helix) | Delete each selection, leaving the clipboard alone |
delete-word-back | alt-backspace, ctrl-w (every style’s typing mode), ctrl-backspace (vscode) | Delete back to the start of the word before each cursor |
delete-word-forward | alt-d (every style’s typing mode), ctrl-delete (vscode) | Delete to the start of the next word after each cursor |
detach | Leave the editor running in the background; greed attach comes back | |
earlier | alt-u (helix), g - (vim) | Go back to the state of the text made before this one, on any undo branch |
erase-back | backspace (vscode) | Delete the selection, or the character before the cursor |
erase-forward | delete (vscode) | Delete the selection, or the character after the cursor |
errors | List errors from plugin code that nothing caught, with the plugin, what it ran and where it failed | |
expand-selection | alt-o (helix) | Grow each selection to the syntax node around it |
extend-big-word-end | E (helix-select) | Extend the selection to the end of the WORD |
extend-big-word-left | B (helix-select) | Extend the selection to the previous WORD |
extend-big-word-right | W (helix-select) | Extend the selection to the next WORD |
extend-down | down, j (helix-select), shift-down (vscode) | Extend the selection one line down |
extend-end | g e (helix-select), ctrl-shift-end (vscode) | Extend the selection to the end of the buffer |
extend-find-next-char | f (helix-select) | Extend to and including the next character typed |
extend-find-prev-char | F (helix-select) | Extend back to the previous character typed |
extend-first-non-blank | g s (helix-select) | Extend the selection to the first character that isn’t a space |
extend-goto-line | G (helix-select) | Extend the selection to the line given as a count, or the last line |
extend-left | h, left (helix-select), shift-left (vscode) | Extend the selection one character left |
extend-line-end | end, g l (helix-select), shift-end (vscode) | Extend the selection to the end of the line |
extend-line-start | g h, home (helix-select) | Extend the selection to the start of the line |
extend-right | l, right (helix-select), shift-right (vscode) | Extend the selection one character right |
extend-smart-home | shift-home (vscode) | Select to the first non-blank of the line, or to its start |
extend-start | g g (helix-select), ctrl-shift-home (vscode) | Extend the selection to the start of the buffer |
extend-till-next-char | t (helix-select) | Extend up to the next character typed |
extend-till-prev-char | T (helix-select) | Extend back to just after the previous character typed |
extend-to-line-bounds | X (helix) | Extend each selection to whole lines |
extend-up | k, up (helix-select), shift-up (vscode) | Extend the selection one line up |
extend-word-end | e (helix-select) | Extend the selection to the end of the word |
extend-word-left | b (helix-select), ctrl-shift-left (vscode) | Extend the selection to the previous word |
extend-word-right | w (helix-select), ctrl-shift-right (vscode) | Extend the selection to the next word |
file-delete | Delete this file from the disk, after you press y, and close it | |
file-rename | Rename or move this file: a name alone keeps it in its folder, a path is from the project | |
find | ctrl-f (vscode) | Find text in the file as you type, as VS Code’s ctrl-f does: enter and shift-enter go to the next and previous match, esc closes |
find-next | enter, f3 (in find buffers) | Go to the next match with the find bar open |
find-next-char | f (helix) | Select up to and including the next character typed |
find-prev | shift-enter, shift-f3 (in find buffers) | Go to the previous match with the find bar open |
find-prev-char | F (helix) | Select back to the previous character typed |
first-non-blank | g s (helix) | Move to the first character on the line that isn’t a space |
flip | alt-; (helix) | Swap the anchor and head of each selection |
fold-close | z C (helix), z c (vim) | Fold the block the cursor is in under its first line |
fold-close-all | z M (vim), ctrl-k ctrl-0 (vscode) | Fold every outermost block in the buffer |
fold-next | z j (vim) | Go to the start of the block below the cursor |
fold-open | z o (helix, vim), z d (vim) | Unfold the folds the cursor is in |
fold-open-all | z R (helix, vim), z E (vim), ctrl-k ctrl-j (vscode) | Unfold everything in the buffer |
fold-prev | z k (vim) | Go to the end of the block above the cursor |
fold-selection | Fold the selected lines under the first | |
fold-toggle | tab (blocks, helix, vim), z a (helix, vim), ctrl-k ctrl-l (vscode) | Fold the block the cursor is in, or unfold it |
fold-toggle-all | shift-tab (blocks, helix) | Unfold everything when anything is folded, or else fold every outermost block |
font-bigger | ctrl-+, ctrl-= (global) | Make the window’s text bigger |
font-reset | ctrl-0 (global) | Put the window’s text back to its size before zooming |
font-smaller | ctrl-- (global) | Make the window’s text smaller |
goto-column | g | (helix) | Move to the column given as a count, on each cursor’s line |
goto-definition | g d (every style’s command mode), f12 (vscode) | Go to where the thing under the cursor is defined |
goto-end | ctrl-end (vscode) | Move to the end of the buffer |
goto-file | g f (helix) | Open the file named under the cursor or in the selection |
goto-last-accessed-file | g a (helix), ctrl-6, ctrl-^ (every style’s command mode) | Show the file you were in before this one |
goto-last-line | g e (helix) | Move to the start of the last line |
goto-last-modification | g . (helix), ctrl-k ctrl-q (vscode) | Move to where this file was last changed |
goto-last-modified-file | g m (helix) | Show the file you changed last, other than this one |
goto-line | G (helix) | Move to the line given as a count, or the last line |
goto-parent-end | alt-e (helix) | Move to the end of the syntax node around each selection’s |
goto-parent-start | alt-b (helix) | Move to the start of the syntax node around each selection’s |
goto-start | g g (helix), ctrl-home (vscode) | Move to the start of the buffer, or with a count, to that line |
goto-window-bottom | g b (helix) | Move to the bottom line on the screen |
goto-window-center | g c (helix) | Move to the middle line on the screen |
goto-window-top | g t (helix) | Move to the top line on the screen |
half-page-down | ctrl-d (helix, read, view, vim), z ctrl-d (helix) | Move half a screen down |
half-page-up | ctrl-u (helix, read, view, vim), z ctrl-u (helix) | Move half a screen up |
hover | k (after the leader), K (vim), ctrl-k ctrl-i (vscode) | Show what’s under the cursor, and any problems there |
increment | ctrl-a (helix) | Add the count (or 1) to the number at each cursor |
indent | > (helix), ctrl-t (vim-insert), ctrl-] (vscode) | Indent the lines of each selection |
insert-char | Insert the typed character at each cursor | |
insert-line-above | ctrl-shift-enter (vscode) | Start a new line above this one |
insert-line-below | ctrl-enter (vscode) | Start a new line below this one |
insert-line-start | I (helix) | Insert at the start of each line, after its indent |
insert-mode | i (helix) | Insert before each selection |
insert-newline | enter (every style’s typing mode), alt-enter (every style’s typing mode; in shell buffers) | Insert a line break at each cursor, starting the new line at its indent |
insert-register | ctrl-r (every style’s typing mode) | Insert what the register typed next holds at each cursor |
insert-tab | tab (every style’s typing mode) | Go to the next place of the snippet being filled in; on a list item’s first line, indent it with what’s under it (when there’s one before it to go under); otherwise insert a level of indent at each cursor |
join-lines | J (helix) | Join the next line onto each cursor’s, or the lines of each selection, with one space |
jump-back | ctrl-o (helix, vim), alt-left (vscode) | Go back to where the last jump started, in this view |
jump-forward | ctrl-i (helix, vim), alt-right (vscode) | Go forward again after jumping back, in this view |
jump-to-word | g w (helix) | Label the words on screen and select the one whose label is typed |
kebab-case | Change the selected words to kebab case, each line on its own | |
keep-matching | K (helix) | Keep the selections that match a regex |
keep-primary | , (helix) | Keep only the primary selection |
later | alt-U (helix), g + (vim) | Go on to the state of the text made after this one, on any undo branch |
line-end | end (helix, every style’s typing mode, vscode), g l (helix) | Move to the end of the line |
line-start | g h (helix), home (helix, every style’s typing mode) | Move to the start of the line |
link-copy | y (in link buffers) | Copy the link in this float |
lowercase | ``` (helix) | Make the selections lowercase |
macro-save | Save the last macro (or the one in a register) as a command you can run and edit | |
match-bracket | m m (helix) | Move to the matching bracket, or the closing one of the pair around the cursor |
merge-consecutive-selections | alt-_ (helix) | Merge selections that touch or overlap |
merge-selections | Merge all selections into one, from the first to the last | |
motion-hint-1 | Do the last motion 1 more times | |
motion-hint-2 | Do the last motion 2 more times | |
motion-hint-3 | Do the last motion 3 more times | |
motion-hint-4 | Do the last motion 4 more times | |
motion-hint-5 | Do the last motion 5 more times | |
motion-hint-6 | Do the last motion 6 more times | |
motion-hint-7 | Do the last motion 7 more times | |
motion-hint-8 | Do the last motion 8 more times | |
motion-hint-9 | Do the last motion 9 more times | |
move-down | down (helix, read, every style’s typing mode, vscode), j (helix, read) | Move one line down |
move-left | h (helix, read), left (helix, read, every style’s typing mode, vscode) | Move one character left |
move-lines-down | alt-down (vscode) | Move the cursors’ lines down one, or the list item or section the cursor is in past the next |
move-lines-up | alt-up (vscode) | Move the cursors’ lines up one, or the list item or section the cursor is in past the one before |
move-right | l (helix, read), right (helix, read, every style’s typing mode, vscode) | Move one character right |
move-up | k (helix, read), up (helix, read, every style’s typing mode, vscode) | Move one line up |
move-word-left | ctrl-left (vscode) | Move to the start of the previous word |
move-word-right | ctrl-right (vscode) | Move to the start of the next word |
next-big-word | W (helix) | Select to the start of the next WORD (punctuation included) |
next-comment | ] c (helix, vim) | Select the next comment |
next-entry | ] e (helix, vim) | Select the next entry |
next-function | ] f (helix, vim) | Select the next function |
next-item | ] m (every style’s command mode) | Go to the next item: a message in a chat room or a mail thread, a row of a list |
next-parameter | ] a (helix, vim) | Select the next parameter |
next-test | ] T (helix, vim) | Select the next test |
next-type | ] t (helix, vim) | Select the next type |
next-word | w (helix) | Select to the start of the next word |
normal-mode | esc (every style’s typing mode) | Back to the editing style’s own mode (normal, in Helix’s) |
open | Open a file in the main view | |
open-above | O (helix) | Open a new line above each cursor and insert there |
open-below | o (helix) | Open a new line below each cursor and insert there |
page-down | ctrl-f (helix, read, view, vim), pagedown (helix, read, every style’s typing mode, vim, vscode), z ctrl-f (helix) | Move a screen down |
page-up | ctrl-b (helix, read, view, vim), pageup (helix, read, every style’s typing mode, vim, vscode), z ctrl-b (helix) | Move a screen up |
pascal-case | Change the selected words to pascal case, each line on its own | |
paste-after | p, space p (helix) | Paste after each selection |
paste-before | P (helix) | Paste before each selection |
paste-image | alt-v (in agent-transcript buffers) | Paste the image on your clipboard into what you’re in, like an agent’s box |
paste-over | ctrl-v (vscode) | Paste, replacing each selection; whole lines go above the cursor’s line |
play-macro | q (helix) | Play the macro in @, or the register picked |
press-button | enter (helix, read, vim) | Run the button under the cursor, as clicking it does |
prev-big-word | B (helix) | Select to the start of the previous WORD |
prev-comment | [ c (helix, vim) | Select the previous comment |
prev-entry | [ e (helix, vim) | Select the previous entry |
prev-function | [ f (helix, vim) | Select the previous function |
prev-parameter | [ a (helix, vim) | Select the previous parameter |
prev-test | [ T (helix, vim) | Select the previous test |
prev-type | [ t (helix, vim) | Select the previous type |
prev-word | b (helix) | Select to the start of the previous word |
previous-item | [ m (every style’s command mode) | Go to the item before, or the start of the one the cursor is in |
profile | Start counting where the editor’s time goes; again, stop and show it, the most time first | |
project | Open a project, or switch to it if it’s open | |
project-close | Close the shown project, unless it has unsaved changes (force closes anyway) | |
project-config | Run the shown project’s own config in .greed/, if you trusted it | |
prompt-cancel | ctrl-c, esc (in find, prompt, search-box buffers) | Close the prompt without accepting |
prompt-submit | enter (in prompt, search-box buffers) | Accept what’s typed in the prompt |
quick-fix | a (after the leader), g r a (vim), ctrl-. (vscode) | Fix or change what’s under the cursor: what a plugin offers there, like linking a note a line mentions, or else the language server’s fixes and refactorings |
quit | ctrl-q (global) | Close this pane when there are others; otherwise close the project and leave, or exit the editor if it’s the last one, refusing with unsaved changes (force goes anyway) |
quit-abort | In a file a program waits on, like git commit’s message, stop the program with an error, as Vim’s :cq does; whatever was written is left as it is | |
quit-all | End the session and every project in it, whatever runs, unless files have unsaved changes (force ends it anyway) | |
quit-ask | ctrl-q (vscode) | Leave the project, or exit the editor, from any pane, as VS Code’s ctrl-q does; asks whether to save unsaved files first rather than refusing |
quit-session | End the session, whatever runs in it, unless files have unsaved changes (force ends it anyway); terminals, shells and agents never count as unsaved | |
record-macro | Q (helix) | Start recording keys into a macro (@, or the register picked), or stop |
redo | U (helix), ctrl-Z, ctrl-y (vscode) | Redo the last undone change |
reflow | Rewrap the lines of each selection to the text width, or the width given | |
reindent-lines | Indent each selected line as its language and the lines around it say | |
reload | Load the file again from disk, as an edit undo can take back | |
reload-all | Load every open file again from disk, as edits undo can take back | |
remove-matching | alt-K (helix) | Remove the selections that match a regex |
remove-primary | alt-, (helix) | Remove the primary selection |
repeat-change | . (helix, vim) | Repeat the last change, at the cursors; a count replaces the one it had |
repeat-find | alt-. (helix) | Do the last f, t, F or T again; in select mode, extending |
replace-char | r (helix) | Replace every selected character with the next one typed |
replace-in-file | ctrl-h (vscode) | Replace text everywhere in the file, as VS Code’s ctrl-h does: what to find, with its matches lit and counted, then what to put instead |
replace-with-copy | R, space R (helix) | Replace each selection with what was copied |
rotate-contents | alt-) (helix) | Move each selection’s text to the selection after it, the last’s to the first |
rotate-contents-back | alt-( (helix) | Move each selection’s text to the selection before it, the first’s to the last |
rotate-primary | ) (helix) | Make the next selection the primary one |
rotate-primary-back | ( (helix) | Make the previous selection the primary one |
save | ctrl-s (global) | Write the buffer to its file, or to a new one; force makes a folder it goes in that isn’t there |
save-all | ctrl-k s (vscode) | Write every file with unsaved changes; force makes folders they go in that aren’t there |
save-quit | Z Z (vim) | Write the buffer to its file if it changed, then quit |
save-quit-all | Write every file with unsaved changes, then end the session | |
scroll-down | z down, z j (helix), down, j (view), ctrl-e (vim) | Scroll the view a line down |
scroll-up | z k, z up (helix), k, up (view), ctrl-y (vim) | Scroll the view a line up |
search | / (helix, read, vim) | Search forward for a regex as you type |
search-back | ? (helix, vim) | Search backward for a regex as you type |
search-box-newer | down (in search-box buffers) | Put the query submitted after this one in the search box |
search-box-older | up (in search-box buffers) | Put the query submitted before this one in the search box |
search-clear | Take away the search’s match highlights, as Vim’s :noh does | |
search-next | n (helix, read, vim), f3 (vscode) | Select the next match of the last search |
search-next-add | n (helix-select) | Add the next match of the last search as another selection |
search-prev | N (helix, read, vim), shift-f3 (vscode) | Select the previous match of the last search |
search-prev-add | N (helix-select) | Add the previous match of the last search as another selection |
search-selection | * (helix) | Search for the selected text, as whole words where it starts or ends one |
search-selection-anywhere | alt-* (helix) | Search for the selected text, also inside longer words |
secret-set | Keep a secret, like an API key, in the system keyring (or Greed’s secrets file) | |
select-all | % (helix), ctrl-a (vscode) | Select the whole buffer |
select-all-children | alt-I (helix) | Select every syntax node inside each selection’s |
select-all-matches | ctrl-L (vscode) | Select every match of the selected text (or the word at the cursor) |
select-all-siblings | alt-a (helix) | Select every syntax node beside each selection’s, its own included |
select-around-angles | m a <, m a > (helix) | Select around the angles |
select-around-backticks | `m a `` (helix) | Select around the backticks |
select-around-big-word | m a W (helix) | Select the WORD and the space after it |
select-around-braces | m a {, m a } (helix) | Select around the braces |
select-around-brackets | m a [, m a ] (helix) | Select around the brackets |
select-around-comment | m a c (helix) | Select around the comment at each selection |
select-around-double-quotes | m a " (helix) | Select around the double-quotes |
select-around-entry | m a e (helix) | Select around the entry at each selection |
select-around-function | m a f (helix) | Select around the function at each selection |
select-around-indent | m a i (helix) | Select the lines indented as far as this one, and the one above |
select-around-last | m a l (helix) | Select around the last pair of the bracket or quote typed next |
select-around-next | m a n (helix) | Select around the next pair of the bracket or quote typed next |
select-around-number | m a d (helix) | Select the number at or after the cursor, with its sign |
select-around-pair | m a m (helix) | Select around the nearest brackets or quotes |
select-around-parameter | m a a (helix) | Select around the parameter at each selection |
select-around-parens | m a (, m a ) (helix) | Select around the parens |
select-around-quotes | m a ' (helix) | Select around the quotes |
select-around-tag | m a x (helix) | Select around the XML or HTML element |
select-around-test | m a T (helix) | Select around the test at each selection |
select-around-type | m a t (helix) | Select around the type at each selection |
select-around-word | m a w (helix) | Select the word and the space after it |
select-inside-angles | m i <, m i > (helix) | Select inside the angles |
select-inside-backticks | `m i `` (helix) | Select inside the backticks |
select-inside-big-word | m i W (helix) | Select the WORD |
select-inside-braces | m i {, m i } (helix) | Select inside the braces |
select-inside-brackets | m i [, m i ] (helix) | Select inside the brackets |
select-inside-comment | m i c (helix) | Select inside the comment at each selection |
select-inside-double-quotes | m i " (helix) | Select inside the double-quotes |
select-inside-entry | m i e (helix) | Select inside the entry at each selection |
select-inside-function | m i f (helix) | Select inside the function at each selection |
select-inside-indent | m i i (helix) | Select the lines indented as far as this one |
select-inside-last | m i l (helix) | Select inside the last pair of the bracket or quote typed next |
select-inside-next | m i n (helix) | Select inside the next pair of the bracket or quote typed next |
select-inside-number | m i d (helix) | Select the number at or after the cursor |
select-inside-pair | m i m (helix) | Select inside the nearest brackets or quotes |
select-inside-parameter | m i a (helix) | Select inside the parameter at each selection |
select-inside-parens | m i (, m i ) (helix) | Select inside the parens |
select-inside-quotes | m i ' (helix) | Select inside the quotes |
select-inside-tag | m i x (helix) | Select inside the XML or HTML element |
select-inside-test | m i T (helix) | Select inside the test at each selection |
select-inside-type | m i t (helix) | Select inside the type at each selection |
select-inside-word | m i w (helix) | Select the word |
select-line | x (helix) | Select the whole line, including its line break; again, the next line too |
select-lines | ctrl-l (vscode) | Select the cursor’s line, or the next one too when whole lines are selected |
select-next-match | ctrl-d (vscode) | Select the word at the cursor, then add the next match of it as another selection |
select-next-sibling | ] n (helix, vim) | Select the next syntax node beside each selection |
select-prev-sibling | [ n (helix, vim) | Select the previous syntax node beside each selection |
select-regex | s (helix) | Select every match of a regex inside the selections |
select-register | " (helix, vim) | Pick a register, by the next key typed, for the next copy, paste or macro |
selection-redo | ctrl-k (helix), ctrl-U (vscode) | Go forward to the selection selection-undo went back from |
selection-undo | ctrl-h (helix), ctrl-u (vscode) | Go back to the selection before the last command |
sentence-case | Change the selected words to sentence case, each line on its own | |
session | Go to another session: a running one by name, or a project’s (started if needed) | |
session-back | B (after the leader) | Go back to the session you were in before, on whichever machine (space B) |
session-home | Go back to this machine: the session here you were in last, or this folder’s | |
shrink-selection | alt-i (helix) | Shrink each selection back, or to the first syntax node inside it |
shrink-to-line-bounds | alt-x (helix) | Shrink each selection to the whole lines inside it |
smart-home | home (vscode) | Go to the first non-blank of the line, or to its start |
snake-case | Change the selected words to snake case, each line on its own | |
split-lines | alt-s (helix) | Split the selections into lines |
split-regex | S (helix) | Split the selections at every match of a regex |
stalls | List the times plugin code held the editor up, with the plugin and what it ran | |
style | Switch editing style, or pick one | |
surround-add | m s (helix) | Wrap each selection in the pair of the next character typed |
surround-delete | m d (helix) | Take away the pair of the next character typed from around each selection |
surround-replace | m r (helix) | Swap the pair of the next character typed around each selection for another’s |
swap-node-next | alt-shift-right (helix, vim, vim-visual) | Move the syntax node selected past the one after it |
swap-node-prev | alt-shift-left (helix, vim, vim-visual) | Move the syntax node selected past the one before it |
switch-case | ~ (helix) | Switch the case of each selected letter |
text-float-close | Close the float showing text | |
till-next-char | t (helix) | Select up to the next character typed |
till-prev-char | T (helix) | Select back to just after the previous character typed |
title-case | Change the selected words to title case, each line on its own | |
toggle-comment | ctrl-c, space c (helix), ctrl-/, ctrl-_ (vscode) | Comment the lines of each selection, or uncomment them if they all are |
trim-selections | _ (helix) | Trim the spaces and line breaks off both ends of each selection |
trust | Trust the shown project to run its own code: its config in .greed/, language servers and formatting on save | |
type-char | Type the pressed character, replacing any selection | |
type-newline | enter (vscode) | Type a line break, replacing any selection, and start the new line at its indent |
type-tab | tab (vscode) | Go to the next place of the snippet being filled in; otherwise indent the selected lines when a selection spans lines, or the list item the cursor starts with what’s under it, or type a level of indent |
ui-next | Go to the next widget of a plugin’s view | |
ui-press | Press the widget at the cursor in a plugin’s view, as clicking it does | |
ui-prev | Go to the widget before in a plugin’s view | |
undo | u (helix), ctrl-z (vscode) | Undo the last change |
uppercase | `alt-`` (helix) | Make the selections uppercase |
view-mode | Z (helix) | Keys for the view until esc: center, top, bottom, scroll |
view-mode-leave | esc (view) | Back from the view mode |
window-new | ctrl-N (global) | Open another window on this session, laid out on its own, as a terminal’s new window does; space P in it goes to another project |
word-end | e (helix) | Select to the end of the word |
zoom-in | z (after the leader) | Show only the list item or section the cursor is in, with what’s under it |
zoom-out | Z (after the leader) | Show what’s around the list item or section zoomed in to, or all of it again |
| Option | Default | What it does |
|---|---|---|
auto-pairs | "style" | Type brackets and quotes in pairs: style (as the editing style does: on in helix and vscode, off in vim), on or off |
auto-reload | true | Load files changed on disk into their buffers, unless they have unsaved changes |
auto-save | false | Save files on their own a moment after their edits stop |
auto-save-delay | 1000 | How long after the last edit auto-save saves, in milliseconds |
editing-style | "helix" | How editing works: helix, vim, vscode or another style a plugin adds (see :style) |
effects | false | Small animations, like a wave of light through the status line when you switch files |
effects-changes | true | Light up text someone other than you changed, like an agent or a formatter, fading out |
effects-dim | false | Dim the text of the panes you’re not in |
effects-jumps | true | Light up the line a jump lands on, briefly |
gui-font | "" | The font the window draws text in, by family name; empty for the system’s monospaced font |
gui-font-prose | "" | The proportional font the window draws prose in (styles with font = “prose”, like Markdown’s text), by family name; empty for the system’s sans-serif |
gui-font-size | 15 | The size of the window’s text in pixels, before the screen’s scale; zooming gives a window a size of its own |
gui-smooth-scroll | true | Whether the window glides a view’s text to where it scrolled, rather than jumping there |
indent | " " | One level of indent, spaces or a tab, in languages that don’t set their own |
jump-label-alphabet | "abcdefghijklmnopqrstuvwxyz" | The letters jump labels are made of, most comfortable first |
line-numbers | "absolute" | How line numbers count: “absolute”, “relative” to the cursor’s line, or “hybrid” (relative, with the cursor’s line its own number) |
link-opener | "" | What opens a link, e.g. “firefox”; empty for xdg-open, or open on macOS |
markup-reveal | "cursor" | Where hidden markup (a field’s brackets, a link’s target) shows as written outside typing: cursor, once the cursor steps inside it; never |
motion-hints | false | Number the next places a word motion would go, and go there on a digit |
notes-search-case | "ignore" | How searching notes minds case: “smart” (only when what you type has a capital letter), “ignore”, “match”, or “default” for as search-case says |
on-quit | "auto" | What :q on the last project does to the session: “auto” ends it unless something is running (a command in a terminal, an agent at work) and keeps it then, “end” always ends it, “keep” always leaves it running to attach to again |
on-quit-remote | "keep" | Like on-quit, when you’re attached over greed ssh |
project-trust | "ask" | “ask”: a project you haven’t trusted runs none of its own code (its .greed config, language servers, formatting on save) until you say so, asked once when a file of it opens; “off”: every project runs them |
scroll-margin | 5 | How many lines a view keeps in sight above and below the cursor, at most half of it (Vim’s and Helix’s scrolloff) |
search-case | "smart" | How searches you type mind case, unless their kind says otherwise: “smart” (only when what you type has a capital letter), “ignore” or “match” |
session-idle-hours | 24 | A session nothing is attached to, with nothing running and nothing unsaved, ends after this many hours; 0 keeps it |
shell-filter-search-case | "ignore" | How filtering a shell block with / minds case: “smart” (only when what you type has a capital letter), “ignore”, “match”, or “default” for as search-case says |
ssh-agent-confirm | "first" | When to ask before a program in a session from greed ssh signs with your ssh key: never, first (once each time you attach) or always |
ssh-agent-confirm-hosts | "" | ssh-agent-confirm for some machines alone, by the name of the machine the session runs on: “bastion=always devbox=never” |
substitute-search-case | "match" | How :s minds case: “smart” (only when what you type has a capital letter), “ignore”, “match”, or “default” for as search-case says |
tab-width | 4 | How many columns apart tab stops are, in languages that don’t set their own |
text-width | 80 | How wide :reflow (and Vim’s gq) makes lines |
trash | true | Deleting a file or folder moves it to the trash, where there is one on the same disk |
undo-files | true | Keep each saved file’s undo history, so undo goes on after a restart |
watch-interval | 10 | Seconds between looks at each watched object |
data
Data in documents: tables read from files and databases, shown live in
Markdown under the block that asks for them. The sources (sources.luau)
are core.data’s, so any plugin can add one and any plugin can read
one; documents draw them (document.luau).
space m n the data block's next rows; space m p the ones before
space m o its table in a float, as text (enter on the table too)
Uses: core, markdown, blocks, shell.
| Command | Keys | What it does |
|---|---|---|
data-close | esc, q (in data-row, data-table buffers) | Close the float showing a data block’s table, or a row of it |
data-open | m o (after the leader) | Open the data block at the cursor’s table in a float, as text to go through |
data-page-next | m n (after the leader) | Show the data block’s next rows |
data-page-prev | m p (after the leader) | Show the data block’s rows before these |
data-refresh | Read the data block at the cursor again | |
data-run | Let the data block at the cursor run its query, as a code block, and read it |
| Option | Default | What it does |
|---|---|---|
data-psql | "psql" | The psql program the psql data source runs |
data-sqlite3 | "sqlite3" | The sqlite3 program the sqlite data source runs |
describe
Help: describe anything the editor is made of, to see what it does, who defined it and where. In the help window, enter jumps to the definition and esc (or q) closes it.
space h h describe anything: commands, options, events, the API,
plugins and modes, in one picker
space h c a command space h o an option
space h e an event space h a a function of the API
space h p a plugin space h m a mode and its keys
space h k press a key to see what it runs
space h i inspect what's under the cursor, or the editor: an
object's state, what it relates to and what it can do
Agents get the same through the describe tool, from text.
Uses: core, picker.
| Command | Keys | What it does |
|---|---|---|
describe | h h (after the leader) | Describe anything: a command, option, event, API function, plugin or mode |
describe-api | h a (after the leader) | Describe a function or type of the plugin API |
describe-command | h c (after the leader) | Describe a command |
describe-event | h e (after the leader) | Describe an event |
describe-key | h k (after the leader) | Press keys to see what command they run |
describe-mode | h m (after the leader) | Describe a mode |
describe-object | Describe an object | |
describe-option | h o (after the leader) | Describe an option |
describe-plugin | h p (after the leader) | Describe a plugin |
describe-style | h s (after the leader) | Describe a style |
help-again | r (in help buffers) | In the inspector, look at the object again, as it is now |
help-back | alt-left, backspace, ctrl-o (in help buffers) | In the inspector, go back to the object inspected before |
help-close | Close the help window | |
help-forward | alt-right, ctrl-i (in help buffers) | In the inspector, go forward again to the object gone back from |
help-goto | enter (in help buffers) | Open the file what’s described is defined in, at its definition; in the inspector, inspect the object on this line or run its action |
inspect | h i (after the leader) | Inspect what’s under the cursor: its state, what it relates to, what it can do; with nothing there, start at the editor |
docker
Docker in the shell. docker ps’s rows are containers, in the docker
context the command ran against when it named one, to read the logs
of, open a shell in, inspect, restart or stop; the image each runs is
an object too, to inspect or pull. Containers complete the next docker
command acting on one.
Uses: core, shell.
docs
The manual, in the editor: the same Markdown pages the website is built from, shipped with Greed, so they’re the ones for the version you run.
space h d go to a page or a heading in it, from a picker of them all
space h / search the pages as you type
:docs [WORDS] the heading with those words, or the picker
Pages open read-only, in the reading view: links go to other pages, and
esc shows the Markdown. A plugin’s own docs folder joins them.
Uses: core, picker, markdown.
| Command | Keys | What it does |
|---|---|---|
docs | h d (after the leader) | Read the manual: go to the heading with these words, or pick one of them all |
docs-search | h / (after the leader) | Search the manual and plugins’ docs as you type, and go to what’s found |
flash
Flashes text as it’s copied, so you can see what went to the clipboard.
With a “#rrggbb” background for “ui.flash” in the theme it fades out; with the 16 terminal colors it shows briefly and goes. Either way it’s a decoration and a theme entry changing over time, which is all an animation is.
To change how long it lasts, set “flash-duration” from your config:
require("@greed").option.set("flash-duration", 150)
Uses: core.
| Option | Default | What it does |
|---|---|---|
flash-duration | 300 | How long copied text flashes, in milliseconds |
folders
Folders as text you edit: space - (or :folder) shows the folder of
the file you’re in as a buffer with a line per file and folder. Rename
by editing a name, with any style’s keys (Helix’s s and c rename
many at once); make a file by adding a line, a folder by ending it in
/, and a file in a new folder with a/b.txt; delete by deleting the
line. Move a file by cutting its line in one folder’s buffer and pasting
it in another’s; pasting it while it’s still in the first copies it.
Saving says what it will do and does it once you press y, for every
folder buffer at once; :folder-undo takes that back. Deleting goes to
the trash where there is one (see core.file.remove).
In a folder’s buffer, enter opens the file or folder on the line and
- goes up to the folder above. Each line starts with a hidden number
that says which file it was, so a renamed line is a rename, not a
delete and a new file.
Uses: core.
| Command | Keys | What it does |
|---|---|---|
folder | - (after the leader) | Show a folder as a buffer you edit to rename, make, move and delete files: this file’s, or the one given |
folder-open | enter (every style’s command mode; in folder buffers) | Open the file or folder on the cursor’s line of a folder’s buffer |
folder-undo | Take back what the last save of folder buffers did | |
folder-up | - (every style’s command mode; in folder buffers) | Show the folder above in a folder’s buffer |
| Option | Default | What it does |
|---|---|---|
folder-hidden | false | Show hidden files and folders in a folder’s buffer |
format
Formatting: :format, and on every save unless format-on-save is off.
A language’s formatter program (see the languages plugin) is used when
it’s installed; otherwise the language server is asked. Only what changed
is replaced, so the cursor and selections stay where they were.
To stop formatting on save:
require("@greed").option.set("format-on-save", false)
Uses: core, languages.
| Command | Keys | What it does |
|---|---|---|
format | = (helix’s command mode) | Format the buffer with its language’s formatter or language server |
| Option | Default | What it does |
|---|---|---|
format-on-save | true | Format files when they’re saved |
git-plugins
Plugins from git: say which in your config, and Greed fetches them into
its data folder and pins each to a commit in a lock file next to your
config, plugins.lock, so another machine gets the same ones. Put the
lines in init.luau or in a file you require from it:
local plugins = require("@git-plugins")
plugins.use("https://github.com/someone/greed-jump")
plugins.use("https://github.com/someone/greed-todo", { ref = "v2", name = "todo" })
Saying so only records it: nothing is fetched while the config runs, so
starting never waits on the network. Missing plugins are fetched in the
background once the editor is up, or with :plugins-sync, at the commit
the lock file says, or the latest of ref for one that’s new there.
:plugins-update [NAME] fetches the latest of each ref and writes the
lock file again. Taking a line out of your config and running
:plugins-sync removes that plugin (to the trash where there is one) and
its pin. A plugin fetched loads like any of yours: one asking
for capabilities waits for your approval (:plugins-approve), and so
does an update asking for more.
Uses: core, approvals.
| Command | Keys | What it does |
|---|---|---|
plugins-sync | Fetch the plugins your config says to use from git that aren’t here yet, at the lock file’s commits, and remove those it no longer uses | |
plugins-update | Take the plugins from git (or the one named) to the latest of what each follows, and pin that |
| Option | Default | What it does |
|---|---|---|
plugins-lock | "" | The lock file pinning plugins from git to commits; empty for plugins.lock in your config’s folder |
grep
Search the whole project, and replace by editing what was found.
space / search the project for a regex as you type
space L the same in this buffer, unsaved changes included
ctrl-e in that picker: put the matches in a results panel
:grep PATTERN DIR? put the matches in a results panel straight away
The results panel is a multibuffer: each matching line under its file’s name. Edit the lines with anything (s to select the matches and c to change them all works well) and the files change as you type; :w saves them, enter opens the match under the cursor, and q closes the panel.
Patterns are regexes; ones in lowercase ignore case. The project is the folder holding .jj or .git (see core’s project.luau).
Uses: picker, multibuffer.
| Command | Keys | What it does |
|---|---|---|
grep | Put the lines matching a regex in a panel, to go to them or edit them | |
grep-close | Close the search results | |
search-buffer | L (after the leader) | Search this buffer for a regex as you type, listing the lines that match |
search-project | / (after the leader) | Search the project for a regex as you type, and go to a match |
guides
Indent guides: a thin line at each level of indent, so you can see the
lines a block holds. Blank lines inside a block get them too. :set indent-guides false turns them off; their style is “ui.indent.guide”.
Rulers, at the columns the rulers option names, go the same way: where
nothing is written at their column, in “ui.ruler”.
Both are drawn over the text (overlay), past a line’s end too, so
neither moves the cursor or what you type.
Uses: core.
| Option | Default | What it does |
|---|---|---|
indent-guides | true | Show a line at each level of indent |
rulers | "" | Columns to show a ruler at, counted from 1, like “80,100”; empty for none |
helix
Helix’s editing style, the default: select text, then say what to do with
it. Its modes are helix (normal), helix-insert and helix-select;
the status line shows them as NORMAL, INSERT and SELECT. The commands
are core’s; this plugin gives them Helix’s keys. Copy any part of it
into your own config to change it.
Uses: core.
| Command | Keys | What it does |
|---|---|---|
select-mode | v (helix, helix-select), esc (helix-select) | Start select mode, where moves extend the selection, or leave it |
hints
Key hints: after a key that starts longer sequences, like “space”, show
what can come next and what each key does. f1 shows the keys of the mode
you’re in, and the first time you’re in a mode listed in intro (like
typing into a terminal), a line in the status line says how to get out.
Uses: core.
| Command | Keys | What it does |
|---|---|---|
keys-help | f1 (global, pane, resize, tab, terminal) | Show the keys of the mode you’re in and what each does |
hoard
Hoard: your notes, todos and today, for anyone, not only programmers.
greed notes goes to it in the session of the hoard service, which opens
your notes folder on its home: search, adding a todo or a thought to
today’s note, today’s note, the agenda with boxes to tick, the inbox and
recent notes (home.luau). Editing there is modeless, with VS Code’s keys
(hoard-editing-style changes that), notes save on their own and have no
line numbers, and language servers leave them alone. That session starts
with Greed when you have notes, and it’s the one that sets off reminders
and runs the agent’s scheduled jobs, once for all sessions.
:hoard (space n h) goes to Hoard from any session, starting it if
needed, and :hoard-window (space n H) opens it in a window of its own.
Uses: core, notes, statusline, picker, service.
| Command | Keys | What it does |
|---|---|---|
hoard | n h (after the leader) | Go to Hoard (your notes, todos and today), starting it if needed; in Hoard, its home |
hoard-add | alt-enter, ctrl-enter (in hoard buffers) | Add what’s written in the home’s box to today’s note: lines starting [] as todos; starting with ?, ask your notes |
hoard-agenda | Open the agenda note: what’s due, as queries you can change | |
hoard-box | esc (every style’s typing mode; in hoard buffers) | On the home: back to the end of the box to write in |
hoard-down | down (every style’s typing mode; in hoard buffers) | On the home: down a line in the box, or to the next thing to open or press, and past the last back to the box |
hoard-enter | enter (every style’s typing mode; in hoard buffers) | On the home: a new line in the box, or else open or press what the cursor is on |
hoard-escape | esc (vscode’s typing mode; in file buffers) | In Hoard: let go of the selection, or zoom out of a list item or section, or else go back to the home |
hoard-review | n w (after the leader) | Look back at the week: what was done, what’s overdue, coming and waiting, the inbox and what was written, in a note of its own |
hoard-schedule | alt-d (every style’s typing mode; in hoard buffers) | On the home: say when the todo on the agenda the cursor is on is due; in the box, delete the next word as usual |
hoard-tab | tab (every style’s typing mode; in hoard buffers) | On the home: the next place of a snippet being filled in, or the next thing to open |
hoard-tab-back | shift-tab (every style’s typing mode; in hoard buffers) | On the home: the place of a snippet before, or the thing to open before |
hoard-up | up (every style’s typing mode; in hoard buffers) | On the home: up a line in the box, from its first line to the nearest thing above to open or press, and from there to the one before |
hoard-window | n H (after the leader) | Open Hoard in a window of its own, staying here; in a terminal, go to it |
| Option | Default | What it does |
|---|---|---|
hoard-editing-style | "vscode" | The editing style in Hoard: “vscode” types as soon as a key is pressed, without modes; “same” keeps the one the rest of Greed uses |
hoard-language-servers | false | Run Markdown’s language servers (spelling, grammar) on notes in Hoard |
hosts
Connecting to another machine from inside Greed: space C (:connect)
lists the hosts you connected to lately and those in ~/.ssh/config, and
going to one shows its session here, as greed ssh HOST would, starting
one there if none is running. Typing a host that isn’t listed connects
to it too.
Uses: core, picker.
| Command | Keys | What it does |
|---|---|---|
connect | C (after the leader) | Show a session on another machine here, as greed ssh does: pick a host, or type one |
hub
The hub: one session on the machine follows all the others, so every
session can say what waits elsewhere and go there, and one place decides
what to tell you. The hub is a role, not a process: among the running
sessions of this greed’s build, the one hub-session names, or else the
first by name. Each session works it out again as sessions come and go,
so when the hub ends another takes over.
The hub follows each other session with greed ctl watch and adds what
they say to its own status (machine); the others follow only the hub.
Every message is a whole status, so a missed one only means a later look.
Hubs follow hubs: the machines you reached with greed ssh lately, and
the hosts in hub-hosts, are other machines whose hubs this one follows
over ssh (greed ssh HOST ctl watch --hub), and what they say of the
machines they know comes along (machines). There’s no
main hub: every entry names the machine it’s about, a hub ignores news
of its own machine, and of each other machine it keeps what it heard
itself, else the freshest, so loops die out.
space i A the agents of every session you can reach: enter goes there,
ctrl-a answers or stops one where it runs
Uses: core, agent, picker, statusline.
| Command | Keys | What it does |
|---|---|---|
machine | i A (after the leader) | The agents of every other session, here and on the machines the hub follows: enter goes there, ctrl-a answers or stops it (space i A) |
machine-forget | Stop following a machine you reached with greed ssh, until you do again |
| Option | Default | What it does |
|---|---|---|
hub-hosts | "" | More machines whose hubs this machine’s hub follows, beside the ones you reached with greed ssh lately, as ssh hosts separated by spaces, like “eris mini” |
hub-session | "" | The session that follows the others on this machine; empty for the first running one by name |
image
Image files open as the image: PNG, JPEG and GIF, drawn as wide as the view at most (in the window, and in terminals that show images), under a line with its name, size and zoom.
+ - bigger, smaller
= as wide as the view, or its own size when it's smaller
0 its own size
Uses: core.
| Command | Keys | What it does |
|---|---|---|
image-zoom-actual | 0 (in image buffers) | Draw the image at its own size |
image-zoom-fit | = (in image buffers) | Draw the image as wide as the view, or at its own size when it’s smaller |
image-zoom-in | + (in image buffers) | Draw the image bigger |
image-zoom-out | - (in image buffers) | Draw the image smaller |
kubernetes
Kubernetes in the shell. The prompt shows the context and namespace
kubectl would use, read from its config without running it, in red
when the context is a production one (shell-production-contexts).
kubectl get’s rows are pods, deployments and other objects, in the
context and namespace the command ran against, to describe, read the
logs of, open a shell in, restart or delete; and they complete the
next kubectl command. space o k and space o K switch the context and
namespace, everywhere or in one shell. On a kubectl get block,
space . shows another resource or namespace in its place, live if it
was.
Uses: core, shell, picker, terminal.
| Command | Keys | What it does |
|---|---|---|
kube-context | o k (after the leader) | Switch kubectl’s context, everywhere or in this shell only; with a name, to that one |
kube-namespace | o K (after the leader) | Switch the namespace of kubectl’s context, everywhere or in this shell only; with a name, to that one |
languages
Languages, batteries included: which files are in which language, their
language servers and how they’re commented and indented. The table is in
languages.luau. A server only starts if it’s installed, so nothing needs
setting up; :health shows what’s found and what’s missing.
Change an entry from your config. Fields you give replace those fields:
local languages = require("@languages")
languages.set("python", { servers = { { "pylsp" } } })
languages.set("odin", { extensions = { "odin" }, servers = { { "ols" } } })
Uses: core, cmdline.
| Command | Keys | What it does |
|---|---|---|
grammar-fetch | Download a grammar Greed knows where to get, ahead of opening a file in it | |
health | Show each language’s highlighting and servers, and which are installed | |
language | Set this buffer’s language, for its highlighting, indent and language server; with none, say which it has |
| Option | Default | What it does |
|---|---|---|
grammar-download | true | Download the grammar for a language Greed has none for when a file in it opens |
lsp
Language servers: hover, definitions, references, rename, code actions
and diagnostics. Lines with problems get a sign, and the worst problem’s
message shows after the line (turn that off with
:set diagnostic-messages false).
space k show what's under the cursor, with any problems there
g d go to the definition
g r pick a place it's used
space r rename it everywhere
space a pick a fix or refactor
space d pick a problem in this file
space D pick a problem in any file
] d / [ d next / previous problem
Servers start the first time a file of their language is open, if one is
installed; the languages plugin says which (see :health).
Uses: core, markdown, picker, multibuffer, statusline.
| Command | Keys | What it does |
|---|---|---|
code-action | Pick a fix or refactor for the cursor or the selection | |
completion-accept | enter (completion-helix-insert, completion-vim-insert, completion-vscode; in agent-transcript, file, hoard, mail-compose, search-box, shell buffers) | Put the current completion in place of the word being typed; with none chosen, close the menu and do what enter does |
completion-ask | ctrl-x (helix’s typing mode), tab (every style’s typing mode; in search-box, shell buffers), ctrl-space (every style’s typing mode) | Ask what could go at the cursor: a source like the shell’s, or the language server |
completion-close | esc (completion-helix-insert, completion-vim-insert, completion-vscode; in agent-transcript, file, hoard, mail-compose, search-box, shell buffers) | Close the completion menu and do what esc does where you were typing |
completion-down | down (completion-helix-insert, completion-vim-insert, completion-vscode; in agent-transcript, file, hoard, mail-compose, search-box, shell buffers) | Move to the next completion, or in a shell’s menu that opened by itself, the command after |
completion-next | ctrl-n (completion-helix-insert, completion-vim-insert, completion-vscode; in agent-transcript, file, hoard, mail-compose, search-box, shell buffers) | Move to the next completion |
completion-prev | ctrl-p, shift-tab (completion-helix-insert, completion-vim-insert, completion-vscode; in agent-transcript, file, hoard, mail-compose, search-box, shell buffers) | Move to the previous completion |
completion-tab | tab (completion-helix-insert, completion-vim-insert, completion-vscode; in agent-transcript, file, hoard, mail-compose, search-box, shell buffers) | Move to the next completion; where tab completes in place, as in a shell, first put in what every match starts with |
completion-up | up (completion-helix-insert, completion-vim-insert, completion-vscode; in agent-transcript, file, hoard, mail-compose, search-box, shell buffers) | Move to the previous completion, or in a shell’s menu that opened by itself, the command before |
completion-words | ctrl-n (vim-insert) | Complete the word being typed from words in open files |
completion-words-back | ctrl-p (vim-insert) | Complete the word being typed from words in open files, starting with the last |
first-diagnostic | [ D (every style’s command mode) | Go to the first problem in this file |
goto-declaration | g D (every style’s command mode) | Go to where the thing under the cursor is declared |
goto-implementation | g i (every style’s command mode), g r i (vim) | Go to where the thing under the cursor is implemented |
goto-references | g r (every style’s command mode), g r r (vim), shift-f12 (vscode) | Pick a place where the thing under the cursor is used, and go there |
goto-type-definition | g y (every style’s command mode), g r t (vim) | Go to where the type of the thing under the cursor is defined |
last-diagnostic | ] D (every style’s command mode) | Go to the last problem in this file |
lsp-restart | Start this file’s language server again, as when it’s stuck; with all, every server | |
next-diagnostic | ] d (every style’s command mode), f8 (vscode) | Go to the next problem in this file |
pick-diagnostic | d (after the leader) | Pick a problem in this file and go to it |
pick-problem | D (after the leader), ctrl-M (vscode) | Pick a problem in any file, open or not, and go to it |
pick-workspace-symbol | S (after the leader), ctrl-t (vscode) | Pick a function, type or other symbol anywhere in the project, as the language server knows them; with a kind, only those |
prev-diagnostic | [ d (every style’s command mode), shift-f8 (vscode) | Go to the previous problem in this file |
rename | r (after the leader), g r n (vim), f2 (vscode) | Rename the thing under the cursor everywhere it’s used |
select-references | H (after the leader) | Select every place in this file where the thing under the cursor is used |
signature-help | While typing, show what the function being called takes |
| Option | Default | What it does |
|---|---|---|
completion-delay | 150 | Milliseconds of no typing before a completion menu opens by itself; 0 opens it only when asked |
completion-enter | "auto" | What enter does in a completion menu: “first” puts in the first item, “selected” only one moved to with tab or the arrows (otherwise enter does what it does without a menu, like running a shell’s line), “auto” lets each source say: the shell “selected”, language servers “first” |
diagnostic-messages | true | Show each line’s worst problem after the end of the line |
Mail: your mail searched and read in Greed. In the mail session
(greed mail) the page shows what a search finds, newest first, with
the search box over it (in:inbox to start); elsewhere :mail opens the
same list in a float for a quick look. enter reads a thread, /
searches again, $ syncs now, q goes back or closes; u marks read
or unread, s flags, t tags, T makes a todo, e archives and
d trashes; r replies, a replies to all and c writes new mail,
which :mail-send sends.
greed-mail syncs the accounts in mail.toml and keeps the index this
searches (backend.luau); a search is the query language anywhere in
Greed: from:anna is:unread date:2w.. in:work invoice.
Uses: core, notes, picker, panes, service.
| Command | Keys | What it does |
|---|---|---|
mail | Search and read your mail: on the page in the mail session, a quick look elsewhere | |
mail-archive | e (in mail, mail-thread buffers) | Move the message (or the thread being read) to the archive |
mail-attach | Attach a file to the mail being written | |
mail-browser | b (in mail, mail-thread buffers) | Show the message in a web browser as it was sent, loading nothing from anywhere |
mail-close | Go back from a thread to the list, or close a quick look at mail | |
mail-compose | c (in mail, mail-thread buffers) | Write new mail |
mail-drafts | Pick a draft to go on writing; alt-. on one discards it | |
mail-from | Pick which of your addresses the mail being written is from, with its signature | |
mail-open-all | o (in mail-thread buffers) | Show all of the thread: every message opened and every quote, or folded again |
mail-plain | h (in mail-thread buffers) | Read the thread as its messages’ text, or laid out from their HTML again |
mail-read | enter (in mail buffers) | Read the thread of the message under the cursor |
mail-reply | r (in mail, mail-thread buffers) | Reply to the message (or the thread being read), quoting it |
mail-reply-all | a (in mail, mail-thread buffers) | Reply to everyone the message (or the thread being read) went to |
mail-rule-run | Run a mail rule over all the mail it finds, asking first | |
mail-rule-try | Show what a mail rule finds in the mail you have, changing nothing | |
mail-save-attachment | S (in mail-thread buffers) | Save what’s attached under the cursor (or the thread’s only attachment) where you say |
mail-search | / (in mail buffers) | Search the mail in the list again |
mail-search-1 | alt-1 (in mail buffers) | Show what saved search 1 finds (require(“@mail”).searches) |
mail-search-2 | alt-2 (in mail buffers) | Show what saved search 2 finds (require(“@mail”).searches) |
mail-search-3 | alt-3 (in mail buffers) | Show what saved search 3 finds (require(“@mail”).searches) |
mail-search-4 | alt-4 (in mail buffers) | Show what saved search 4 finds (require(“@mail”).searches) |
mail-search-5 | alt-5 (in mail buffers) | Show what saved search 5 finds (require(“@mail”).searches) |
mail-search-6 | alt-6 (in mail buffers) | Show what saved search 6 finds (require(“@mail”).searches) |
mail-search-7 | alt-7 (in mail buffers) | Show what saved search 7 finds (require(“@mail”).searches) |
mail-search-8 | alt-8 (in mail buffers) | Show what saved search 8 finds (require(“@mail”).searches) |
mail-search-9 | alt-9 (in mail buffers) | Show what saved search 9 finds (require(“@mail”).searches) |
mail-search-next | tab (in mail buffers) | Show what the next saved search finds |
mail-search-previous | shift-tab (in mail buffers) | Show what the saved search before finds |
mail-searches | g s (in mail buffers) | Pick a saved search to show, however many there are, with how many unread each finds |
mail-send | alt-enter, ctrl-enter (in mail-compose buffers) | Send the mail being written |
mail-session | Go to the mail session, starting it if needed: it syncs your mail | |
mail-sync | $ (in mail buffers) | Sync your mail now |
mail-tag | t (in mail, mail-thread buffers) | Tag the message (or the thread being read), or take the tag off if it has it |
mail-todo | T (in mail, mail-thread buffers) | Add a todo about the message (or the thread being read) to your inbox note, linking back to it |
mail-toggle-flag | s (in mail, mail-thread buffers) | Flag the message (or the thread being read), or take its flag off |
mail-toggle-read | u (in mail, mail-thread buffers) | Mark the message (or the thread being read) read, or unread if it’s read |
mail-trash | #, d (in mail, mail-thread buffers) | Move the message (or the thread being read) to the trash; in the trash, delete it for good |
mail-undo | z (in mail, mail-thread buffers) | Undo the last change to your mail, or take back the mail just sent while it waits |
| Option | Default | What it does |
|---|---|---|
mail-markdown | true | Whether mail you write is Markdown, sent as what you wrote and the HTML it makes; off sends plain text alone |
mail-program | "" | The greed-mail program that syncs your mail, its name on PATH or a path; empty for the one beside greed, or else on PATH |
mail-threads | true | Whether a mail list shows each thread once, as its newest message found, rather than every message |
markdown
Markdown as a document: headings without their hashes (the top level
twice the size), bold, italic, struck and code without their
markers, links as their text, fenced code on a background of its own,
quotes with a bar, --- as a line, list dashes as bullets and tables in
columns with borders (tables.luau). The file stays plain Markdown:
typing on a line shows it as written (see core.reveal). Turn it off
with :set markdown-look false, or for one file with
markdown-look-toggle. tab folds the section, list item or code block
around the cursor (folds.luau).
The reading view (markdown-read) shows the file read-only with no
markup at all, images in place and links to follow (links.luau), in the
“read” mode; esc goes back to editing at the same place.
Other plugins can draw some parts their own way: notes draws headings and
bullets as symbols, and claims them with require("@markdown").claim.
Uses: core.
| Command | Keys | What it does |
|---|---|---|
choice-pick | Pick the choice under the cursor, unpicking the others in its group | |
markdown-cell-edit | m t e (after the leader) | Type the text of the Markdown table cell at the cursor, or the formula filling its column |
markdown-cell-next | alt-l (every style’s command mode, vscode’s typing mode) | Go to the next cell of a Markdown table; elsewhere, what the key does otherwise |
markdown-cell-prev | alt-h (every style’s command mode, vscode’s typing mode) | Go to the cell before in a Markdown table; elsewhere, what the key does otherwise |
markdown-field-make | m f (after the leader) | Make what’s selected, or the number or word at the cursor, a field named as you type; on a field, rename it |
markdown-field-set | Set the value of the field at the cursor, value in Markdown | |
markdown-follow | Follow the Markdown link under the cursor: to a heading, another file or a web page | |
markdown-look-toggle | m l (after the leader), alt-V (vscode’s typing mode) | Show this Markdown file as a document or as written, whatever markdown-look says |
markdown-read | m v (after the leader), alt-v (read, vscode’s typing mode), esc, q, space m v (read) | Read this Markdown file as a document, with images and links to follow; again or esc to edit |
markdown-table-align | m t = (after the leader) | Line up a Markdown table’s pipes |
markdown-table-column-add | m t c (after the leader) | Add a column right of the cursor’s, in a Markdown table |
markdown-table-column-add-left | m t C (after the leader) | Add a column left of the cursor’s, in a Markdown table |
markdown-table-column-delete | m t D (after the leader) | Delete the cursor’s column of a Markdown table |
markdown-table-column-left | m t h (after the leader) | Move the cursor’s column of a Markdown table left |
markdown-table-column-right | m t l (after the leader) | Move the cursor’s column of a Markdown table right |
markdown-table-row-add | m t o (after the leader) | Add a row under the cursor’s, in a Markdown table |
markdown-table-row-add-above | m t O (after the leader) | Add a row above the cursor’s, in a Markdown table |
markdown-table-row-delete | m t d (after the leader) | Delete the cursor’s row of a Markdown table |
markdown-table-row-down | m t j (after the leader) | Move the cursor’s row of a Markdown table down |
markdown-table-row-up | m t k (after the leader) | Move the cursor’s row of a Markdown table up |
markdown-table-sort | m t s (after the leader) | Sort a Markdown table’s rows by the cursor’s column |
markdown-table-sort-descending | m t S (after the leader) | Sort a Markdown table’s rows by the cursor’s column, largest first |
| Option | Default | What it does |
|---|---|---|
markdown-look | true | Show Markdown with its markup hidden and its headings, code and quotes drawn as such |
models
Language models by role. Plugins ask for a role, like “fast” or “reasoning”, and your config says which provider and model plays it, so no plugin hard-codes a provider and switching to a local model is one line.
:models each role's provider and model and whether its key is found;
enter changes a role, e its effort, k sets a key, l signs in
What you pick in :models (or the setup page) is kept in Greed’s data folder and read before your config, which has the last word.
In your config:
local models = require("@models")
models.roles.fast = { provider = "ollama", model = "llama3.2" }
models.providers.work = { kind = "openai", url = "https://llm.example.com/v1", secret = "work" }
Keys come from greed.secrets (:models, :secret-set anthropic, or
ANTHROPIC_API_KEY).
Uses: core, picker.
| Command | Keys | What it does |
|---|---|---|
login | Sign in to a provider: with an account for those whose plan comes with one, like Berget Code or Mistral’s Vibe, or else its API key | |
logout | Forget the sign-in kept for a provider | |
models | Show and change which model plays each role, set API keys and sign in | |
models-change | On the :models page, pick the provider and model that play the role under the cursor | |
models-close | Close the :models page | |
models-effort | On the :models page, pick how hard the model of the role under the cursor thinks | |
models-key | On the :models page, set the API key of the provider of the role under the cursor | |
models-login | On the :models page, sign in to the provider of the role under the cursor | |
usage | How many tokens the models were sent and wrote today and over the last week |
| Option | Default | What it does |
|---|---|---|
models-idle-timeout | 90 | Seconds a model’s answer may go quiet before its request counts as failed and is tried again; the first bytes get three times as long. 0 waits for ever |
multibuffer
Multibuffers: one buffer made of excerpts from many files, edited in place. Typing in an excerpt edits its file as you go (the file opens in Greed the first time one of its excerpts changes), and a change made to the file anywhere else shows in the excerpt. :w saves every file changed this way, enter goes to the line under the cursor and q closes the view.
Search results open in one. A plugin makes its own with
require("@multibuffer").open({ { path = "/src/main.rs", from = 9, to = 12 } },
{ summary = "1 place" })
Each file’s name shows above its excerpts and its line numbers beside them; neither is text you can edit. Excerpts that overlap or touch are joined.
Uses: core.
| Command | Keys | What it does |
|---|---|---|
multibuffer-close | q (in why buffers) | Close the view showing the multibuffer |
multibuffer-open | enter (every style’s command mode; in multibuffer buffers) | Go to the line under the cursor in its file |
multibuffer-revert | g r (after the leader; in multibuffer buffers) | Put the change under the cursor back the way it was, in a view of changes |
notes
Notes: a folder of plain Markdown files, linked with [[note]], with todos and an agenda. It’s only files, so git or Syncthing can carry them to other machines and a phone.
space n d today's note space n f find a note
space n c capture a todo space n / search the notes
space n a the agenda: open todos, soonest due first
space n x tick a todo, or untick it
space n t jot a thought down in the inbox
space n r dismiss the reminders notice
space n l have Greed's agent link the inbox to your other notes
space n j pick another job for the agent (jobs.luau)
space n k link to a heading, list item or block in a note
space n n a new note from a template (types.luau)
space n y give this note a template's fields
space k on a due date or a reminder, say when it is in words
g d follow the [[link]] under the cursor (making the note)
tab, z a fold the section, list item or code block under the cursor,
or unfold it (Markdown's folds)
In notes (Markdown files in the notes folder, or every Markdown file with
notes-everywhere), links show without their brackets, markup shows as
symbols (look.luau), and each note lists the notes linking to it at its
end. Todos and lines can carry reminders (reminders.luau).
local greed = require("@greed")
greed.option.set("notes-folder", "~/Documents/notes")
Uses: core, picker, agent, markdown, statusline, acp, image, service.
| Command | Keys | What it does |
|---|---|---|
notes-agenda | n a (after the leader) | Pick from the open todos in every note, soonest due first |
notes-agent | n j (after the leader) | Pick a job for Greed’s agent on your notes: connect them, pull out todos, ask them |
notes-ask | Ask your notes a question: Greed’s agent answers from them, linking what it used | |
notes-capture | n c (after the leader) | Add a todo to the inbox note, from wherever you are: the project’s when it keeps notes |
notes-capture-mine | Add a todo to your own inbox note, even in a project that keeps notes | |
notes-connect | n l (after the leader) | Have Greed’s agent go through the inbox (or the note you’re in), link it to your other notes and add context, as changes you review |
notes-daily | n d (after the leader) | Open today’s note, making it if there isn’t one |
notes-find | n f (after the leader) | Open a note by name, or pick one |
notes-link | n k (after the leader) | Link to a heading, a list item or a block in a note, picked from all of them |
notes-new | n n (after the leader) | Make a note from a template: pick one, then name the note |
notes-reminder-open | Open the first reminder in the notice, and close the notice | |
notes-reminders-dismiss | n r (after the leader) | Close the reminders notice |
notes-search | n / (after the leader) | Search every note as you type |
notes-tag-rename | Rename a tag in every note, with the tags under it | |
notes-thought | n t (after the leader) | Jot a thought or an idea down in the inbox note, with today’s date, from wherever you are |
notes-type | n y (after the leader) | Give this note a template’s fields, those it doesn’t have yet |
todo-toggle | n x (after the leader) | Tick the todo on each selected line, or untick it; a plain line becomes a todo |
| Option | Default | What it does |
|---|---|---|
notes-agent-schedule | "" | Jobs Greed’s agent runs on its own, as JOB DAY HH:MM separated by commas, e.g. week friday 16:00, connect weekdays 08:00; DAY is daily, weekdays or a weekday’s name. Empty runs none |
notes-conceal | true | Show links in notes without their brackets, and markup as symbols |
notes-everywhere | false | Treat every Markdown file as a note: concealed links and backlinks |
notes-folder | "~/notes" | The folder notes live in; ~ is your home folder |
notes-project-folder | ".greed/notes" | Where a project keeps its notes, in the project: they’re named project:NAME, and the plan and decisions you share with agents are among them |
notes-remind-desktop | true | Show reminders as desktop notifications with notify-send or osascript, where installed |
notes-remind-time | "09:00" | When a reminder with a date and no time goes off, as HH:MM |
operations
Operations: work across files taken as one thing. An operation groups the edits it makes in every buffer and the programs it runs, so you can review it in one view and undo it in one step.
space u o recent operations, to review one
space u u undo the latest operation (in a review, that one)
In a review, space g r puts back the change under the cursor.
A plugin or agent makes one with
local operations = require("@operations")
operations.run("rename parse to parse_line", function(op)
-- edit buffers, then
operations.exec(op, { "cargo", "test" })
end)
Uses: core, picker, multibuffer.
| Command | Keys | What it does |
|---|---|---|
operation-undo | u u (after the leader) | Undo the latest operation, or the one being reviewed, in every file at once |
operations | u o (after the leader) | Pick a recent operation to review: its changes across files and the programs it ran |
panes
Panes and tabs, the way a terminal multiplexer has them: split the screen between files and terminals, move between them, give a pane more room, keep tabs of layouts (arranged by the layout managers in layouts.luau). The keys follow zellij’s where they can:
- alt keys work everywhere, in every editing style and in terminals:
alt-h/j/k/l move between panes (and to the next tab at the edge),
alt-n opens a terminal pane (a floating one while floats are shown),
alt-f shows or hides the tab's floating views (opening a floating
terminal when there are none), alt-F floats this file, alt-= and
alt-- resize, alt-< and alt-> (alt-[ and alt-] too) or alt-1..9
change tabs. alt-w changes how the tab lays out its floats (see
floats.luau), alt-{ and alt-} cycle through them and alt-W picks one
from the dock.
- alt-p and alt-t open the pane and tab modes, where single keys act until
esc.
- In normal mode, ctrl-w (and the leader’s w) is the window prefix Vim and Helix
users know, and in Vim, g t and g T change tabs.
Every key is in M.keys; rebind or unbind them from your config like any
other (see the keys docs).
Uses: core, picker, terminal, statusline.
| Command | Keys | What it does |
|---|---|---|
float-dock | Show the dock of this tab’s floating views, or hide it | |
float-dock-pick | alt-W (global, terminal) | Pick a floating view from the dock: 1 to 9, or the arrows and enter |
float-file | alt-F (global, terminal), E (pane) | Open a file (this one if none is given) in a new floating view |
float-flip | F, e (pane) | Take this pane out to float over the tab, or put a floating view back in as a pane |
float-go | Bring this tab’s floating view number N to the front, as the dots on its border count | |
float-layout-next | alt-w (global, terminal) | Lay this tab’s floating views out with the next float layout |
float-layout-pick | Y (pane) | Pick how this tab lays out its floating views |
float-move-down | down (resize) | Move the floating view down |
float-move-left | left (resize) | Move the floating view left |
float-move-right | right (resize) | Move the floating view right |
float-move-up | up (resize) | Move the floating view up |
float-next | alt-} (global, terminal), } (pane) | Bring the next floating view in this tab to the front |
float-previous | alt-{ (global, terminal), { (pane) | Bring the floating view before in this tab to the front |
float-terminal-new | W (pane) | Open another floating terminal in this tab |
floats-cascade | C (pane) | Stack this tab’s floating views in a cascade, from now on |
floats-one | O (pane) | Show this tab’s floating views one at a time, like tabs, all in the same place, from now on |
floats-tile | T (pane) | Lay this tab’s floating views out side by side, from now on |
floats-toggle | alt-f (global, terminal), w, z (pane) | Hide this tab’s floating views or show them again; with none, open a floating terminal |
layout-main-grow | ] (pane) | Give the main pane more room |
layout-main-shrink | [ (pane) | Give the main pane less room |
layout-next | alt-space (global, terminal), space (pane) | Arrange this tab with the next layout |
layout-open | Open a saved layout as a new tab | |
layout-pick | y (pane) | Pick how this tab arranges its panes |
layout-rotate | o (pane) | Move every pane one place along |
layout-save | Save this tab’s panes, and what they show, as a layout of the project | |
layout-save-mine | Save this tab’s panes, and what they show, as a layout for any project | |
layout-swap-main | alt-m (global, terminal), m (pane) | Swap this pane with the main one |
pane-close | w c, w q (after the leader), ctrl-w c, ctrl-w q (every style’s command mode) | Close this pane |
pane-close-done | x (pane) | pane-close, then back from the mode |
pane-down | alt-down, alt-j (global, terminal), w j (after the leader), down, j (pane), ctrl-w j (every style’s command mode) | Move to the pane below |
pane-file-down | w f (after the leader), ctrl-w f (every style’s command mode) | Open the file named under the cursor in a pane below |
pane-file-right | w F (after the leader), ctrl-w F (every style’s command mode) | Open the file named under the cursor in a pane on the right |
pane-grow | alt-+, alt-= (global, terminal), +, = (pane, resize) | Give this pane more room |
pane-left | alt-h, alt-left (global, terminal), w h (after the leader), h, left (pane), ctrl-w h (every style’s command mode) | Move to the pane on the left, or the tab before |
pane-mode | alt-p (global, terminal) | Keys for panes until esc: move, split, resize, close |
pane-mode-leave | alt-p (pane), enter, esc (pane, resize, tab), alt-r (resize), alt-t (tab) | Back from the pane or tab mode |
pane-new-down | w n s (after the leader), ctrl-w n s (every style’s command mode) | Open a pane below with a new, empty buffer |
pane-new-right | w n v (after the leader), ctrl-w n v (every style’s command mode) | Open a pane on the right with a new, empty buffer |
pane-next | w w (after the leader), tab (pane), ctrl-w w (every style’s command mode) | Move to the next pane |
pane-only | w o (after the leader), ctrl-w o (every style’s command mode) | Close every other pane in the tab |
pane-pick | w g (after the leader), g (pane), ctrl-w g (every style’s command mode) | Label the panes and go to the one whose label you type next; esc leaves the pane mode |
pane-place | p (pane) | Show where a new pane would go, to move it and open it there |
pane-place-cancel | esc (pane-place) | Put things back without a new pane |
pane-place-down | down, j (pane-place) | Move the new pane’s frame down |
pane-place-here | enter (pane-place) | Open a pane with this file where the frame is |
pane-place-left | h, left (pane-place) | Move the new pane’s frame left |
pane-place-right | l, right (pane-place) | Move the new pane’s frame right |
pane-place-terminal | t (pane-place) | Open a terminal where the frame is |
pane-place-up | k, up (pane-place) | Move the new pane’s frame up |
pane-resize-down | J (pane), j (resize) | Make this pane bigger by moving its bottom edge down, or the other edge at the screen’s edge |
pane-resize-left | H (pane), h (resize) | Make this pane bigger by moving its left edge out, or the other edge at the screen’s edge |
pane-resize-right | L (pane), l (resize) | Make this pane bigger by moving its right edge out, or the other edge at the screen’s edge |
pane-resize-up | K (pane), k (resize) | Make this pane bigger by moving its top edge up, or the other edge at the screen’s edge |
pane-right | alt-l, alt-right (global, terminal), w l (after the leader), l, right (pane), ctrl-w l (every style’s command mode) | Move to the pane on the right, or the tab after |
pane-shrink | alt-- (global, terminal), - (pane, resize) | Give this pane less room |
pane-shrink-down | J (resize) | Make this pane smaller by moving its bottom edge up, or the other edge at the screen’s edge |
pane-shrink-left | H (resize) | Make this pane smaller by moving its left edge in, or the other edge at the screen’s edge |
pane-shrink-right | L (resize) | Make this pane smaller by moving its right edge in, or the other edge at the screen’s edge |
pane-shrink-up | K (resize) | Make this pane smaller by moving its top edge down, or the other edge at the screen’s edge |
pane-split-down | w s (after the leader), s (pane), ctrl-w s (every style’s command mode) | Show this pane’s file in a new pane below |
pane-split-right | w v (after the leader), v (pane), ctrl-w v (every style’s command mode), ctrl-\ (vscode) | Show this pane’s file in a new pane on the right |
pane-swap-down | w J (after the leader), ctrl-w J (every style’s command mode) | Swap this pane with the one below |
pane-swap-left | w H (after the leader), ctrl-w H (every style’s command mode) | Swap this pane with the one on its left |
pane-swap-right | w L (after the leader), ctrl-w L (every style’s command mode) | Swap this pane with the one on its right |
pane-swap-up | w K (after the leader), ctrl-w K (every style’s command mode) | Swap this pane with the one above |
pane-terminal | alt-n (global, terminal), w t (after the leader), ctrl-w t (every style’s command mode) | Open a terminal in a new pane, or a floating one while floating views are shown |
pane-terminal-done | n (pane) | pane-terminal, then back from the mode |
pane-terminal-down | d (pane) | Open a terminal in a new pane below |
pane-terminal-right | r (pane) | Open a terminal in a new pane on the right |
pane-to-new-tab | Move this pane (or panel, or floating view) to a new tab | |
pane-to-new-tab-done | b (pane) | pane-to-new-tab, then back from the mode |
pane-to-panel | Move this pane (or floating view) into a panel on the right | |
pane-to-panel-done | P (pane) | pane-to-panel, then back from the mode |
pane-to-tab | Move this pane (or panel, or floating view) to a tab you pick, or a new one | |
pane-to-tab-done | t (pane) | pane-to-tab, then back from the mode |
pane-up | alt-k, alt-up (global, terminal), w k (after the leader), k, up (pane), ctrl-w k (every style’s command mode) | Move to the pane above |
pane-zoom | w z (after the leader), f (pane), ctrl-w z (every style’s command mode) | Show only this pane, or all of them again |
resize-mode | alt-r (global, terminal), R (pane) | Keys for resizing the pane or floating view until esc, and moving a float |
tab-close | Close this tab and its panes | |
tab-close-done | x (tab) | tab-close, then back from the mode |
tab-go | alt-1, alt-2, alt-3, alt-4, alt-5, alt-6, alt-7, alt-8, alt-9 (global, terminal) | Show tab N |
tab-mode | alt-t (global, terminal) | Keys for tabs until esc: new, close, switch, rename |
tab-new | Open a new tab | |
tab-new-done | n (tab) | tab-new, then back from the mode |
tab-next | alt->, alt-] (global, terminal), ], l, right (tab), g t (vim’s command mode) | Show the next tab; with a count, tab N, as Vim’s 3gt |
tab-previous | alt-<, alt-[ (global, terminal), [, h, left (tab), g T (vim’s command mode) | Show the tab before; with a count, that many tabs back |
tab-rename | Name this tab | |
tab-rename-done | r (tab) | tab-rename, then back from the mode |
tab-terminal | Open a new tab with a terminal | |
tab-terminal-done | t (tab) | tab-terminal, then back from the mode |
terminal-float | Show the floating terminal, or hide it |
| Option | Default | What it does |
|---|---|---|
float-layout | "free" | How new tabs lay out their floating views: “free”, “one”, “tiled”, “cascade” or your own |
pane-layout | "manual" | How new tabs arrange their panes: “manual”, “main-stack”, “columns”, “spiral” or your own |
PDF files open as their pages: one page at a time, drawn as wide as the
view (in terminals that show images, and in the window), or as the text
on every page, which reads anywhere and searches with /.
] [ next and previous page
+ - = bigger, smaller, as wide as the view
t pages or text
Uses: core.
| Command | Keys | What it does |
|---|---|---|
pdf-next-page | ] (in pdf buffers) | Show the next page of the PDF |
pdf-previous-page | [ (in pdf buffers) | Show the previous page of the PDF |
pdf-text | t (in pdf buffers) | Switch between the PDF’s pages and the text on them |
pdf-zoom-fit | = (in pdf buffers) | Draw the PDF’s page as wide as the view |
pdf-zoom-in | + (in pdf buffers) | Draw the PDF’s page bigger |
pdf-zoom-out | - (in pdf buffers) | Draw the PDF’s page smaller |
picker
Pickers: type to narrow a list down, then choose an item.
A picker is one floating buffer. Its first line is what you type; the lines below are the items that match, best first, with the current one highlighted. Move with up/down (or ctrl-n/ctrl-p), choose with enter, close with esc.
Other plugins open one with require("@self/picker").pick(...); see
pickers.luau for examples.
Uses: core.
| Command | Keys | What it does |
|---|---|---|
act | . (blocks, after the leader), alt-. (vscode’s typing mode) | List what you can do with what’s under the cursor (a file, link, symbol, problem, change or the selection), and do it |
command-palette | ? (after the leader), ctrl-P (vscode) | Run any command by name |
pick-anything | space (after the leader) | Switch to anything: a file, a shell, a terminal or another buffer, and what plugins add, like your sessions and agents; @kind keeps one kind, ctrl-a lists what can be done to it (answer an agent), ctrl-v, ctrl-s and ctrl-f open a buffer beside, below or in a float |
pick-buffer | b (after the leader), ctrl-b (vscode) | Switch to an open file, or a buffer kept open without one, like a shell’s > buf:NAME |
pick-file | f (after the leader), ctrl-p (vscode) | Open a file in the project, skipping ignored files |
pick-file-here | F (after the leader) | Open a file under the folder Greed was started in, skipping ignored files |
pick-jump | j (after the leader) | Pick a place from the jumplist and go there |
pick-outline | s (after the leader), g O (vim), ctrl-O (vscode) | Jump to a function or type in the file, from its syntax tree |
pick-style | Pick an editing style | |
picker-act | alt-. (in picker buffers) | List what you can do with the current item, and do it |
picker-choose | enter (in picker buffers) | Choose the current item and close the picker |
picker-close | esc (in picker buffers) | Close the picker without choosing |
picker-complete | tab (in picker buffers) | Put the current path in the picker’s query, to go on from there |
picker-key | Run what the open picker does for the key pressed | |
picker-next | ctrl-n, down (in picker buffers) | Move to the next item in the picker |
picker-prev | ctrl-p, up (in picker buffers) | Move to the previous item in the picker |
picker-resume | ' (after the leader) | Open the last picker again |
search-everywhere | n s (after the leader) | Search your notes, mail and chat at once, as you type; in:mail, in:chat or in:notes picks some |
watches | List what’s watched for changes; enter stops watching one |
pipe
Pipe each selection through something and put back what comes out:
| ask what to pipe through
:pipe TARGET the same, from the command line
The target says what it is:
sort -u a shell command, given the selection as input
luau: snake_case a Luau function (see pipe.define)
model: use the new client API a language model, in the pipe-model role
Every selection gets its own result, and they all go in as one change, so one undo takes them back. A model’s changes are an operation too, to review with space u o; each result lands in its place even if you edit while the model works.
Uses: core, models, operations.
| Command | Keys | What it does |
|---|---|---|
append-output | alt-! (helix’s command mode) | Insert what a shell command prints after each selection |
insert-output | ! (helix’s command mode) | Insert what a shell command prints before each selection |
keep-pipe | $ (helix’s command mode) | Keep the selections a shell command succeeds on, given each as input |
pipe | | (helix’s command mode) | Pipe each selection through a shell command, a Luau filter (luau: name) or a model (model: what to do) |
pipe-to | alt-| (helix’s command mode) | Give each selection to a shell command as input, leaving the text as it is |
| Option | Default | What it does |
|---|---|---|
pipe-model-role | "fast" | The model role | model: ... asks; see :models |
plan
A plan and decisions you share with agents, as notes in the project’s
notes folder (.greed/notes, see the notes plugin), so they’re searched,
linked and in the agenda like any note.
The plan (project:plan) is an agent’s checklist where you can see and
change it: tick, reorder, add or delete items, and the agent reads what
you did. An agent replaces the whole plan when it writes, giving the
version it read, so it can’t write over changes you made since.
Decisions (project:decisions/*) are what you settled, kept across
sessions: “use sqlite”, “never touch the generated code”. Ones an agent
adds stay proposed until you accept them, and agents are told so, so an
agent can’t make itself rules the next one follows.
Uses: core, agent, picker, notes.
| Command | Keys | What it does |
|---|---|---|
decision-accept | Accept the proposed decision you’re in, so agents follow it | |
decision-new | Write down a decision for this project, kept for you and agents | |
decisions | Pick a decision kept for this project to open it | |
plan | Open the plan you share with agents, in the project’s notes |
projects
Projects: space P lists, in one picker, the projects open here, the
sessions running on this machine, recent projects, and the projects your
sources find, each saying what enter does with it. A project gets a
session of its own: enter switches to one open here or to its session,
and starts a session for one that has none. alt-o opens it here
instead, in this session, for work across projects; alt-enter starts a
new session even when one is running for it, and alt-w goes to it in
another window, this one staying where it is. A typed folder opens too.
Sources are folders to look in and commands that print paths:
require("@projects").sources({
-- every folder one level under these
{ dirs = { "~/Development", "~/Work" } },
-- deeper, but only folders that look like projects
{ dirs = { "~/src" }, depth = 3, markers = { ".jj", ".git" } },
-- any command that prints one path per line
{ command = { "zoxide", "query", "-l" } },
})
Sources are looked at in the background, when the editor starts and each time the picker opens, and what they found last is kept, so the picker opens at once.
Uses: core, picker.
| Command | Keys | What it does |
|---|---|---|
pick-project | P (after the leader) | Go to a project: one open here, a running session, a recent one or one your sources find; or type a folder to open |
prometheus
Prometheus in the shell: prom QUERY asks a Prometheus server (the
prometheus-url option, or --url) and prints what it answers as rows,
which the shell shows as a table and | chart draws.
prom 'up' a row a series, as it is now
prom 'rate(http_requests_total[5m])' | chart bars of each
watch -n 5 prom 'rate(http_requests_total[5m])' | chart
a line a series, as it goes
prom 'node_load1' --range 1h | chart the last hour, a line a series
A series is named by its labels’ values, api/10.0.0.1:9100, or its
metric’s name when it has none of its own.
Uses: shell.
| Option | Default | What it does |
|---|---|---|
prometheus-url | "http://localhost:9090" | The Prometheus server prom asks, unless –url says |
prose
Text objects for prose: select or move by sentence, paragraph and Markdown section.
m i p / m a p select the paragraph (a: with the blank lines after it)
m i s / m a s select the sentence (a: with the spaces after it)
m i h / m a h select the section under a heading (a: with the heading)
] p / [ p next / previous paragraph
] s / [ s next / previous sentence
Uses: core, markdown.
| Command | Keys | What it does |
|---|---|---|
next-paragraph | ] p (every style’s command mode) | Move to the start of the next paragraph |
next-sentence | ] s (every style’s command mode) | Move to the start of the next sentence |
prev-paragraph | [ p (every style’s command mode) | Move to the start of the paragraph, or the one before |
prev-sentence | [ s (every style’s command mode) | Move to the start of the sentence, or the one before |
select-paragraph | m i p (helix’s command mode) | Select the paragraph |
select-paragraph-around | m a p (helix’s command mode) | Select the paragraph and the blank lines after it |
select-section | m i h (helix’s command mode) | Select the text under the Markdown heading |
select-section-around | m a h (helix’s command mode) | Select the Markdown section, heading included |
select-sentence | m i s (helix’s command mode) | Select the sentence |
select-sentence-around | m a s (helix’s command mode) | Select the sentence and the spaces after it |
restore
Session restore: a session remembers its projects, the files open in
each and where the cursor was, and each project’s tabs: their panes,
what those show, and the terminals in them (run again, unless what they
ran is risky; then a shell). It opens them again when it starts, unless
it was quit: then it starts clean, except with restore-after-quit or
after an upgrade. Written down when it starts and quits and when a file
is opened, closed or saved, per session name in the cache, so it only
works for editors running as a session (which greed is, unless
GREED_NO_SESSION is set).
Uses: core, panes.
| Option | Default | What it does |
|---|---|---|
restore-after-quit | false | Restore a session when it starts again after it was quit, too |
restore-session | true | Open the files a session had open when it starts again after it ended without being quit, as in a crash or a restart |
scene
Scenes: small vector drawings, as charts are made of, and how one looks drawn in a block of character cells, which every client shows. Lines and dots are braille, two by four dots a cell; filled shapes are eighth blocks, so a bar’s end falls between cells; text is text. Each cell takes the style of what was drawn in it last.
A scene’s coordinates are in cells, as numbers with fractions: (0, 0) is the top left, (cols, rows) the bottom right, y going down.
local scene = require("@scene")
local lines = scene.cells({
alt = "cpu over the last minute",
items = {
{ kind = "line", points = { { 0, 9 }, { 10, 2 } }, style = "chart.series.1" },
{ kind = "rect", at = { 12, 4 }, size = { 1, 6 }, fill = "chart.series.2" },
{ kind = "text", at = { 0, 0 }, text = "cpu", style = "chart.title" },
},
}, 40, 10)
Items are drawn in order: line (points, style), area (points down
to base, fill), rect (at, size, fill, or style for its edges),
dots (points, style), text (at, text, style, align “start”,
“middle” or “end”) and group (items, clipped to clip, x0 y0 x1 y1).
Kinds it doesn’t know are left out.
| Option | Default | What it does |
|---|---|---|
scene-drawing | "auto" | How charts and other scenes show: auto (as an image where the terminal can draw one, else characters) or cells (characters everywhere) |
service
Services: state that lives in one place, the session of its owner, shown
and acted on from any session through views. The owner offers a service;
a view uses it, in the owner’s session directly and elsewhere over the
owner’s session socket, through greed mcp started for that session.
Greed starts the owner’s session when a view needs it.
On the socket, as JSON-RPC: service/hello (which version the owner
speaks, and its incarnation: an id that changes whenever it starts
again), service/listen and service/ignore (topics), service/request,
and the owner’s service/notify to views listening.
Uses: core, agent.
| Command | Keys | What it does |
|---|---|---|
service-restart | Quit a service’s session and start it again with this greed, as after an upgrade |
| Option | Default | What it does |
|---|---|---|
services-at-start | "" | The services that start in the background when Greed starts, names with spaces between (like mail hoard chat); the others start when first used |
setup
Setting Greed up: the first time you start it without a config, a page
asks how you like to edit, which theme, whether your font has icons,
whether to add Greed’s tools to the agents installed here, and which
language model to use. The page is setup.md, a questionnaire in Markdown
(see the markdown and blocks plugins): a style or theme picked switches
at once, and Save writes a config from the answers and opens it, and has
the model’s roles use the provider picked. :setup brings the page back
any time.
tab and shift-tab go from choice to choice and button to button, enter (or space) or a click picks one or presses it, and esc or q closes it as “Not now”.
Uses: core, theme, models, markdown, blocks.
| Command | Keys | What it does |
|---|---|---|
config-types | Set up type checking for your config: a .luaurc beside it that knows @greed and the plugins | |
setup | Answer a few questions to set Greed up: editing style, theme, icons, agents, a model | |
setup-close | Close the setup page without saving; :setup brings it back | |
setup-next | Go to the next choice or button on the setup page | |
setup-prev | Go to the previous choice or button on the setup page | |
setup-save | Save the setup page’s answers as your config, and open it |
| Option | Default | What it does |
|---|---|---|
setup-first-start | true | Show the setup page the first time a terminal or window attaches without a config |
shell
A shell in a buffer: type a command at the prompt at the bottom, enter runs it, and it becomes a block above: the command, what it printed, and how it ended. Blocks stay to read, search, fold, copy and run again.
space o s switch to a shell, or open one (:shell opens a new one)
enter run what's at the prompt; on a block, edit its command
[ p ] p the block before or after the cursor
g o select the block's output
] e [ e the next or previous file:line the output names; enter opens it
ctrl-c interrupt the running block (vscode style: copy a selection)
ctrl-t type into the running block's program, in a terminal
space r run the block again, as it ran; space R here and now
space y/Y copy its output / its command
space x stop it; space v opens its whole output; space c clears
The shell runs cd, export, unset, env, history, clear,
open and help itself; every other line goes to a real shell, yours
(sh for an agent), whose cd and export carry over (fallback.luau). It
runs in a pseudo terminal (pty.luau), handed to a terminal when a
program wants one; an agent’s run through a pipe. Each shell has its own
folder and variables, and a project can have several.
$3 | sort, buf:NAME | ..., @sel | ... and @file | ... send block
3’s output, a buffer, the selection or the file you’re in to a command,
and ... > buf:NAME (>> adds) sends its output to a buffer
(data.luau). Output that’s JSON is kept as a value on the block, and a
table (kubectl get, docker ps, ps) as a table, which $3 | where ...,
select and sort work on (tables.luau). / filters what a block
shows, and space s sorts a table (rows.luau).
Agents run commands with shell_run and read blocks with shell_read (tools.luau).
Uses: core, picker, terminal.
| Command | Keys | What it does |
|---|---|---|
pick-running | o w (after the leader) | Pick among what runs in every shell, its output beside: enter opens it in a float, ctrl-o goes to it, ctrl-x stops it |
pick-shell | o s (after the leader) | Switch to a shell of this project, or open a new one |
shell | Open a new shell: a buffer of commands and what they printed | |
shell-accept-or-end | ctrl-e, end (every style’s typing mode; in shell buffers) | At the end of the prompt, take the rest of the command it suggests; elsewhere go to the end of the line |
shell-accept-or-right | right (every style’s typing mode; in shell buffers) | At the end of the prompt, take the rest of the command it suggests; elsewhere move right |
shell-before | b (blocks) | Show what the block showed the run before this one |
shell-beside | v (blocks) | Show the block in a pane beside, following it as it prints, with a filter of its own (/) |
shell-blocks | Go to blocks mode, to move between commands and act on them | |
shell-blocks-down | down, j (blocks) | Down a step: the next row, or the next command |
shell-blocks-filter | / (blocks) | Filter the rows the command printed |
shell-blocks-first | g (blocks) | The first command |
shell-blocks-keys | ? (blocks) | List the keys of blocks mode |
shell-blocks-last | G (blocks) | The last command |
shell-blocks-next | J, ctrl-down (blocks) | The next command, past its rows |
shell-blocks-out | h, left (blocks) | Back out of the rows to the command |
shell-blocks-previous | K, ctrl-up (blocks) | The command before |
shell-blocks-prompt | a, esc, i (blocks) | Go back to the prompt |
shell-blocks-rerun | r (blocks) | Run the selected command again in its place, staying on it |
shell-blocks-rows | l, right (blocks) | Into the rows the command printed |
shell-blocks-type | Go back to the prompt and type there what the key types; a key that types nothing does nothing | |
shell-blocks-up | k, up (blocks) | Up a step: the row before, or the command before |
shell-change | C (after the leader; in shell buffers) | Change the block’s command and run it in the block’s place, as a watch switching to show something else |
shell-clear | c (after the leader; in shell buffers) | Take the finished blocks out of the shell |
shell-copy-command | Y (blocks, after the leader; in shell buffers) | Copy the block’s command |
shell-copy-or-interrupt | ctrl-c (vscode’s typing mode; in shell buffers) | Copy the selection, or with nothing selected interrupt the running block |
shell-copy-output | y (blocks, after the leader; in shell buffers) | Copy what the block printed |
shell-diff-before | d (blocks) | Show what changed in the block since the run before |
shell-drill-keep | ctrl-z (every style’s command mode, vscode’s typing mode; in shell buffers) | Go back up from a level drilled down to, keeping its command running in the shell |
shell-edit | Put the block’s command at the prompt, to change and run again | |
shell-enter | enter (blocks, every style’s command mode, every style’s typing mode; in shell buffers) | Run what’s at the prompt; on a block, put its command at the prompt to edit, or on a row that’s a file or a pod, open or describe it |
shell-esc | esc (every style’s typing mode; in shell buffers) | Leave the prompt: for blocks mode, or the style’s own mode with shell-blocks off |
shell-filter | / (every style’s command mode; in shell buffers), ctrl-f (vscode’s typing mode; in shell buffers) | Keep the lines of the block at the cursor with what’s typed in them (/ for a regex), or a table’s rows (COL=VALUE, COL~TEXT, COL>N); elsewhere, search |
shell-handoff | ctrl-t (blocks, every style’s command mode, every style’s typing mode; in shell buffers) | Show the running block’s program in a terminal, to type into it |
shell-history | ctrl-r (blocks, every style’s command mode, every style’s typing mode; in shell buffers) | Pick a command typed before, in any shell, to put at the prompt |
shell-history-back | up (every style’s typing mode; in shell buffers) | Put the command typed before at the prompt, one starting with what’s typed there |
shell-history-forward | down (every style’s typing mode; in shell buffers) | Put the command typed after at the prompt, or back to what was typed |
shell-interrupt | ctrl-c (blocks, every style’s command mode, every style’s typing mode; in shell buffers), s (blocks) | Interrupt the running block at the cursor, or the latest one, as ctrl-c does |
shell-kill | x (after the leader; in shell buffers) | Stop the running block at the cursor, or the latest one, for good |
shell-line | Run a command line in this project’s shell, opening one if there’s none, as :!cmd does | |
shell-next-block | ] p (every style’s command mode; in shell buffers), ctrl-down (vscode’s typing mode; in shell buffers) | Go to the block after the cursor, or the prompt |
shell-next-reference | ] e (every style’s command mode; in shell buffers), f8 (vscode’s typing mode; in shell buffers) | Go to the next file and line a block’s output names, like an error’s place; enter opens it |
shell-notify | Send a notification each time a watch’s rows change, saying how, while Greed isn’t focused; again to stop | |
shell-output-open | o (blocks), v (after the leader; in shell buffers) | Open the block’s whole output in a buffer of its own |
shell-peek | Open the block in a float, to filter it, act on its rows or stop it, and close it again with esc | |
shell-pretty | p (blocks) | Show the block’s JSON lines readably (time, level and message first) or as they came |
shell-prev-block | [ p (every style’s command mode; in shell buffers), ctrl-up (vscode’s typing mode; in shell buffers) | Go to the block before the cursor |
shell-prev-reference | [ e (every style’s command mode; in shell buffers), shift-f8 (vscode’s typing mode; in shell buffers) | Go to the file and line a block’s output names before the cursor |
shell-rerun | r (after the leader; in shell buffers) | Run the block’s command again, in the folder and with the variables it had |
shell-rerun-here | R (after the leader; in shell buffers) | Run the block’s command again in the shell’s folder now |
shell-rerun-in-place | Run the block’s command again in its place, keeping what it showed before (b in blocks mode shows it) | |
shell-run | Run what’s at the prompt | |
shell-select-output | g o (every style’s command mode; in shell buffers) | Select the block’s output, to copy or search |
shell-show-all | S (after the leader; in shell buffers) | Show the block at the cursor’s output as it came, without a filter or a sort |
shell-sort | s (after the leader; in shell buffers) | Sort the table at the cursor by the column under it; again to reverse, a third time as it came |
shell-unfilter | esc (every style’s command mode; in shell buffers) | Show every line, or row, of the filtered block at the cursor again, keeping its sort; in a block’s float, close it |
| Option | Default | What it does |
|---|---|---|
shell-agent-max-output | 30000 | How many bytes of a command’s output and of its errors the shell tools give an agent: the start and the end, with what’s between left out |
shell-aliases | true | Whether a line can start with one of your shell’s aliases, read once from its startup files |
shell-ask-role | "fast" | The model role a line ending or starting with ? asks for a command; see :models |
shell-blocks | true | In the shell, esc and clicks in output go to blocks mode, to move between commands and rows and act on them |
shell-completion-sources | "cobra fish carapace man help" | Where a shell completes a program’s arguments from, in order: cobra, fish, carapace, man, help |
shell-completion-timeout | 2000 | Milliseconds a program asked for completions (kubectl, fish, carapace, –help) gets to answer |
shell-confirm-lines | 5 | Running a prompt of more lines than this asks first, as after pasting a transcript |
shell-editor | true | Whether programs you run in a shell, like git commit, open files to edit in Greed: $EDITOR, $VISUAL, $GIT_EDITOR, $JJ_EDITOR and $KUBE_EDITOR are greed edit –wait |
shell-environments | "devenv direnv" | Which environments a shell loads in folders that bring one, in order, the first that applies winning: devenv, direnv, and those plugins add; empty for none |
shell-fallback | "" | The shell that runs lines with pipes, globs and the like, e.g. “bash”; empty for your $SHELL (sh unless it’s sh, bash, zsh, dash, ksh, fish or nu) |
shell-fallback-rc | false | Whether the shell running those lines reads its startup files (-i), for your aliases and functions |
shell-fold-lines | 0 | A block that printed more lines than this folds as it ends, unless it failed; 0 never |
shell-fold-older | false | Running a command folds the finished blocks above it, except those that failed |
shell-fold-structured | 100 | JSON or YAML output of more lines than this shows its top keys folded as it ends, and inside a fold still this long, the keys under it; 0 never |
shell-help-completion | "on-flag" | When a shell runs a program with –help to complete its flags: on-flag (when you press tab on one) or never |
shell-help-never | "reboot shutdown halt poweroff init telinit kill killall pkill" | Programs a shell never runs with –help to complete their flags |
shell-history-size | 5000 | How many commands typed at shells are kept |
shell-icons | "plain" | The icons of a shell’s prompt segments: “plain” ones any font has, or “nerd” ones a Nerd Font has |
shell-json-lines | "pretty" | How a block whose lines are JSON objects or logfmt, as many logs are, shows them: “pretty” (time, level and message first, the other fields after) or “raw” |
shell-max-lines | 5000 | How many lines of a block’s output a shell shows: the first half and the latest half |
shell-max-record | 8388608 | How many bytes of a block’s output its record keeps; the rest goes to a file in the cache folder |
shell-production-contexts | "prod" | Patterns for kubernetes contexts a shell’s prompt warns about, like prod; space between them |
shell-prompt | "greed" | What draws a shell’s prompt before its ❯: “greed” (its own segments and folder) or “starship” (your starship prompt, when starship is installed) |
shell-suggestions | true | Whether a shell’s prompt suggests the rest of a command typed before, after the cursor |
shell-watch-minutes | 60 | How long a shell’s watch runs before it stops by itself, in minutes; 0 for until it’s stopped |
slides
Slides from a Markdown file. A --- line with a blank line above it
starts the next slide (right under text, --- underlines a heading),
and front matter at the top isn’t a slide. :slides (space m P) shows
the slide the cursor is on in a float over the whole screen, a view of
the file itself, so a block on a slide runs there and its result shows.
right, space, l, pagedown the next left, backspace, h, pageup the one before
home, g the first end, G the last
r run the block the cursor is on (it lands on the first)
q, esc back to the file
A ```speaker block at the end of a slide is what you’d say there:
it isn’t shown on the slide.
The slides are a talk, and every client can show it: :slides on another
screen joins it, and :slides-presenter shows the slide with the notes,
the next slide and the time beside it. Going to another slide on any of
them goes there on all; q leaves one, and the talk ends with the last.
Uses: core, markdown, blocks.
| Command | Keys | What it does |
|---|---|---|
slide-first | Go to the first slide, on every screen showing the slides | |
slide-last | Go to the last slide, on every screen showing the slides | |
slide-next | Go to the next slide, on every screen showing the slides | |
slide-prev | Go to the slide before, on every screen showing the slides | |
slides | m P (after the leader) | Show this Markdown file as slides, from the one the cursor is on, or join the slides another screen shows |
slides-presenter | Show the slides with their notes, the next slide and the time beside them, for whoever presents | |
slides-stop | Stop showing slides here and go back to the file; other screens go on |
| Option | Default | What it does |
|---|---|---|
slides-center | false | Center what’s on a slide, across and down: each heading, and the rest as one block |
slides-margin | 2 | Cells left empty above and left of a slide |
slides-scale | 1 | How many times bigger slides’ text is drawn, 1 to 4, in the window and in kitty, a big heading twice that; “fit” draws each slide as big as fits |
snippets
Snippets of your own, in VS Code’s format: a JSON file per language in
your snippets folder (snippets in your config’s folder) or a project’s
(.greed/snippets), each snippet a name with a prefix to type, a body
and a description:
{
"test": {
"prefix": "test",
"body": ["#[test]", "fn ${1:name}() {", "\t$0", "}"],
"description": "A test function"
}
}
rust.json is for Rust, all.json for every language, and a
.code-snippets file, as VS Code shares them, may give a snippet a
“scope” (“rust,python”); without one it’s for every language. Snippets
come up as you type their prefix, after what the language server
offers; :snippet picks one by name, and :snippets-edit opens this
language’s file. Saving a file reloads it.
Uses: core, picker.
| Command | Keys | What it does |
|---|---|---|
snippet | Pick one of the snippets for this file’s language by name and put it in | |
snippets-edit | Open your snippets for this file’s language, making the file if there’s none |
| Option | Default | What it does |
|---|---|---|
snippets-folder | "" | Where your own snippets are; empty for the snippets folder in your config’s folder |
statusline
The status line: on the left the mode, the tab, the file (or the latest message) and whether keys are being recorded; on the right the branch, problems, the language and its server, the editing style (dim), anything unusual about the file, how many selections there are, where the cursor is, the machine and the session. With the statusline-pills option some are pills, with rounded ends drawn in the theme’s colors, and with the effects option light goes through the tab or the file when you go to another, and the mode when it changes.
Add to it from your config, or take a piece away:
local statusline = require("@statusline")
statusline.add("right", "clock", function() return os.date("%H:%M") end)
statusline.remove("host")
greed.statusline with a function of your own replaces it all; the last
one set wins.
Uses: core.
| Command | Keys | What it does |
|---|---|---|
messages | Show the last messages in full, newest last |
| Option | Default | What it does |
|---|---|---|
statusline-caps | "round" | The ends of status line pills: “round” (needs a Nerd Font) or “none” |
statusline-pills | false | Show the mode, tab, machine and session in the status line as pills in their colors |
swatches
Colors written as #rrggbb (or #rgb, #rrggbbaa) get a small square
in that color in front of them, in any file. A three-digit one needs a
letter in it, so an issue number like #123 stays plain. :set color-swatches false turns them off.
Uses: core.
| Option | Default | What it does |
|---|---|---|
color-swatches | true | Show a square in their color in front of colors like #ff8800 |
terminal
Terminals: a shell, or any program, in a buffer. :terminal [command]
opens one in the main view and sends it every key; ctrl-\ goes back to
the editing style’s mode, where the output is text to select, search
and copy, and i or enter types into the program again.
The buffer holds the lines that scrolled off the top, then the screen. Output replaces the screen part and adds what scrolled off above it.
Uses: core, picker.
| Command | Keys | What it does |
|---|---|---|
open-link | g x (in terminal buffers) | Open the link under the cursor, or the file it names, at the line it says |
pick-terminal | t (after the leader) | Switch to a terminal, or open a new one |
task | o t (after the leader) | Run a task, like the project’s build or tests, in a terminal that stays open; without a name, pick one |
terminal | Open a terminal running a command, or your shell | |
terminal-close | End the terminal’s program and close it | |
terminal-esc | esc (terminal) | Send esc to the terminal’s program; a second one quickly after stops typing into it |
terminal-input | a, enter, i (in terminal buffers) | Type into the terminal’s program |
terminal-key | Send the key to the terminal’s program | |
terminal-leader | ctrl-space (terminal) | Stop typing into the terminal and open the leader, for the keys after it |
terminal-leave | ctrl-\ (terminal) | Stop typing into the terminal, to move around its output |
terminal-next-command | ] p (in terminal buffers) | Go to the command after the cursor in a terminal, where its shell marks commands |
terminal-next-reference | ] e (in terminal buffers) | Go to the next file and line the output names, like an error’s place; g x opens it |
terminal-paste | p (in terminal buffers) | Paste the latest copy into the terminal’s program |
terminal-prev-command | [ p (in terminal buffers) | Go to the command before the cursor in a terminal, where its shell marks commands |
terminal-prev-reference | [ e (in terminal buffers) | Go to the file and line the output names before the cursor |
terminal-references | d (after the leader; in terminal buffers) | Pick from the files and lines the output names, like a compiler’s errors, to open one |
terminal-select-output | g o (in terminal buffers) | Select the output of the command at the cursor in a terminal, to copy or search |
terminal-send | T (after the leader) | Send the selection, the code block the cursor is in, or the cursor’s line, to the terminal you used last, and run it |
| Option | Default | What it does |
|---|---|---|
terminal-esc-wait | true | Hold esc a moment in terminals whose program draws on the normal screen, like Claude Code, so esc esc stops typing into it without the program getting an esc |
terminal-notifications | true | Whether what a program in a terminal notifies (OSC 9, OSC 777) also goes to your desktop, as Greed’s own notifications do |
terminal-scrollback | 10000 | How many lines that scrolled off a terminal’s screen are kept |
terminal-shell | "" | What a new terminal runs, e.g. “fish -l”; empty for your $SHELL |
terminal-shell-integration | true | Whether a terminal’s bash, zsh or fish gets the marks around prompts, commands and output and the folder it’s in, with nothing to set up |
theme
Themes: what every style name looks like. Greed comes with the default (the terminal’s 16 colors) and the usual ones from other editors: Nord, Dracula, Catppuccin, Gruvbox, Tokyo Night, One Dark and more.
:theme NAME switch to a theme
:theme pick one, trying each as you move; esc goes back
The theme picked is remembered (in the cache folder) until you pick another. To set it from your config, or define your own:
local theme = require("@theme")
theme.use("nord")
theme.define("mine", {
palette = { bg = "#101418", ... }, -- see palette.luau
styles = { comment = { fg = "#5c6773" } },
})
theme.define("nord-bold", { inherits = "nord", styles = { keyword = { bold = true } } })
A theme is the base under greed.theme.set: entries set that way, from
your config or a plugin, stay on top whichever theme is in use.
Uses: picker, cmdline.
| Command | Keys | What it does |
|---|---|---|
theme | ctrl-k ctrl-t (vscode) | Switch to a theme, or pick one trying each as you move |
todo-comments
TODO, FIXME and their kind stand out in comments: TODO, HACK and XXX in
one color, FIXME and BUG in another, NOTE in a third. Only in comments,
by the syntax tree where the language has one (by its comment marker
where it doesn’t), so a string saying “TODO” stays as it is.
:todo-comments lists them across the project. :set todo-comments false stops picking them out.
Change the words and their styles from your config:
require("@todo-comments").words.PERF = "comment.note"
Uses: core, picker.
| Command | Keys | What it does |
|---|---|---|
todo-comments | List the TODO, FIXME and like comments in the project’s files |
| Option | Default | What it does |
|---|---|---|
todo-comments | true | Pick out TODO, FIXME and the like in comments |
tree
A file tree in a side panel. space e opens it (or moves to it, or closes
it if you’re in it). In the tree: enter or l opens a file or folds a
folder, h folds the folder you’re in, r reads the disk again, q closes;
a makes a file (or a folder, ending in /), R renames, d deletes (to the
trash, where there is one); e shows the folder on the cursor as a buffer
to edit many names at once (the folders plugin). Hidden and ignored files
are left out, like in the file picker.
It’s only a plugin: to turn it off, greed.plugin.unload("tree") from your
config.
Uses: core.
| Command | Keys | What it does |
|---|---|---|
tree | e (after the leader) | Open the file tree, move to it, or close it if you’re in it |
tree-add | a (in tree buffers) | Make a file in the folder on the cursor, or a folder with a / at the end |
tree-close | Close the file tree | |
tree-delete | d (in tree buffers) | Delete the file or folder on the cursor, after you press y |
tree-edit | e (in tree buffers) | Show the folder on the cursor, or the one its file is in, as a buffer to edit its files’ names |
tree-fold | h (in tree buffers) | Fold the folder on the cursor, or the one it’s in |
tree-open | enter, l (in tree buffers) | Open the file on the cursor, or fold or unfold the folder |
tree-refresh | r (in tree buffers) | Read the tree from the disk again |
tree-rename | R (in tree buffers) | Rename or move the file or folder on the cursor; open files go along |
| Option | Default | What it does |
|---|---|---|
tree-icons | "none" | Icons by the names in the file tree: “none”, or “nerd” for a Nerd Font’s |
tutor
The tutor: :tutor opens tutor.md, a page to read and edit with the
keys of your editing style. It asks which style first, switches to the one
picked, and shows each lesson’s keys for it, with <!-- if style=... -->
parts (see the markdown plugin’s questions).
A lesson’s exercise is a practice block followed by a want block, the
text it should become. The tutor hides the want block and marks the
practice block done once its text matches. The want block’s options give
each style’s keys for it (vim="w d w"); the tests press them, so the
keys the page teaches are known to work.
Uses: core, markdown, blocks.
| Command | Keys | What it does |
|---|---|---|
tutor | Learn to edit with your editing style’s keys, and get around Greed |
undo-tree
The undo tree, like Emacs’s vundo: every state the text has been in, the
branches an undo followed by an edit left behind included. space u t
shows it; moving up and down takes the text to that state as you go,
enter keeps it, and esc goes back to where you were.
○ 0 loaded
○ 1 3m
│ ○ 2 2m a branch left behind
● 3 now where the text is
The newest branch of each state carries on below it; older ones are indented under it.
Uses: core.
| Command | Keys | What it does |
|---|---|---|
undo-tree | u t (after the leader) | Show every state the file has been in, branches included, and go to one |
undo-tree-cancel | esc (in undo-tree buffers) | Close the undo tree and put the text back as it was |
undo-tree-down | down, j (in undo-tree buffers) | Go to the next state down the undo tree |
undo-tree-keep | enter, q (in undo-tree buffers) | Close the undo tree, keeping the text as it is |
undo-tree-up | k, up (in undo-tree buffers) | Go to the next state up the undo tree |
vcs
Version control: signs beside lines added (+), changed (~) and removed (-) since the last commit, with jj, or git where there’s no .jj.
] g / [ g next / previous change; ] G / [ G the last and first
m i g the change under the cursor; m a g its lines
space g r put the change under the cursor back the way it was
space g b who last changed this line, and when
space g s every change since the last commit, in one multibuffer
space u c commit just the latest operation's files, named after it
space g a stage the change under the cursor (git)
space g S what's staged (git), to unstage hunks and commit
With jj the comparison is with the working copy’s parent (@-), so the signs show what the change you’re working on does to the file. With git it’s with what’s staged, so staged changes lose their signs.
In a shell, the rows of git status, git log, jj st and jj log
are changed files, commits and revisions to act on.
Uses: core, agent, multibuffer, operations, picker, statusline, shell.
| Command | Keys | What it does |
|---|---|---|
blame-line | g b (after the leader) | Show who last changed the line under the cursor, and when |
change-diff-close | q (in change-diff buffers) | Go back to the change stack |
change-stack | g l (after the leader) | Show the changes from the last pushed one to the working copy, to describe, squash, move or abandon |
change-stack-abandon | a (in change-stack buffers) | Abandon it, after asking |
change-stack-close | q (in change-stack buffers) | Close the stack and go back to what was shown before |
change-stack-describe | d (in change-stack buffers) | Describe the change |
change-stack-down | alt-j (in change-stack buffers) | Move it below the change below it |
change-stack-edit | e (in change-stack buffers) | Make it the working copy, to edit it |
change-stack-menu | ? (in change-stack buffers) | List the change stack’s keys and pick one |
change-stack-new | n (in change-stack buffers) | Start a new change on top of it |
change-stack-refresh | r (in change-stack buffers) | Read the stack again |
change-stack-show | enter (in change-stack buffers) | Show the change’s diff |
change-stack-split | S (in change-stack buffers) | Split it: pick the hunks that go in a change of their own before it |
change-stack-squash | s (in change-stack buffers) | Squash it into its parent, keeping the parent’s description |
change-stack-undo | u (in change-stack buffers) | Undo the last jj operation |
change-stack-up | alt-k (in change-stack buffers) | Move it above the change above it |
changes | g s (after the leader) | Show every change since the last commit in one buffer, to read, edit or put back |
first-change | [ G (every style’s command mode) | Go to the first change since the last commit |
hunk-picker-all | a (in hunk-picker buffers) | Pick every hunk, or none if all are picked |
hunk-picker-cancel | esc, q (in hunk-picker buffers) | Put back what was shown, picking nothing |
hunk-picker-done | enter (in hunk-picker buffers) | Go on with the hunks picked |
hunk-picker-toggle | space (in hunk-picker buffers) | Pick the hunk under the cursor, or put it back, and go to the next |
last-change | ] G (every style’s command mode) | Go to the last change since the last commit |
next-change | ] g (every style’s command mode) | Go to the next change since the last commit |
operation-commit | u c (after the leader) | Save the files of the latest operation (or the one being reviewed) and commit just them, named after it |
pick-changed-file | g g (after the leader) | Open a file changed since the last commit |
prev-change | [ g (every style’s command mode) | Go to the previous change since the last commit |
revert-change | g r (after the leader) | Put the change under the cursor back the way it was at the last commit |
select-around-change | m a g (helix’s command mode) | Select the lines of the change since the last commit under the cursor |
select-inside-change | m i g (helix’s command mode) | Select the text of the change since the last commit under the cursor |
stage-change | g a (after the leader) | Stage the change under the cursor for the next git commit, leaving the rest |
staged | g S (after the leader) | Show what’s staged for the next git commit, to unstage hunks or commit |
staged-commit | c (in staged-diff buffers) | Commit what’s staged |
staged-refresh | r (in staged-diff buffers) | Read what’s staged again |
staged-unstage | u (in staged-diff buffers) | Unstage the hunk under the cursor |
why-lines | g w (after the leader) | Show how the selected lines came to be: each change that made them, with its description and diff |
| Option | Default | What it does |
|---|---|---|
vcs-signs | true | Show signs beside lines changed since the last commit |
versions
When Greed would show a session that another version of Greed runs, the two can’t work together. Greed then runs a Greed of its own for this page, in the terminal or the window you started, which says so and asks what to do: end that session and start one of this version, open it with the version it runs, to save your work first, or start one beside it. Greed does what’s picked once the page closes.
1 2 3 pick that choice
enter press the button under the cursor; tab goes to the next
esc, q cancel
Uses: core, markdown, blocks.
| Command | Keys | What it does |
|---|---|---|
versions-1 | Pick choice 1 on the page about another version of Greed | |
versions-2 | Pick choice 2 on the page about another version of Greed | |
versions-3 | Pick choice 3 on the page about another version of Greed | |
versions-cancel | Leave the session another version of Greed runs as it is, and stop | |
versions-next | Go to the next button on the page about another version of Greed |
vim
Vim-style editing, written only against the plugin API. It has modes of
its own (vim, vim-insert, vim-replace and the three visual modes), beside
Helix’s, and says which plays each role: keys other plugins bind for the
command role (the language server’s, the next change) and the leader
(space) work here as in every style.
Switch to it with :style vim, or put this in ~/.config/greed/init.luau:
require("@greed").option.set("editing-style", "vim")
It reads in this order: common.luau, text helpers; motions.luau, the
motions (one table, each saying how an operator takes its range) and
marks; objects.luau, ranges and text objects; operators.luau, operators
applied through apply and the line and case tables; visual.luau, the
visual modes (block mode keeps a selection per line), with the commands
for motions and operators; then this file, with insert, replace, the
change list and U; keys.luau last. Ex commands (:s, :g, ranges) are the
command line plugin’s, and . is core’s.
Uses: core.
| Command | Keys | What it does |
|---|---|---|
vim-append | a (vim) | Insert after the cursor |
vim-append-line-end | A (vim) | Insert at the end of the line |
vim-block-append | A (vim-visual-block) | Type after the block on each of its lines |
vim-block-insert | I (vim-visual-block) | Type before the block on each of its lines |
vim-change-line | S (vim) | Change the whole line |
vim-change-newer | g , (vim) | Go to a newer place in the change list |
vim-change-older | g ; (vim) | Go to an older place in the change list |
vim-change-to-end | C (vim) | Change to the end of the line |
vim-command-line | : (vim, vim-visual) | Open the command line, with the selected lines (or the count’s) as its range |
vim-decrement | ctrl-x (vim) | Subtract the count (or 1) from the number at or after the cursor |
vim-delete-char | x (vim) | Delete the character under the cursor |
vim-delete-char-before | X (vim) | Delete the character before the cursor |
vim-delete-to-end | D (vim) | Delete to the end of the line |
vim-expand-selection | alt-o (vim, vim-visual) | Select the syntax node around the cursor or selection, in visual mode |
vim-increment | ctrl-a (vim) | Add the count (or 1) to the number at or after the cursor |
vim-insert | i (vim) | Insert before the cursor |
vim-insert-last | g i (vim) | Insert where insert mode was last left |
vim-insert-line-start | I (vim) | Insert at the first non-blank of the line |
vim-insert-one | ctrl-o (vim-insert) | Run one normal mode command, then go on typing |
vim-join | J (vim) | Join the next line onto this one, with one space |
vim-join-raw | g J (vim) | Join the next line onto this one as it is |
vim-jump-to-word | g s (vim) | Label every word on screen and jump to the one typed |
vim-macro | q (vim) | Record a macro into the register typed next, or stop recording |
vim-mark | m (vim) | Set the mark typed next (a to z here, A to Z across files) at the cursor |
vim-motion-$ | $ (vim, vim-visual) | Vim motion $ |
vim-motion-% | % (vim, vim-visual) | Vim motion % |
vim-motion-' | ' (vim, vim-visual) | Vim motion ’ |
vim-motion-( | ( (vim, vim-visual) | Vim motion ( |
vim-motion-) | ) (vim, vim-visual) | Vim motion ) |
vim-motion-+ | + (vim, vim-visual) | Vim motion + |
vim-motion-, | , (vim, vim-visual) | Vim motion , |
vim-motion-- | - (vim, vim-visual) | Vim motion - |
vim-motion-0 | 0 (vim, vim-visual) | Vim motion 0 |
vim-motion-; | ; (vim, vim-visual) | Vim motion ; |
vim-motion-B | B (vim, vim-visual) | Vim motion B |
vim-motion-E | E (vim, vim-visual) | Vim motion E |
vim-motion-F | F (vim, vim-visual) | Vim motion F |
vim-motion-G | G (vim, vim-visual) | Vim motion G |
vim-motion-H | H (vim, vim-visual) | Vim motion H |
vim-motion-L | L (vim, vim-visual) | Vim motion L |
vim-motion-M | M (vim, vim-visual) | Vim motion M |
vim-motion-T | T (vim, vim-visual) | Vim motion T |
vim-motion-W | W (vim, vim-visual) | Vim motion W |
vim-motion-^ | ^ (vim, vim-visual) | Vim motion ^ |
vim-motion-_ | _ (vim, vim-visual) | Vim motion _ |
| `vim-motion-`` | ``` (vim, vim-visual) | Vim motion ` |
vim-motion-b | b (vim, vim-visual) | Vim motion b |
vim-motion-e | e (vim, vim-visual) | Vim motion e |
vim-motion-f | f (vim, vim-visual) | Vim motion f |
vim-motion-gE | g E (vim, vim-visual) | Vim motion g E |
vim-motion-g_ | g _ (vim, vim-visual) | Vim motion g _ |
vim-motion-ge | g e (vim, vim-visual) | Vim motion g e |
vim-motion-gg | g g (vim, vim-visual) | Vim motion g g |
vim-motion-h | h (vim, vim-visual) | Vim motion h |
vim-motion-j | j (vim, vim-visual) | Vim motion j |
vim-motion-k | k (vim, vim-visual) | Vim motion k |
vim-motion-l | l (vim, vim-visual) | Vim motion l |
vim-motion-t | t (vim, vim-visual) | Vim motion t |
vim-motion-w | w (vim, vim-visual) | Vim motion w |
vim-motion-{ | { (vim, vim-visual) | Vim motion { |
| `vim-motion- | ` | | (vim, vim-visual) |
vim-motion-} | } (vim, vim-visual) | Vim motion } |
vim-multi-append | A, a (vim-multi) | Type after every selection |
vim-multi-back | ctrl-p (vim-multi) | Drop the match added last |
vim-multi-change | c, s (vim-multi) | Delete every selection and type in each place |
vim-multi-copy | y (vim-multi) | Copy every selection |
vim-multi-delete | d, x (vim-multi) | Delete every selection |
vim-multi-insert | I, i (vim-multi) | Type before every selection |
vim-multi-next | ctrl-n (vim, vim-multi) | Select the word under the cursor, or add its next match |
vim-multi-skip | ctrl-x (vim-multi) | Drop this match and add the next one instead |
vim-normal | esc (vim-insert, vim-multi, vim-visual), V, v (vim-visual), ctrl-v (vim-visual-block) | Back to normal mode |
vim-open-above | O (vim) | Open a line above and insert |
vim-open-below | o (vim) | Open a line below and insert |
vim-operator-! | ! (vim, vim-visual) | Vim operator !, followed by a motion |
vim-operator-< | < (vim, vim-visual) | Vim operator <, followed by a motion |
vim-operator-= | = (vim, vim-visual) | Vim operator =, followed by a motion |
vim-operator-> | > (vim, vim-visual) | Vim operator >, followed by a motion |
vim-operator-c | c (vim, vim-visual) | Vim operator c, followed by a motion |
vim-operator-d | d (vim, vim-visual), x (vim-visual) | Vim operator d, followed by a motion |
vim-operator-g? | g ? (vim, vim-visual) | Vim operator g?, followed by a motion |
vim-operator-gU | g U (vim), U (vim-visual) | Vim operator gU, followed by a motion |
vim-operator-gc | g c (vim, vim-visual) | Vim operator gc, followed by a motion |
vim-operator-gq | g q (vim, vim-visual) | Vim operator gq, followed by a motion |
vim-operator-gu | g u (vim), u (vim-visual) | Vim operator gu, followed by a motion |
vim-operator-gw | g w (vim) | Vim operator gw, followed by a motion |
vim-operator-g~ | g ~ (vim, vim-visual), ~ (vim-visual) | Vim operator g~, followed by a motion |
vim-operator-y | y (vim, vim-visual) | Vim operator y, followed by a motion |
vim-operator-zf | z f (vim, vim-visual) | Vim operator zf, followed by a motion |
vim-paste-after | p (vim) | Paste after the cursor, or below the line |
vim-paste-before | P (vim) | Paste before the cursor, or above the line |
vim-play-macro | @ (vim) | Play the macro in the register typed next; @@ plays the last one again |
vim-quit-unsaved | Z Q (vim) | Close without saving (ZQ) |
vim-redo | ctrl-r (vim) | Redo |
vim-replace-back | backspace (vim-replace) | Put back the character typed over last, or move left |
vim-replace-char | r (vim) | Replace the character under the cursor with the next one typed |
vim-replace-mode | R (vim) | Type over the text |
vim-replace-typed | Type over the character under the cursor | |
vim-reselect | g v (vim) | Select the last visual selection again |
vim-search-word | * (vim) | Search for the word under the cursor |
vim-search-word-back | # (vim) | Search for the word under the cursor |
vim-select-match | g n (vim) | Select the search match under the cursor, or the next one |
vim-shrink-selection | alt-i (vim, vim-visual) | Shrink the selection back, or to the first syntax node inside it |
vim-substitute | s (vim) | Change the character under the cursor |
vim-switch-case | ~ (vim) | Switch the case of the character under the cursor and move on |
vim-undo | u (vim) | Undo |
vim-undo-line | U (vim) | Put back the line last changed as it was before (U) |
vim-visual | v (vim) | Select characters, starting here |
vim-visual-around | a (vim-visual) | Select around the text object typed next |
vim-visual-block | ctrl-v (vim, vim-visual) | Select a block of columns across lines |
vim-visual-inside | i (vim-visual) | Select inside the text object typed next |
vim-visual-join | J (vim-visual) | Join the selected lines, with one space |
vim-visual-line | V (vim) | Select whole lines, starting with this one |
vim-visual-paste | P, p (vim-visual) | Replace the selection with what’s in the register |
vim-visual-replace | r (vim-visual) | Replace every selected character with the next one typed |
vim-visual-surround | S (vim-visual) | Wrap the selection in the pair typed next |
vim-visual-swap | o (vim-visual) | Go to the other end of the selection |
vscode
The vscode style: no modes, VS Code’s keys. Typing inserts text (replacing any selection), arrows move, shift and the arrows select, and the usual ctrl shortcuts do the usual things. The editing itself is core’s (core/modeless.luau), shared with any other style without modes; this plugin gives it VS Code’s keys.
Switch to it with :style vscode, or to use it all the time, put this in
~/.config/greed/init.luau:
require("@greed").option.set("editing-style", "vscode")
Uses: core, picker.
watch
Watchers: Greed’s own agent with a standing job, set up in your config, keeping an eye on chat rooms, mentions and direct messages. It wakes on new messages that match, a few at once, and escalates to you, drafts a reply for you to send, or replies on its own where you allowed it.
local watch = require("@watch")
watch.add({
name = "work",
prompt = "Escalate anything about outages; draft answers to questions for me.",
watch = { chat = { rooms = { "infra" }, mentions = true, dms = true } },
may = { reply = "draft", escalate = true },
})
A watcher runs where what it watches is kept, in the chat session, and
only there; it starts with it. A new one starts in quarantine: it reads
and decides, and logs what it would have done, but sends and drafts
nothing, until :watcher-release. :watchers lists them, each an
object to pause, turn off, run now, or read the log of.
Uses: core, picker, chat, acp, agent.
| Command | Keys | What it does |
|---|---|---|
watcher-drafts | The replies watchers drafted: pick one to send, change or drop | |
watcher-log | Show a watcher’s log | |
watcher-off | Turn a watcher off, across restarts | |
watcher-on | Turn a watcher on, out of quarantine | |
watcher-pause | Pause a watcher, for an hour or as long as you say (30m, 2h) | |
watcher-quarantine | Put a watcher back in quarantine: it reads and logs only | |
watcher-release | Let a watcher out of quarantine (turn it on) | |
watcher-resume | Resume a paused or stopped watcher | |
watcher-run | Wake a watcher now on what’s waiting | |
watcher-sign | Sign what a watcher sends on its own with a text, or off | |
watchers | Your watchers: their state; pick one to pause, turn off, run now or read its log | |
watchers-pause | Pause every watcher for an hour, or as long as you say (30m, 2h) |
Options
Set any of these in your init.luau, e.g. require("@greed").option.set("motion-hints", true), or while the editor runs with :set motion-hints true.
| Option | Default | Plugin | What it does |
|---|---|---|---|
agent-auto | false | acp | Start agent sessions in auto mode: Greed answers their questions where it can, the decision model judging commands by what you asked for, and asks you the rest; alt-a switches a session |
agent-auto-rules | "" | acp | What the decision model should know in auto mode, in plain words: what’s fine to do in your setup and what isn’t, like “deleting under /tmp is fine; never touch the prod cluster” |
agent-box | "auto model mode effort keys" | acp | What the line under an agent’s message box shows before its status, in the order it gives way when space is short: agent, auto (only when Greed answers its questions), mode (when not the one it started in), model, effort, keys, fields added with acp.box_field and “text in quotes” |
agent-care | "thorough" | acp | How Greed’s own agent gathers context: “thorough” maps what exists with helpers before design questions and says what it checked; “quick” only reads what an answer depends on |
agent-compact-at | 0 | acp | Compact conversations with Greed’s own agent once they reach this many tokens; 0 waits until they near the model’s limit |
agent-editor-context | true | acp | Send agents the file you’re in, the cursor, the selection and the other files on screen with each message |
agent-eval | "auto" | agent | How Luau from agents runs: “auto” (sandboxed, a reviewer or you for more), “ask”, “allow” or “off” |
agent-greed-tools | true | acp | Give agents Greed’s own tools (buffers, diagnostics, syntax queries, proposals) through greed mcp |
agent-heading | "model" | acp | Who the line under each of the agent’s turns says answered: its “model”, falling back to the agent’s name, or the agent’s “name” |
agent-max-thought | 8000 | acp | Stop a thought of Greed’s own agent once it passes this many tokens, before it acts, and ask for smaller steps; 0 lets thoughts run on |
agent-max-tokens | 0 | acp | Stop Greed’s own agent once a session has read and written this many tokens, every request counted; 0 sets no limit |
agent-max-turns | 0 | acp | Stop Greed’s own agent after this many steps in one prompt, for runs nobody watches; 0 lets it work until it’s done |
agent-pane-title | true | acp | Whether a panel or float showing an agent has the agent’s name as its title |
agent-sessions-kept | 50 | acp | How many sessions with Greed’s own agent are kept per repository to take up again; older ones are deleted |
agent-thoughts | true | acp | Show what agents think in their transcripts, each thought folded to its first line (tab unfolds it); /thoughts switches it |
agent-title | "agent folder workspace" | acp | What the line above an agent’s transcript says, in its order: agent, model, folder (in ~/where), workspace, fields added with acp.box_field and “text in quotes”; empty for no line |
agent-tool-groups | "plan" | agent | The tool groups agents get from the start, besides those they switch on: names with spaces between, or “all” |
agent-workspace-edits | true | acp | Let agents in a workspace of their own edit, move and delete files there without asking |
assist-role | "fast" | assist | The model role assist’s commands ask; see :models |
auto-pairs | "style" | core | Type brackets and quotes in pairs: style (as the editing style does: on in helix and vscode, off in vim), on or off |
auto-reload | true | core | Load files changed on disk into their buffers, unless they have unsaved changes |
auto-save | false | core | Save files on their own a moment after their edits stop |
auto-save-delay | 1000 | core | How long after the last edit auto-save saves, in milliseconds |
blocks-max-lines | 1000 | blocks | The most lines of output a block’s result keeps; the rest is cut |
blocks-stream | true | blocks | Show a block’s output under it as it comes, not only once it’s done; a block’s stream=false turns it off for that one |
board-card-width | 50 | board | How wide a board’s cards are at least, in columns: a wider board puts more of them side by side |
chart-height | 12 | chart | How many lines tall a chart in the shell is, unless –height says |
chat-alerts | "mentions" | chat | Which new messages tell you: mentions and direct messages, all the service notifies of, or none |
chat-alerts-desktop | false | chat | Show chat alerts as the desktop’s own notifications too (notify-send or osascript), for when no Greed is attached to tell you |
chat-list | "sidebar" | chat | Where :chat shows your rooms outside the chat session: “sidebar”, a panel on the left, or “float” |
chat-matrix-program | "" | chat | The greed-matrix program, its name on PATH or a path; empty for the one beside greed, or else on PATH |
chat-mattermost-program | "" | chat | The greed-mattermost program, its name on PATH or a path; empty for the one beside greed, or else on PATH |
chat-previews | true | chat | Show what links in chat messages lead to, under them, where the service can say |
chat-search-days | 90 | chat | How many days back each room’s messages are fetched and kept to search; newer ones are always kept |
claude-command | "claude" | agent | How the Claude pane starts Claude Code, e.g. “claude –continue” |
color-swatches | true | swatches | Show a square in their color in front of colors like #ff8800 |
completion-delay | 150 | lsp | Milliseconds of no typing before a completion menu opens by itself; 0 opens it only when asked |
completion-enter | "auto" | lsp | What enter does in a completion menu: “first” puts in the first item, “selected” only one moved to with tab or the arrows (otherwise enter does what it does without a menu, like running a shell’s line), “auto” lets each source say: the shell “selected”, language servers “first” |
data-psql | "psql" | data | The psql program the psql data source runs |
data-sqlite3 | "sqlite3" | data | The sqlite3 program the sqlite data source runs |
diagnostic-messages | true | lsp | Show each line’s worst problem after the end of the line |
editing-style | "helix" | core | How editing works: helix, vim, vscode or another style a plugin adds (see :style) |
effects | false | core | Small animations, like a wave of light through the status line when you switch files |
effects-changes | true | core | Light up text someone other than you changed, like an agent or a formatter, fading out |
effects-dim | false | core | Dim the text of the panes you’re not in |
effects-jumps | true | core | Light up the line a jump lands on, briefly |
flash-duration | 300 | flash | How long copied text flashes, in milliseconds |
float-layout | "free" | panes | How new tabs lay out their floating views: “free”, “one”, “tiled”, “cascade” or your own |
folder-hidden | false | folders | Show hidden files and folders in a folder’s buffer |
format-on-save | true | format | Format files when they’re saved |
grammar-download | true | languages | Download the grammar for a language Greed has none for when a file in it opens |
gui-font | "" | core | The font the window draws text in, by family name; empty for the system’s monospaced font |
gui-font-prose | "" | core | The proportional font the window draws prose in (styles with font = “prose”, like Markdown’s text), by family name; empty for the system’s sans-serif |
gui-font-size | 15 | core | The size of the window’s text in pixels, before the screen’s scale; zooming gives a window a size of its own |
gui-smooth-scroll | true | core | Whether the window glides a view’s text to where it scrolled, rather than jumping there |
hoard-editing-style | "vscode" | hoard | The editing style in Hoard: “vscode” types as soon as a key is pressed, without modes; “same” keeps the one the rest of Greed uses |
hoard-language-servers | false | hoard | Run Markdown’s language servers (spelling, grammar) on notes in Hoard |
hub-hosts | "" | hub | More machines whose hubs this machine’s hub follows, beside the ones you reached with greed ssh lately, as ssh hosts separated by spaces, like “eris mini” |
hub-session | "" | hub | The session that follows the others on this machine; empty for the first running one by name |
indent | " " | core | One level of indent, spaces or a tab, in languages that don’t set their own |
indent-guides | true | guides | Show a line at each level of indent |
jump-label-alphabet | "abcdefghijklmnopqrstuvwxyz" | core | The letters jump labels are made of, most comfortable first |
line-numbers | "absolute" | core | How line numbers count: “absolute”, “relative” to the cursor’s line, or “hybrid” (relative, with the cursor’s line its own number) |
link-opener | "" | core | What opens a link, e.g. “firefox”; empty for xdg-open, or open on macOS |
mail-markdown | true | Whether mail you write is Markdown, sent as what you wrote and the HTML it makes; off sends plain text alone | |
mail-program | "" | The greed-mail program that syncs your mail, its name on PATH or a path; empty for the one beside greed, or else on PATH | |
mail-threads | true | Whether a mail list shows each thread once, as its newest message found, rather than every message | |
markdown-look | true | markdown | Show Markdown with its markup hidden and its headings, code and quotes drawn as such |
markup-reveal | "cursor" | core | Where hidden markup (a field’s brackets, a link’s target) shows as written outside typing: cursor, once the cursor steps inside it; never |
models-idle-timeout | 90 | models | Seconds a model’s answer may go quiet before its request counts as failed and is tried again; the first bytes get three times as long. 0 waits for ever |
motion-hints | false | core | Number the next places a word motion would go, and go there on a digit |
notes-agent-schedule | "" | notes | Jobs Greed’s agent runs on its own, as JOB DAY HH:MM separated by commas, e.g. week friday 16:00, connect weekdays 08:00; DAY is daily, weekdays or a weekday’s name. Empty runs none |
notes-conceal | true | notes | Show links in notes without their brackets, and markup as symbols |
notes-everywhere | false | notes | Treat every Markdown file as a note: concealed links and backlinks |
notes-folder | "~/notes" | notes | The folder notes live in; ~ is your home folder |
notes-project-folder | ".greed/notes" | notes | Where a project keeps its notes, in the project: they’re named project:NAME, and the plan and decisions you share with agents are among them |
notes-remind-desktop | true | notes | Show reminders as desktop notifications with notify-send or osascript, where installed |
notes-remind-time | "09:00" | notes | When a reminder with a date and no time goes off, as HH:MM |
notes-search-case | "ignore" | core | How searching notes minds case: “smart” (only when what you type has a capital letter), “ignore”, “match”, or “default” for as search-case says |
on-quit | "auto" | core | What :q on the last project does to the session: “auto” ends it unless something is running (a command in a terminal, an agent at work) and keeps it then, “end” always ends it, “keep” always leaves it running to attach to again |
on-quit-remote | "keep" | core | Like on-quit, when you’re attached over greed ssh |
pane-layout | "manual" | panes | How new tabs arrange their panes: “manual”, “main-stack”, “columns”, “spiral” or your own |
pipe-model-role | "fast" | pipe | The model role | model: ... asks; see :models |
plugins-lock | "" | git-plugins | The lock file pinning plugins from git to commits; empty for plugins.lock in your config’s folder |
project-trust | "ask" | core | “ask”: a project you haven’t trusted runs none of its own code (its .greed config, language servers, formatting on save) until you say so, asked once when a file of it opens; “off”: every project runs them |
prometheus-url | "http://localhost:9090" | prometheus | The Prometheus server prom asks, unless –url says |
restore-after-quit | false | restore | Restore a session when it starts again after it was quit, too |
restore-session | true | restore | Open the files a session had open when it starts again after it ended without being quit, as in a crash or a restart |
rulers | "" | guides | Columns to show a ruler at, counted from 1, like “80,100”; empty for none |
scene-drawing | "auto" | scene | How charts and other scenes show: auto (as an image where the terminal can draw one, else characters) or cells (characters everywhere) |
scroll-margin | 5 | core | How many lines a view keeps in sight above and below the cursor, at most half of it (Vim’s and Helix’s scrolloff) |
search-case | "smart" | core | How searches you type mind case, unless their kind says otherwise: “smart” (only when what you type has a capital letter), “ignore” or “match” |
services-at-start | "" | service | The services that start in the background when Greed starts, names with spaces between (like mail hoard chat); the others start when first used |
session-idle-hours | 24 | core | A session nothing is attached to, with nothing running and nothing unsaved, ends after this many hours; 0 keeps it |
setup-first-start | true | setup | Show the setup page the first time a terminal or window attaches without a config |
shell-agent-max-output | 30000 | shell | How many bytes of a command’s output and of its errors the shell tools give an agent: the start and the end, with what’s between left out |
shell-aliases | true | shell | Whether a line can start with one of your shell’s aliases, read once from its startup files |
shell-ask-role | "fast" | shell | The model role a line ending or starting with ? asks for a command; see :models |
shell-blocks | true | shell | In the shell, esc and clicks in output go to blocks mode, to move between commands and rows and act on them |
shell-completion-sources | "cobra fish carapace man help" | shell | Where a shell completes a program’s arguments from, in order: cobra, fish, carapace, man, help |
shell-completion-timeout | 2000 | shell | Milliseconds a program asked for completions (kubectl, fish, carapace, –help) gets to answer |
shell-confirm-lines | 5 | shell | Running a prompt of more lines than this asks first, as after pasting a transcript |
shell-editor | true | shell | Whether programs you run in a shell, like git commit, open files to edit in Greed: $EDITOR, $VISUAL, $GIT_EDITOR, $JJ_EDITOR and $KUBE_EDITOR are greed edit –wait |
shell-environments | "devenv direnv" | shell | Which environments a shell loads in folders that bring one, in order, the first that applies winning: devenv, direnv, and those plugins add; empty for none |
shell-fallback | "" | shell | The shell that runs lines with pipes, globs and the like, e.g. “bash”; empty for your $SHELL (sh unless it’s sh, bash, zsh, dash, ksh, fish or nu) |
shell-fallback-rc | false | shell | Whether the shell running those lines reads its startup files (-i), for your aliases and functions |
shell-filter-search-case | "ignore" | core | How filtering a shell block with / minds case: “smart” (only when what you type has a capital letter), “ignore”, “match”, or “default” for as search-case says |
shell-fold-lines | 0 | shell | A block that printed more lines than this folds as it ends, unless it failed; 0 never |
shell-fold-older | false | shell | Running a command folds the finished blocks above it, except those that failed |
shell-fold-structured | 100 | shell | JSON or YAML output of more lines than this shows its top keys folded as it ends, and inside a fold still this long, the keys under it; 0 never |
shell-help-completion | "on-flag" | shell | When a shell runs a program with –help to complete its flags: on-flag (when you press tab on one) or never |
shell-help-never | "reboot shutdown halt poweroff init telinit kill killall pkill" | shell | Programs a shell never runs with –help to complete their flags |
shell-history-size | 5000 | shell | How many commands typed at shells are kept |
shell-icons | "plain" | shell | The icons of a shell’s prompt segments: “plain” ones any font has, or “nerd” ones a Nerd Font has |
shell-json-lines | "pretty" | shell | How a block whose lines are JSON objects or logfmt, as many logs are, shows them: “pretty” (time, level and message first, the other fields after) or “raw” |
shell-max-lines | 5000 | shell | How many lines of a block’s output a shell shows: the first half and the latest half |
shell-max-record | 8388608 | shell | How many bytes of a block’s output its record keeps; the rest goes to a file in the cache folder |
shell-production-contexts | "prod" | shell | Patterns for kubernetes contexts a shell’s prompt warns about, like prod; space between them |
shell-prompt | "greed" | shell | What draws a shell’s prompt before its ❯: “greed” (its own segments and folder) or “starship” (your starship prompt, when starship is installed) |
shell-suggestions | true | shell | Whether a shell’s prompt suggests the rest of a command typed before, after the cursor |
shell-watch-minutes | 60 | shell | How long a shell’s watch runs before it stops by itself, in minutes; 0 for until it’s stopped |
slides-center | false | slides | Center what’s on a slide, across and down: each heading, and the rest as one block |
slides-margin | 2 | slides | Cells left empty above and left of a slide |
slides-scale | 1 | slides | How many times bigger slides’ text is drawn, 1 to 4, in the window and in kitty, a big heading twice that; “fit” draws each slide as big as fits |
snippets-folder | "" | snippets | Where your own snippets are; empty for the snippets folder in your config’s folder |
ssh-agent-confirm | "first" | core | When to ask before a program in a session from greed ssh signs with your ssh key: never, first (once each time you attach) or always |
ssh-agent-confirm-hosts | "" | core | ssh-agent-confirm for some machines alone, by the name of the machine the session runs on: “bastion=always devbox=never” |
statusline-caps | "round" | statusline | The ends of status line pills: “round” (needs a Nerd Font) or “none” |
statusline-pills | false | statusline | Show the mode, tab, machine and session in the status line as pills in their colors |
substitute-preview | true | cmdline | Show what :s will change as you type it, before it runs |
substitute-search-case | "match" | core | How :s minds case: “smart” (only when what you type has a capital letter), “ignore”, “match”, or “default” for as search-case says |
tab-width | 4 | core | How many columns apart tab stops are, in languages that don’t set their own |
terminal-esc-wait | true | terminal | Hold esc a moment in terminals whose program draws on the normal screen, like Claude Code, so esc esc stops typing into it without the program getting an esc |
terminal-notifications | true | terminal | Whether what a program in a terminal notifies (OSC 9, OSC 777) also goes to your desktop, as Greed’s own notifications do |
terminal-scrollback | 10000 | terminal | How many lines that scrolled off a terminal’s screen are kept |
terminal-shell | "" | terminal | What a new terminal runs, e.g. “fish -l”; empty for your $SHELL |
terminal-shell-integration | true | terminal | Whether a terminal’s bash, zsh or fish gets the marks around prompts, commands and output and the folder it’s in, with nothing to set up |
text-width | 80 | core | How wide :reflow (and Vim’s gq) makes lines |
todo-comments | true | todo-comments | Pick out TODO, FIXME and the like in comments |
trash | true | core | Deleting a file or folder moves it to the trash, where there is one on the same disk |
tree-icons | "none" | tree | Icons by the names in the file tree: “none”, or “nerd” for a Nerd Font’s |
undo-files | true | core | Keep each saved file’s undo history, so undo goes on after a restart |
vcs-signs | true | vcs | Show signs beside lines changed since the last commit |
watch-interval | 10 | core | Seconds between looks at each watched object |
web-search | "" | agent | The search service agents search the web with: “brave”, “exa”, “tavily” or “searxng”; empty for none |
web-search-url | "" | agent | Where your SearXNG is, for web-search searxng |
web-sources | "" | agent | Domains whose results agents’ searches show first, like “reuters.com docs.rs”; a domain counts its subdomains too |
web-sources-only | false | agent | Agents’ searches show only results from the web-sources domains |
Luau API
What plugins and your config get from require("@greed"): the module first, then the types it hands out. Positions are 0-based byte offsets and lines are 0-based, as language servers count them.
Greed
command
command: (spec: CommandSpec) -> ()
cli
cli: (spec: CliSpec) -> ()
Adds a command line command, greed NAME ARGS; see CliSpec.
run
run: (name: string, opts: { args: { string }?, force: boolean?, count: number?, wait: boolean? }?) -> ()
Runs a command by name, optionally with arguments, force and a count.
It returns once the command waits for something (a key, a prompt, a
reply); with wait, a command or handler instead waits until it has
finished, without blocking the editor. The command can do only what
this plugin may too, unless it has “commands”.
eval
eval: (source: string, opts: { sandbox: boolean? }?) -> (boolean, string)
Runs Luau code in a scratch environment whose globals persist, like a
REPL. Returns true and the values as text (tab-separated), or false
and the error. The code has every capability; calling it needs eval
from every plugin involved. With sandbox, it runs in a fresh environment that can
read the editor and edit buffers and nothing else: what it would do
beyond that (run programs or commands, change keys, reach files) fails
with an error starting “needs approval:”.
on
on: ((event: "mode.changed", handler: (event: ModeChanged) -> ()) -> ())
& ((event: "buffer.changed", handler: (event: BufferChanged) -> ()) -> ())
& ((event: "keys.pending", handler: (event: KeysPending) -> ()) -> ())
& ((event: "command.run", handler: (event: CommandRun) -> ()) -> ())
& ((event: "lsp.diagnostics", handler: (event: DiagnosticsChanged) -> ()) -> ())
& ((event: "message", handler: (event: Message) -> ()) -> ())
& ((event: "control.request", handler: (event: ControlRequest) -> ()) -> ())
& ((event: "control.closed", handler: (event: ControlClosed) -> ()) -> ())
& ((event: "client.attached", handler: (event: ClientAttached) -> ()) -> ())
& ((event: "client.detached", handler: (event: ClientDetached) -> ()) -> ())
& ((event: "client.paste", handler: (event: ClientPaste) -> ()) -> ())
& ((event: "buffer.opened", handler: (event: BufferChanged) -> ()) -> ())
& ((event: "buffer.saved", handler: (event: BufferChanged) -> ()) -> ())
& ((event: "buffer.closed", handler: (event: BufferClosed) -> ()) -> ())
& ((event: "view.closed", handler: (event: ViewClosed) -> ()) -> ())
& ((event: "view.resized", handler: (event: ViewResized) -> ()) -> ())
& ((event: "pane.opened", handler: (event: PaneOpened) -> ()) -> ())
& ((event: "view.scrolled", handler: (event: ViewScrolled) -> ()) -> ())
& ((event: "selection.changed", handler: (event: SelectionChanged) -> ()) -> ())
& ((event: "view.focused", handler: (event: ViewFocused) -> ()) -> ())
& ((event: "ssh_agent.use", handler: (event: SshAgentUse) -> ()) -> ())
& ((event: "mouse", handler: (event: MouseEvent) -> ()) -> ())
& ((event: "option.changed", handler: (event: OptionChanged) -> ()) -> ())
& ((event: "plugin.loaded", handler: (event: PluginLoaded) -> ()) -> ())
& ((event: "file.changed", handler: (event: FileChanged) -> ()) -> ())
& ((event: "plugin.unloaded", handler: (event: PluginUnloaded) -> ()) -> ())
& ((event: "editor.started", handler: (event: {}) -> ()) -> ())
& ((event: "editor.quitting", handler: (event: {}) -> ()) -> ())
& ((event: "terminal.output", handler: (event: TerminalOutput) -> ()) -> ())
& ((event: "terminal.exited", handler: (event: TerminalExited) -> ()) -> ())
Calls handler every time event happens, until greed.off removes
it or the plugin unloads.
off
off: (event: EventName, handler: (event: any) -> ()) -> ()
Removes handler, added by this plugin with greed.on(event, handler).
Does nothing if it’s not there.
echo
echo: (...any) -> ()
Shows a message to the user.
messages
messages: () -> { string }
The last messages shown, oldest first and whole (the status line shows a message’s first line).
view
view: (() -> View) & ((id: number) -> View?)
The focused view; with an id (view:id()), that view, or nil when it’s closed.
quit
quit: () -> ()
Asks the editor to exit.
line_numbers
line_numbers: (style: "absolute" | "relative" | "hybrid") -> ()
How line numbers count, where buffers show them: each line’s own number, “relative” to the cursor’s line (0 on it), or “hybrid”, relative with the cursor’s line showing its own.
scroll_margin
scroll_margin: (rows: number) -> ()
How many rows views keep in sight above and below the cursor as they follow it, at most half the view (core sets it from the scroll-margin option).
reveal
reveal: (how: "line" | "cursor" | "never", typing: ("line" | "cursor" | "never")?) -> ()
When text hidden by marks whose reveal is “auto” shows: “line” (on a cursor’s line, the default), “cursor” or “never”, as for a mark’s own reveal; typing, the same for those whose reveal is “typing” (as how without it). Core sets them as the mode changes (see core.reveal).
detach
detach: () -> ()
Lets the attached terminal go and keeps the editor running in the
background, for greed attach to come back to.
sleep
sleep: (ms: number) -> ()
Waits ms milliseconds without blocking the editor. Works in commands
and event handlers.
spawn
spawn: (f: (...any) -> ...any, ...any) -> ()
Runs f on its own, the way a command runs, and returns at once: it can wait (greed.sleep, greed.process.run, …) while the editor and the code that started it go on. For work in the background, like a status line piece refreshing.
stalls
stalls: () -> { { ms: number, plugin: string?, what: string, time: number } }
Runs of plugin code that held the editor up (50 ms or more), newest first, for tracing a freeze to its plugin and what it was doing: a command’s name, “the status line”, “loading”. ms is how long it took; time is when, in seconds since 1970 (as os.time() counts, with a fraction).
errors
errors: () -> { { plugin: string?, what: string, message: string, traceback: string, time: number } }
Errors from plugin code that nothing caught (a command, an event handler or a task failing), newest first, up to 100: the plugin, what it ran (“on buffer.opened”, a command’s name), the message, where in its Luau it failed, and when, in seconds since 1970.
profile
profile: { start: () -> (), stop: () -> { ProfileRow }, running: () -> boolean, loading: () -> { [string]: number } }
Counting where the editor’s time goes: every run of plugin code (each command, event handler, status line) and the editor’s own work (handling a key, parsing, drawing), by plugin and what it did. start begins, stop ends and returns the rows, the most time first; running says whether one is being taken. loading is how long each plugin’s code took to load, by name, in milliseconds, profile or not.
debug
debug: Debug
Debug lines and their topics, for seeing what the editor and plugins do: :debug and :debug-log use them.
See Debug.
now
now: () -> number
Milliseconds on the editor’s clock, for timing animations. While a timer wakes code, it reads the time the timer was due.
hostname
hostname: () -> string?
This machine’s name, or nil if the system doesn’t say.
animate
animate: (ms: number, step: (t: number) -> ()) -> ()
Calls step(t) about once a frame for ms milliseconds, with t
going from 0 to 1, e.g. to fade a theme color or move a decoration.
Works in commands and event handlers.
next_key
next_key: () -> string
Waits for the next key press and returns its name, e.g. “g” or “ctrl-s”. The key doesn’t run anything. Works in commands and event handlers.
keys
keys: Keys
See Keys.
process
process: Process
See Process.
rpc
rpc: Rpc
See Rpc.
http
http: Http
See Http.
secrets
secrets: Secrets
See Secrets.
terminal
terminal: Terminals
See Terminals.
image
image: Images
See Images.
scene
scene: Scenes
See Scenes.
pdf
pdf: Pdfs
See Pdfs.
html
html: Htmls
See Htmls.
signal
signal: () -> Signal
A one-shot value that one piece of code waits for and another sends,
e.g. a tool waiting for the user’s review. wait works in commands and
event handlers; a value sent before anyone waits is kept for them.
vouch
vouch: <A..., R...>(f: (A...) -> R..., A...) -> R...
Runs f with ... as your plugin’s own action: only your capabilities count for what it does, not those of the plugins whose code called you or started what runs. For services that check what they do themselves, like the models plugin sending a key only to its provider. Anything you vouch for, any plugin can make you do: vouch only for narrow, checked operations. It can wait.
statusline
statusline: (build: (ctx: StatusContext) -> StatusParts) -> ()
Sets the function that builds the status line. It runs for every frame.
object_finder
object_finder: (find: (kind: string, text: string) -> (any, string?)) -> ()
Sets the function typed commands find an “object” argument with: the object of kind the user typed text for, or nil and why not. It runs in the command, so it can wait. The core plugin sets it from core.objects.
set_menus
set_menus: (menus: { { title: string, items: { { label: string, command: string } } } }) -> ()
Sets the menus a window shows as its menu bar (on macOS, the system’s), replacing those before; each item runs its command. The core plugin keeps them, so add to require("@core").menus rather than calling this.
create_buffer
create_buffer: (kind: string, text: string?, opts: { readonly: boolean?, language: string? }?) -> Buffer
A new buffer that isn’t shown anywhere yet. It goes away when the last view showing it closes.
language_of
language_of: (path: string) -> string?
The language of the file at path, by its name or extension.
filetype
filetype: (language: string, spec: { extensions: { string }?, names: { string }? }) -> ()
Makes files with these extensions (without the dot) or exact names, like
“Makefile”, be in language, replacing whatever it had before.
grammars
grammars: () -> { string }
The languages Greed has a grammar for, built in or loaded, sorted.
which
which: (program: string) -> string?
Where program is on PATH, or nil if it isn’t installed.
float
float: (buffer: Buffer, spec: FloatSpec?) -> View
Shows buffer in a view floating over the main one, and focuses it.
floats
floats: (opts: { hidden: boolean? }?) -> { View }
The floating views shown, the one in front last; with hidden = true, the hidden ones too.
panel
panel: (buffer: Buffer, spec: { side: ("left" | "right")?, width: (number | string)?, title: string?, focus: boolean? }?) -> View
Shows buffer in a panel beside the main view, which gives up the
room. Defaults: the left side, 30 cells wide, focused. Close it with
view:close().
buffers
buffers: () -> { Buffer }
Every open buffer.
buffer
buffer: (id: number) -> Buffer?
The buffer with id id (buffer:id()), or nil when it’s closed.
open
open: (path: string) -> ()
Opens a file in the main view.
load
load: (path: string) -> Buffer
The buffer for the file at path, opening it without showing it.
buffer_for
buffer_for: (path: string) -> Buffer?
The open buffer for the file at path, or nil when it isn’t open; it
doesn’t open it. ~, . and .. are worked out and a relative path
is from the folder Greed started in, so every spelling of a file
finds its buffer.
diff
diff: (old: string, new: string) -> { { from: number, to: number, text: string } }
The changes that turn old into new, whole lines at a time: each
replaces from..to (byte offsets into old) with text. Sorted.
commands
commands: () -> { CommandInfo }
Every command, sorted by name.
handlers
handlers: () -> { HandlerInfo }
Every event handler, by event and then the order they were added.
fuzzy
fuzzy: (query: string, items: { string }, opts: { case: ("smart" | "ignore" | "match")? }?) -> { number }
The 1-based indices of items that match query, best first. case says how it minds case: “smart” (the default: only when query has a capital letter), “ignore” or “match”; core.search.case() gives what the user chose.
fuzzy_positions
fuzzy_positions: (query: string, text: string, opts: { case: ("smart" | "ignore" | "match")? }?) -> { number }
The byte offsets of the characters in text that query matches,
for highlighting them; empty if it doesn’t match. case as for fuzzy.
files
files: (dir: string?) -> { string }
Files under dir (default: the current directory), relative to it and sorted, skipping hidden
and ignored files. Walked in the background while the caller can wait (a command, a handler,
greed.spawn), so a big project doesn’t hold up the editor.
keymap
keymap: Keymap
See Keymap.
mode
mode: Mode
See Mode.
option
option: Options
See Options.
history
history: History
See History.
clipboard
clipboard: Clipboard
See Clipboard.
base64
base64: { encode: (bytes: string) -> string, decode: (text: string) -> string? }
Base64, as data goes in JSON, like an image for a model: encode takes bytes, decode gives them back, or nil for text that isn’t base64.
client
client: Client
See Client.
lsp
lsp: Lsp
See Lsp.
fs
fs: Fs
See Fs.
hash
hash: Hash
See Hash.
compare
compare: Compare
See Compare.
query
query: Query
See Query.
index
index: IndexModule
See IndexModule.
text
text: Text
See Text.
control
control: Control
See Control.
json
json: Json
See Json.
sikt
sikt: Sikt
See Sikt.
project
project: Projects
See Projects.
tab
tab: Tabs
See Tabs.
session
session: Sessions
See Sessions.
ssh_agent
ssh_agent: SshAgent
See SshAgent.
plugin
plugin: Plugins
See Plugins.
syntax
syntax: Syntax
See Syntax.
theme
theme: Theme
See Theme.
Range
A range of text. anchor is where it started and head is where the
cursor is; a cursor is a range where the two are equal.
anchor
anchor: number
head
head: number
Selection
One or more ranges, sorted and never overlapping. primary is the
1-based index of the main range.
ranges
ranges: { Range }
primary
primary: number
Edits
Collects the edits made inside Buffer:edit. They are applied together,
as one undoable change, when the callback returns.
insert
insert: (self: Edits, pos: number, text: string) -> ()
delete
delete: (self: Edits, from: number, to: number) -> ()
replace
replace: (self: Edits, from: number, to: number, text: string) -> ()
select
select: (self: Edits, selection: Selection) -> ()
Sets the selection after the edit (of every view showing the buffer, when the buffer didn’t come from a view). Without this, the current selection is moved along with the text: a cursor ends up after text inserted where it is, and after the new text of a replace or delete that covers it; a range doesn’t grow to take in text inserted at its edges.
Buffer
Open text, backed by a file or not. Two handles to the same buffer are
equal (==).
id
id: (self: Buffer) -> number
Its id, even after it was closed.
valid
valid: (self: Buffer) -> boolean
Whether it is still open. Other methods fail once it was closed.
len
len: (self: Buffer) -> number
Length in bytes.
text
text: (self: Buffer) -> string
slice
slice: (self: Buffer, from: number, to: number) -> string
line_count
line_count: (self: Buffer) -> number
line_of
line_of: (self: Buffer, pos: number) -> number
The line pos is on.
line_start
line_start: (self: Buffer, line: number) -> number
line_end
line_end: (self: Buffer, line: number) -> number
The end of line, before its line break.
line_text
line_text: (self: Buffer, line: number) -> string
The text of line, without its line break.
display_column
display_column: (self: Buffer, pos: number, tab_width: number?) -> number
The screen column pos is drawn at in its line: wide characters take two columns and tabs reach the next tab stop, every tab_width columns (the buffer’s own if not given).
at_display_column
at_display_column: (self: Buffer, line: number, col: number, tab_width: number?) -> number
The position in line drawn at screen column col: the start of the character covering it, or the line’s end if the line is shorter.
char_at
char_at: (self: Buffer, pos: number) -> string?
The character at pos, or nil at the end of the buffer.
next_char
next_char: (self: Buffer, pos: number) -> number
prev_char
prev_char: (self: Buffer, pos: number) -> number
sentence
sentence: (self: Buffer, pos: number) -> (number, number)
The start and end of the sentence around pos, without the spaces
after it. Sentences end at blank lines.
kind
kind: (self: Buffer) -> string
What the buffer is: “file”, “terminal”, …
path
path: (self: Buffer) -> string?
project
project: (self: Buffer) -> number?
The id of the project it was opened in.
readonly
readonly: (self: Buffer) -> boolean
True if only plugins can change the text: edits from keys and undo are refused.
set_readonly
set_readonly: (self: Buffer, readonly: boolean) -> ()
readonly_before
readonly_before: (self: Buffer) -> number?
Where the read-only start of the text ends, when only its start is (set_readonly_before).
set_readonly_before
set_readonly_before: (self: Buffer, pos: number?) -> ()
Makes the text before pos read-only, like set_readonly, and the rest writable, as a transcript above the box you write in; nil makes it all writable. The place moves with edits: what plugins insert there joins the read-only part, what you type there doesn’t. Typing and pasting with a cursor in the read-only part go to the end (core.writable).
name
name: (self: Buffer) -> string?
The name it was given, for a buffer without a file, like a terminal’s “nu ~/src”.
set_name
set_name: (self: Buffer, name: string?) -> ()
Names it where it shows (the tab line, float titles, the status line); nil or “” leaves it unnamed.
title
title: (self: Buffer) -> string
What it’s called where it shows: its file’s name, the name it was given, “untitled” for a file not saved yet, or its kind.
line_numbers
line_numbers: (self: Buffer) -> boolean
Whether the main view shows line numbers beside it (the default).
set_line_numbers
set_line_numbers: (self: Buffer, on: boolean) -> ()
at_bottom
at_bottom: (self: Buffer) -> boolean
Whether its views show it against their bottom edge while it’s shorter than them, as a chat’s messages sit on its box, and never scroll past its end; off by default, from the top.
set_at_bottom
set_at_bottom: (self: Buffer, on: boolean) -> ()
tab_width
tab_width: (self: Buffer) -> number
How many columns apart its tab stops are, as it’s drawn; 4 until set. Core sets it from the language or the “tab-width” option.
set_tab_width
set_tab_width: (self: Buffer, width: number) -> ()
Sets how many columns apart its tab stops are, at least 1.
views
views: (self: Buffer) -> { View }
The views showing it.
kept
kept: (self: Buffer) -> boolean
Whether it stays open while nothing shows it, though it has no file.
set_kept
set_kept: (self: Buffer, kept: boolean) -> ()
Keeps it open while nothing shows it, like a terminal to come back to; with false it goes once nothing shows it (right away if nothing does now).
set_screen_size
set_screen_size: (self: Buffer, size: { rows: number, cols: number, note: string?, cursor_row: number? }?) -> ()
Lays the text out at rows by cols in every view, whatever room a view has, like a terminal whose program has one screen size for one client: the screen is the buffer’s last rows lines. A client whose view is another size crops it (a terminal), keeping row cursor_row (0-based, where the program’s cursor is) in sight, or scales it (a window), and shows note (default “COLSxROWS”) in the room left over. nil lays it out at each view’s own size again.
screen_size
screen_size: (self: Buffer) -> { rows: number, cols: number, note: string?, cursor_row: number? }?
The size set_screen_size set, if any.
set_keys
set_keys: (self: Buffer, keys: { [string]: string }?) -> ()
Binds single keys for this buffer alone, e.g. { y = "answer-yes" }, in every mode and ahead of every other binding, while it has focus. Replaces what was bound for it before; nil drops them.
forget_history
forget_history: (self: Buffer) -> ()
Stops keeping undo history, for buffers whose edits nobody undoes, like a terminal’s: what’s kept goes, and later edits aren’t kept.
clear_history
clear_history: (self: Buffer) -> ()
Lets go of the undo history so far and keeps later edits: undo can’t go back past now, as at a shell’s prompt after a command runs.
language
language: (self: Buffer) -> string?
The language the text is highlighted as, e.g. “rust”.
set_language
set_language: (self: Buffer, language: string?) -> ()
Sets the language, or with nil goes back to the one the file’s extension implies.
tree
tree: (self: Buffer) -> Node?
The root of the syntax tree, or nil if the language has no grammar or the buffer is too big to parse. Just after an edit, when parsing again would hold the editor up, it’s the tree before with the edit applied (nodes moved with the text) until the new one is in.
node_at
node_at: (self: Buffer, from: number, to: number?) -> Node?
The smallest named node covering from..to (default: just from).
query
query: (self: Buffer, source: string, range: { from: number?, to: number? }?) -> { { [string]: Node } }
Runs a tree-sitter query over the buffer, or only for matches
overlapping from..to, e.g.
"(function_item name: (identifier) @name) @fn". One table per
match, from capture name to node. Errors on a query the language’s
grammar can’t compile; a buffer without a grammar has no matches, so
any query gives an empty list there.
edit
edit: (self: Buffer, f: (e: Edits) -> (), opts: { undo: boolean? }?) -> ()
Edits the buffer: f records edits on e, and they are applied
together, as one undoable change, when it returns. With undo = false
the change isn’t kept to undo, like output streaming in above where
someone types: undo skips it and still takes back only what the
steps before it did (redo branches are dropped).
save
save: (self: Buffer, path: string?) -> ()
Writes the buffer to its file, or to path, which becomes its file.
modified
modified: (self: Buffer) -> boolean
True if the text changed since it was opened or last saved.
version
version: (self: Buffer) -> number
A number that grows with every edit, for caches that follow the text.
reload
reload: (self: Buffer) -> boolean
Reads its file again, as an edit by “external” that undo can take back, and counts it as saved. Returns whether the text changed.
close
close: (self: Buffer) -> ()
Closes the buffer, unsaved changes and all. Errors while a view shows it: show something else there first. Plugins hear “buffer.closed”.
decorate
decorate: (self: Buffer, ns: string, marks: { Mark }, within: { from: number, to: number? }?) -> ()
Replaces the marks in namespace ns (pick one per plugin feature,
e.g. “search”). Marks move with edits; {} clears them. With
within, only those starting from from up to (not at) to (default:
the end) are replaced, e.g. on the lines an edit changed.
decorations
decorations: (self: Buffer, ns: string) -> { Mark }
The marks in namespace ns, where they are now.
marks_at
marks_at: (self: Buffer, pos: number) -> { Mark & { ns: string } }
The marks over pos in every namespace, each with its ns: those
whose range holds it, and empty ones that start there.
track
track: (self: Buffer, pos: number, opts: { gravity: ("left" | "right")? }?) -> Anchor
Follows pos through edits. Text inserted exactly there goes before it with gravity = "right" (the default) and after it with “left”. Deleting text around it moves it to where the deletion was.
track_range
track_range: (self: Buffer, from: number, to: number, opts: { from: ("left" | "right")?, to: ("left" | "right")? }?) -> Tracked
Follows from..to through edits. from and to in opts are each end’s gravity, as for track; by default text inserted at either end stays outside. It’s deleted once all of its text is.
find
find: (self: Buffer, pattern: string, from: number?, opts: { backward: boolean?, wrap: boolean? }?) -> (number?, number?, string?)
The first match of the regex pattern starting at or after from
(default 0), or with backward the last one starting before it; wrap
goes round the other end. Returns its start and end, nil when nothing
matches, or nil, nil and the error for a bad pattern.
find_all
find_all: (self: Buffer, pattern: string, from: number?, to: number?) -> ({ { from: number, to: number } }?, string?)
Every match of the regex pattern between from and to (default:
the whole buffer), or nil and the error for a bad pattern.
kept_lines
kept_lines: (self: Buffer, filter: string, opts: { regex: boolean?, query: any?, section: string?, case: boolean?, from: number?, to: number? }?) -> { number }
The lines (0-based) a view’s filter of filter keeps of the buffer, with the same options as View.set_filter; of lines from to to (inclusive) only, with them.
find_groups
find_groups: (self: Buffer, pattern: string, from: number?, to: number?) -> ({ { { from: number, to: number } | false } }?, string?)
Like find_all, but each match is the whole match’s range followed by
each group’s, false for a group that took no part.
history
history: (self: Buffer, filter: HistoryFilter?) -> { HistoryEntry }
The transactions applied to it, newest first: by author (“user”, “plugin”,
“agent” or “external”), plugin, cause (the command that made them, “undo”,
…), group, made at or after since (seconds, like time), at most limit.
text_before
text_before: (self: Buffer, id: number) -> string?
The text as it was before transaction id, or nil if the buffer has none by
that id.
undo_tree
undo_tree: (self: Buffer) -> { nodes: { UndoNode }, current: number }
The undo tree: every state the text has been in, from node 0 (as it was loaded) on, each with the step before it as parent; undo goes to the parent and redo to the last child. current is the node the text is at.
undo_save
undo_save: (self: Buffer) -> string?
The undo tree as JSON, to keep it for after a restart; nil when nothing was done or the buffer keeps no undo history.
undo_restore
undo_restore: (self: Buffer, json: string) -> (boolean, string?)
Takes back an undo tree undo_save gave, for the text as it is now, as its current step: only while nothing was done since the buffer was loaded, and only if every step fits. Returns whether it did, and why not.
Node
A node in a buffer’s syntax tree, from buffer:tree(), buffer:node_at() or
buffer:query(). It describes the buffer as it was when found; after an edit,
find it again. tostring(node) shows its subtree, handy for writing queries.
kind
kind: string
The grammar’s name for it, e.g. “function_item” or “(”.
from
from: number
to
to: number
named
named: boolean
False for punctuation and keywords the grammar doesn’t name.
error
error: boolean
True for text the grammar couldn’t parse, or a missing piece it assumed.
field
field: string?
Its field name in its parent, e.g. “name” or “body”, if it has one.
parent
parent: (self: Node) -> Node?
children
children: (self: Node) -> { Node }
named_children
named_children: (self: Node) -> { Node }
Its children without the unnamed ones (punctuation, keywords).
child
child: (self: Node, field: string) -> Node?
The child in field field, e.g. fn:child("body").
next
next: (self: Node) -> Node?
The next named sibling.
prev
prev: (self: Node) -> Node?
The previous named sibling.
text
text: (self: Node) -> string
Its text. Errors if the buffer changed since the node was found.
Anchor
A position that moves with edits, from buffer:track. It goes when forgotten, when its buffer closes, or when the plugin that made it is unloaded.
pos
pos: (self: Anchor) -> number?
Where it is now, or nil once it’s gone.
forget
forget: (self: Anchor) -> ()
Stops following it.
Tracked
A range that moves with edits, from buffer:track_range. It goes as an Anchor does.
range
range: (self: Tracked) -> (number?, number?)
Where it is now, or nil once its text was deleted or it’s gone.
deleted
deleted: (self: Tracked) -> boolean
Whether all of its text was deleted, or it’s gone. Undo bringing the text back doesn’t change that.
forget
forget: (self: Tracked) -> ()
Stops following it.
MarkLine
A line a mark shows under its range: text, or pieces with styles of their own. On a float’s border (label, footer), a piece’s action is a command that a click on it runs, with any arguments after its name (“float-go 3”).
MarkLine = string | { { text: string, style: string?, action: string? } }
Mark
Text drawn with a style name, e.g. { from = 6, to = 11, style = "match" }.
Text typed at either edge stays outside it.
from
from: number
to
to: number
style
style: string
line
line: boolean?
Style every whole line the mark touches, not just its text.
text
text: string?
Text to show that isn’t in the buffer, like an inlay hint, before the
character at from. The cursor skips over it.
eol
eol: boolean?
Show text after the end of the line instead, cut off at the edge.
sign
sign: string?
A symbol for the sign column next to the line numbers, e.g. “E”.
gutter
gutter: string?
A style for the line number of each line the mark touches, e.g. “ui.gutter.diagnostic.error”.
above
above: boolean?
Draw over selections and cursors rather than under them.
overlay
overlay: boolean?
Draw text over the characters from from instead of inserting it,
like a jump label. The text doesn’t move. Past a line’s end it goes
on over the empty room there, after any eol text, a space only
moving what follows along, so several can share it (like rulers).
wrapped
wrapped: boolean?
With text at the start of a line, draw it again at the start of
each row the line wraps onto, like the bar beside a card.
conceal
conceal: boolean?
Hide the text, showing text (if any) in its place, e.g. the
brackets of a [[link]], except where reveal says.
reveal
reveal: ("line" | "cursor" | "never" | "auto" | "typing")?
When concealed text shows: “line” (the default) when a cursor is on its line, “cursor” when a cursor is inside it past its start (a click leaves it hidden), “never”, “auto” as greed.reveal last said, so the marks needn’t be drawn again when that changes, or “typing” as it said for markup that shows only while typing, like a table’s borders.
fold
fold: boolean?
Hide the lines after the first one, up to the last, unless a cursor is in them, like a section folded under its heading.
peek
peek: boolean?
With fold, show the lines while a cursor is on the first line too, as a part hidden under the line that says when it shows.
nowrap
nowrap: boolean?
Don’t wrap the lines it touches: what’s past the right edge is out of sight, and the view scrolls sideways to the cursor (view:side_scroll()), as for a wide table.
plain
plain: boolean?
Draw the text without syntax highlighting, like a tool’s output in a Markdown buffer.
language
language: string?
Highlight the text as this language, by name or file extension (“bash”, “rs”), over the buffer’s own, like a command in a line that’s no language at all. Languages inside it are found too.
lines
lines: { MarkLine }?
Lines shown under the last line that aren’t in the buffer, like
backlinks. The cursor never goes on them. Each is a string, or pieces
with styles of their own on top of the mark’s, e.g.
{ { text = "x = " }, { text = "2", style = "diff.plus.change" } }.
image
image: { id: number, cols: number, rows: number, col: number?, row: number? }?
An image (from greed.image) drawn over cols by rows cells right
of and below from, whatever text is there. col and row say
which of its cells is at from, for an image cut off at the top or
left. Shown in terminals that can show images.
scene
scene: { id: number, cols: number, rows: number, col: number?, row: number? }?
A scene (from greed.scene) drawn over cols by rows cells right of and below from by the clients that can draw one, as an image is; the text there is what the others show, so put the scene in characters there. col and row are as for an image; a negative row starts it that many rows below from.
action
action: string?
A command that clicking text runs, with the cursor put at from
first, so the text works as a button, e.g. “proposal-accept”.
scale
scale: number?
How many times bigger the range’s text (and text) is, 1 to 4, e.g. 2 for a heading: each character takes that many cells across, and its row that many rows down. The window draws it big, and so does kitty (its text sizing); other terminals show it at the normal size.
data
data: any?
Anything to keep with the mark, given back where it is read: plain data (tables, strings, numbers, booleans), never drawn.
View
A buffer shown on screen, with its own selection. Two handles to the
same view are equal (==).
id
id: (self: View) -> number
Its id, even after it was closed.
valid
valid: (self: View) -> boolean
Whether it is still open. Other methods fail once it was closed.
decorate
decorate: (self: View, ns: string, marks: { Mark }, within: { from: number, to: number? }?) -> ()
buffer:decorate for marks only this view draws, like blame for the line its cursor is on. It replaces only this view’s marks in ns; they go when the view closes.
selection
selection: (self: View) -> Selection
set_selection
set_selection: (self: View, selection: Selection) -> ()
cursor
cursor: (self: View) -> number
The head of the primary selection.
set_cursor
set_cursor: (self: View, pos: number) -> ()
Makes the selection a single cursor at pos.
visible
visible: (self: View) -> (number, number)
The start and end of the text on screen when the view was last drawn, or of the whole buffer before that.
size
size: (self: View) -> (number?, number?)
The rows and columns of text it had room for when last drawn; nil before it’s drawn. “view.resized” says when they change.
area
area: (self: View) -> { x: number, y: number, width: number, height: number }?
Where it was last drawn on the screen, in cells, its gutter included; nil before it’s drawn.
drawn_column
drawn_column: (self: View, pos: number) -> number
The column pos is drawn at in its line in this view, the line as one long row: hidden text (a table’s pipes, a link’s brackets) takes no room and text marks show takes theirs, as it looks now. Vertical moves aim for it, so a table’s column is kept.
at_drawn_column
at_drawn_column: (self: View, line: number, col: number) -> number
The position drawn at column col of line in this view, the line as one long row: the text there, or where the text drawn next starts when col is on text a mark shows or past the line’s end.
hidden_lines
hidden_lines: (self: View) -> { { from: number, to: number } }
The lines folds hide, and those outside the lines it is narrowed to, 0-based and inclusive.
narrow
narrow: (self: View, from: number?, to: number?) -> ()
Shows only lines from to to (0-based, inclusive) of its buffer, as a float showing one part of it; no arguments shows all of it again. Showing another buffer does too.
set_keys
set_keys: (self: View, keys: { [string]: string }?) -> ()
Binds single keys for this view alone, e.g. { right = "slide-next" }, in every mode and ahead of its buffer’s keys and every other binding, while it has focus; other views of the buffer keep theirs. Replaces what was bound for it before; nil drops them.
hide_marks
hide_marks: (self: View, namespaces: { string }?) -> ()
Leaves the marks in these namespaces out of what this view draws, e.g. { "lsp" } for slides without the problems’ squiggles; other views of the buffer still draw them. Replaces the list it had; nil or empty draws them all again.
set_padding
set_padding: (self: View, padding: { top: number?, left: number? }?) -> ()
Leaves rows empty above its text and cells empty left of it, e.g. { top = 4, left = 8 } for a slide’s margin; size() is then the room inside. Nil takes it away.
hide_cursor
hide_cursor: (self: View, hidden: boolean?) -> ()
Draws no cursor or selection of its own in this view (false draws them again), like a slide of text; the cursor is still there and moves.
narrowed
narrowed: (self: View) -> (number?, number?)
The first and last line it’s narrowed to, or nil when it shows all of its buffer.
set_filter
set_filter: (self: View, text: string?, opts: { regex: boolean?, query: any?, section: string?, case: boolean?, skip: number? }?) -> ()
Shows only the lines a filter keeps, among those it shows past the first skip; the others stay in the buffer, hidden in this view alone. text is what was typed, given back by filter(); with regex it’s a regex. Otherwise the lines query matches, a query core.query parsed (as the shell’s filters read one: query.luau there): its words anywhere in a line (minding case with case), its fields those of a line of JSON (dotted paths, through arrays) or logfmt, compared as greed.compare does, and key=value found in the text of other lines; without a query, every word of text. A section (“status.conditions”) keeps the indented text (YAML, indented JSON) under those keys, with the keys above what shows. A line with a cursor on it shows anyway. Nil or empty shows every line again, and so does showing another buffer.
filter
filter: (self: View) -> string?
What set_filter was given, while it filters.
side_scroll
side_scroll: (self: View) -> number
How many columns the lines that don’t wrap (a mark’s nowrap) are scrolled to the left.
set_side_scroll
set_side_scroll: (self: View, columns: number) -> ()
Scrolls the lines that don’t wrap columns to the left. Drawing scrolls again if the primary cursor is on such a line and would be out of sight, so move it first.
scroll
scroll: (self: View) -> number
The 0-based line at the top of the view.
set_scroll
set_scroll: (self: View, line: number) -> ()
Scrolls so line is at the top. Drawing scrolls again if the primary
cursor would be off screen, so move it first.
buffer
buffer: (self: View) -> Buffer
show
show: (self: View, buffer: Buffer) -> ()
Shows another buffer in this view, where the view left it if it showed it before, otherwise at the top.
focus
focus: (self: View) -> ()
Focuses this view, so keys go to it, showing its tab and project if it’s a pane or panel.
close
close: (self: View) -> boolean
Closes the view. Closing a tab’s last pane closes the tab; the project’s last pane can’t be closed, and returns false.
configure
configure: (self: View, spec: FloatSpec) -> boolean
Changes how a floating view is shown; fields left out stay as they are. False, changing nothing, if it isn’t floating; fails if it was closed.
set_title
set_title: (self: View, title: string?) -> boolean
Gives a panel or floating view the title title, nil or “” for none; false if it’s neither.
raise
raise: (self: View) -> boolean
Brings a floating view in front of the other floats; false if it isn’t floating.
float_spec
float_spec: (self: View) -> FloatSpec?
How a floating view is shown, as greed.float takes it; nil if it isn’t floating.
is_pane
is_pane: (self: View) -> boolean
Whether it’s a pane of a tab, rather than a panel or a floating view.
split
split: (self: View, dir: "left" | "right" | "up" | "down", buffer: Buffer?) -> View
Opens a pane beside this one on its dir side, showing buffer, or
this view’s buffer as it shows it, and focuses it. Fails if this
view isn’t a pane.
neighbor
neighbor: (self: View, dir: "left" | "right" | "up" | "down") -> View?
The pane next to this one on its dir side, as last drawn: of
several, the one active most recently.
resize
resize: (self: View, dir: "left" | "right" | "up" | "down", cells: number) -> boolean
Moves this pane’s edge on its dir side by cells (negative to
shrink). False when no pane is on that side. A panel moves the edge by the main view, and only that.
undo
undo: (self: View) -> boolean
Undoes the last change. Returns false if there was nothing to undo.
undo_to
undo_to: (self: View, id: number) -> boolean
Takes the buffer to node id of its undo tree, undoing and redoing on the way, as one move; redo follows that branch from then on. False if there’s no such node or the text is there already.
redo
redo: (self: View) -> boolean
Context
What a command gets when it runs.
view
view: View
See View.
buffer
buffer: Buffer
See Buffer.
keys
keys: string?
The keys that ran the command, e.g. “g g”.
char
char: string?
The character typed, when a single printable key ran the command.
args
args: { string }
Arguments, e.g. from the command line; empty when a key ran it.
values
values: { [string]: any }
The arguments by name: for a typed command, parsed (a number, a boolean, a full path, the core.Object), nil for an optional one left out; otherwise the words as given.
force
force: boolean
Go ahead even if the command would normally refuse, like :q!
quitting with unsaved changes.
count
count: number?
The number typed before the keys, in modes with counts on.
client
client: number
The id of the client it runs for, whose view and selections these are.
ArgSpec
An argument a command takes, for completion, help and checking. Giving any of a command’s arguments a type has them all checked before it runs, and parsed into ctx.values.
name
name: string
doc
doc: string?
complete
complete: string?
What completes it, e.g. “file”, “command”, “option” or “buffer”. Without it, the command line completes from type.
type
type: string?
What it is: “string” (the default), “number”, “boolean” (true/false, yes/no, on/off), “file” or “folder” (one that exists, from the project’s root), “choice” (one of choices), “object” (an object of kind, as core.objects has them), or “rest” (the rest of the words, joined by spaces; last only).
optional
optional: boolean?
It can be left out; every argument after it must be optional too.
choices
choices: { string }?
The words a “choice” can be.
kind
kind: string?
The kind of object an “object” is, e.g. “note” or “pod”.
CommandSpec
name
name: string
Plain words with dashes, e.g. “select-line”.
doc
doc: string?
args
args: { ArgSpec }?
run
run: (ctx: Context) -> ()
CliSpec
A command for the command line, run as greed NAME ARGS in an editor
with no screen. run can wait like a command; what it echoes and
returns is printed, and an error makes greed fail.
name
name: string
Plain words with dashes, e.g. “bring”.
doc
doc: string?
usage
usage: string?
What follows the name, e.g. “HOST [PLUGIN]”.
run
run: (args: { string }) -> string?
Layer
A keymap layer. Leave mode or kind out to match any. In place of a
mode: layer names a layer that isn’t a mode, like the “leader”, which
every editing style enters its own way (space, or ctrl-space
without modes); role is an editing role (“command”, “typing”,
“selecting”) in every style, and with style in that style only.
mode
mode: string?
layer
layer: string?
role
role: string?
style
style: string?
kind
kind: string?
Keymap
bind
bind: (layer: string | Layer, bindings: { [string]: string }) -> ()
Binds key sequences to command names, e.g. { ["g g"] = "goto-start" }.
layer is a mode name or a Layer.
unbind
unbind: (layer: string | Layer, keys: { string }) -> ()
Hides what each key sequence runs in layer, e.g. { "w", "g g" }.
Removing (or reloading) the plugin that unbound them brings them back.
clear
clear: (layer: string | Layer) -> ()
Hides everything bound in layer so far, to start it over. Bindings
made afterwards, by any plugin, apply as usual.
counts
counts: (mode: string) -> ()
Makes digits typed before a key sequence in mode a count, which the
command gets as ctx.count. A leading 0 stays a key.
isolate
isolate: (mode: string) -> ()
Makes mode use only keys bound in it (and its fallback), skipping
inherited ones and those bound for every mode or for a buffer kind,
e.g. for a terminal that takes every key.
inherit
inherit: (mode: string, parent: string | Layer, prefixes: { string }?) -> ()
Makes mode fall back to parent’s keys for sequences starting with
one of prefixes (e.g. { "space", ":" }), or for every key without
them. Keys bound in mode itself come first; what parent inherits
applies in turn. parent can be a layer like { role = "typing" }.
inherit_first
inherit_first: (mode: string, parent: string | Layer) -> ()
Makes mode use parent’s keys ahead of its own, e.g. { style = "vim", role = "command" } for the Vim style’s command mode. core.style.define does this for each style’s roles.
enter
enter: (mode: string, keys: string, layer: string) -> ()
Makes keys typed in mode lead into layer, so what’s bound there works after them, e.g. enter("helix", "space", "leader"). It comes ahead of the mode’s own keys. core.style.define does this for each style’s leader.
fallback
fallback: (mode: string, command: string) -> ()
The command that handles a single unbound key in mode. A mode without one uses that of a mode it inherits every key from.
next
next: (keys: string?) -> { { key: string, command: string? } }
The keys that can follow keys (e.g. “space”) in the current mode, and
the command each runs. Keys without a command start longer sequences.
find
find: (command: string?) -> { { layer: string, keys: string, command: string } }
Every key sequence that runs command (every binding, without one),
the layer it’s bound in (a mode name, a named layer like “leader”,
“role:typing” or “vim:command”, or “global”) and its command.
active
active: () -> { { keys: string, command: string } }
Every key sequence that runs a command in the current mode and buffer, through the layers it enters and inherits (the leader’s as “space f”), less those a more specific layer hides.
overlay
overlay: (bindings: { [string]: string }?) -> ()
Binds single keys for the next key press only, over every layer, e.g. { ["1"] = "hint-1" }; any other key drops them and does what it always does. Nil drops them now.
resolve
resolve: (keys: string) -> (string?, boolean)
What keys runs in the current mode: the command, or nil and whether
more keys could still finish a sequence.
describe
describe: (keys: string) -> { { layer: string, command: string, plugin: string } }
What keys runs in the current mode and buffer and what that hides: the binding in each layer they’re bound in, most specific first, each followed by those it hides in its own layer, with the plugin that bound it. The first runs.
Mode
get
get: () -> string
set
set: (name: string) -> ()
Switches mode, emitting “mode.changed” if it changed. A mode exists once keys are bound in it or it has a fallback, a parent, counts or a cursor shape; switching to one that doesn’t is an error listing those that do.
set_cursor
set_cursor: (mode: string, shape: "block" | "bar" | "underline") -> ()
Sets how the cursor looks in mode; modes without a shape get a block.
cursor_of
cursor_of: (mode: string?) -> "block" | "bar" | "underline"
The cursor shape of mode, or of the current mode. A block or underline sits on a character, the last of a selection going forward; a bar sits between characters.
OptionValue
OptionValue = boolean | number | string
Options
define
define: (spec: { name: string, doc: string?, default: OptionValue, choices: { OptionValue }?, needs: string? }) -> ()
Defines an option. With choices, it takes only those values (the default among them), and :set completes them. With needs, a capability like “proc”, only code that has it, or you yourself (:set, your config), may set it: for an option whose value is run, like a command line. A plugin can’t define an option another plugin defined.
get
get: (name: string) -> OptionValue?
The option’s value for the acting client: its own, if it has one, else everyone’s.
set
set: (name: string, value: OptionValue?, opts: { client: boolean? }?) -> ()
Sets an option for every client; fails on an unknown name, the wrong type or a value that isn’t one of its choices. With client, sets a value of the acting client’s own instead, like a window’s font size, which nil takes away again; setting it for every client takes away each client’s own.
list
list: () -> { OptionInfo }
Every option, sorted by name.
OptionInfo
name
name: string
doc
doc: string
value
value: OptionValue
See OptionValue.
default
default: OptionValue
See OptionValue.
choices
choices: { OptionValue }
The values it can take; empty when any value of its type will do.
owner
owner: string
The plugin that defined it.
set_by
set_by: string?
The plugin that last set it (your config is a plugin too), if anything has.
source
source: string?
Where it was defined, e.g. “core/edit.luau:12”, and the file and line when that file is on disk.
path
path: string?
line
line: number?
HandlerInfo
An event handler, as greed.handlers() lists it.
event
event: string
owner
owner: string
The plugin that added it.
source
source: string?
path
path: string?
line
line: number?
Keys
Recording what’s typed and feeding keys back, for macros and repeating changes. Recordings have names (macros use the default, “”), so several can run at once.
record
record: (name: string?, opts: { fed: boolean? }?) -> ()
Starts keeping every key typed in the recording name, until stop; with fed, keys feed presses too.
stop
stop: (name: string?) -> { string }?
Stops the recording name and returns the keys typed, e.g. { "i", "x", "esc" }, or nil if it wasn’t recording.
recording
recording: (name: string?) -> boolean
feed
feed: (keys: string) -> ()
Presses the keys of a space-separated sequence as if they were
typed. Only recordings started with fed keep them. What they run
can do only what this plugin may (unless it has “commands”), and they
don’t answer a command waiting for you to press a key. A command
that works long enough to give the editor a turn finishes before
the next key; one waiting on a timer or a job doesn’t hold them up.
HttpRequest
A request for greed.http. method defaults to POST with a body and GET
without; timeout is in milliseconds, for the whole request, and
head_timeout for the status and headers alone, which limits a stream’s
wait without limiting its body. With save,
request writes a successful (2xx) response’s body to that file as it
arrives, creating its folders, and returns an empty body; the file appears
only once it’s whole. Other responses come back as usual and nothing is
written. Saving needs “fs.write”.
url
url: string
method
method: string?
headers
headers: { [string]: string }?
body
body: string?
timeout
timeout: number?
head_timeout
head_timeout: number?
save
save: string?
HttpResponse
A whole response. Header names are lowercase.
status
status: number
headers
headers: { [string]: string }
body
body: string
HttpStream
A response whose body arrives in pieces. read waits for the next piece
and returns it, nil at the end, or nil and why it failed; given
timeout milliseconds, it gives up after them with nil and “timed out”,
and the stream stays open for the next read. close stops reading, and
a read waiting in another task returns nil.
status
status: number
headers
headers: { [string]: string }
read
read: (self: HttpStream, timeout: number?) -> (string?, string?)
close
close: (self: HttpStream) -> ()
Http
Requests over the network, each on a thread of its own so the editor never waits. Both wait like greed.sleep, so they work in commands and event handlers. A plugin needs the “net” capability, or “net:HOST” for one host.
request
request: (request: HttpRequest) -> (HttpResponse?, string?)
Sends a request and returns the whole response, or nil and why.
stream
stream: (request: HttpRequest) -> (HttpStream?, string?)
Sends a request and returns once the status and headers are in; read the body as it arrives, e.g. tokens from a model.
Secrets
Secrets like API keys, kept out of config and plugin source: from the environment (GREED_SECRET_NAME, or the usual variable, e.g. ANTHROPIC_API_KEY), the system keyring, or Greed’s own secrets file. Both wait like greed.sleep. A plugin needs “secrets:NAME” for each secret it reads, or “secrets” for all.
get
get: (name: string) -> (string?, string?)
The secret name, or nil if it isn’t set anywhere; then also why when the system keyring couldn’t be reached (e.g. secret-tool isn’t installed), since it may be kept there.
set
set: (name: string, value: string) -> (string?, string?)
Keeps value as the secret name: in the keyring if it can be reached, otherwise in Greed’s secrets file. Returns where it went (with why not the keyring, when it couldn’t be reached), or nil and why not.
variable
variable: (name: string) -> string
The environment variable that sets the secret name, to tell someone: the usual one, like ANTHROPIC_API_KEY, or GREED_SECRET_NAME. Reads nothing, so it needs no capability.
RunOptions
How greed.process.run runs a program: stdin is its input, cwd its folder; in env, false leaves a variable out of what it inherits. With timeout (milliseconds) it’s killed if it runs longer; with group, it gets a process group of its own, which that reaches too. on_start(child) gets it as it starts, to stop it from elsewhere.
RunOptions = { stdin: string?, cwd: string?, env: { [string]: string | false }?, timeout: number?, group: boolean?, on_start: ((child: Child) -> ())? }
Ran
How a program greed.process.run ran went: its exit code, or the signal that ended it, what it printed, and whether its timeout ended it.
Ran = { code: number?, signal: string?, stdout: string, stderr: string, timed_out: boolean }
Process
Running other programs.
run
run: (command: { string }, opts: RunOptions?) -> (Ran?, string?)
Runs command (the program, then its arguments) to its end as opts say and returns how it went; nil and the error if it couldn’t start. Like a spawned program it’s the plugin’s, and goes with it. It waits like greed.sleep, so only in commands, event handlers and greed.spawn.
spawn
spawn: (command: { string }, opts: { cwd: string?, env: { [string]: string | false }?, stderr: ("keep" | "stream")?, group: boolean? }?) -> (Child?, string?)
Starts command to talk to over its input and output, like an agent speaking JSON-RPC, and returns at once; nil and the error if it couldn’t start. It runs until it exits, is killed, or the plugin that started it unloads. In env, false leaves a variable out of what it inherits. With stderr = "stream", what it prints as errors arrives from read too, in the order it comes; by default it’s only kept for child:stderr(). With group, it starts a process group of its own, which kill and signal reach, so the programs it starts end with it.
env
env: (name: string) -> string?
The editor’s own environment variable name, as the programs it starts inherit it, or nil if it isn’t set: env("SHELL").
RpcOptions
How greed.rpc.start talks to a program. framing is how its messages are told apart: “headers” (Content-Length, as language servers and debug adapters write them; the default) or “lines” (one a line, as agents over ACP). on_request(method, params) answers its requests, returning the result or nil and an error; on_notify(method, params) hears its notifications; each runs in a coroutine of its own, so it may wait. on_exit(stderr) is called once it exits, with the last lines of its error output.
RpcOptions = { cwd: string?, env: { [string]: string | false }?, framing: ("headers" | "lines")?, on_request: ((method: string, params: any) -> (any, string?))?, on_notify: ((method: string, params: any) -> ())?, on_exit: ((stderr: string) -> ())? }
RpcConnection
A JSON-RPC connection to a program, from greed.rpc.start.
request
request: (self: RpcConnection, method: string, params: any) -> (any, string?)
Sends a request and waits for its result, or nil and the error. Waits like greed.sleep, so only in commands, event handlers and greed.spawn.
notify
notify: (self: RpcConnection, method: string, params: any) -> boolean
Sends a notification; false if it couldn’t go.
alive
alive: (self: RpcConnection) -> boolean
Whether the program is still running.
stderr
stderr: (self: RpcConnection) -> string
The last lines of its error output.
close
close: (self: RpcConnection) -> ()
Ends the connection; the program’s input closes and it’s killed if it doesn’t exit soon after.
Rpc
JSON-RPC 2.0 with a program, on the transport language servers use.
start
start: (command: { string }, opts: RpcOptions?) -> (RpcConnection?, string?)
Starts command and talks JSON-RPC with it; nil and the error if it couldn’t start. Needs “proc”. The connection is the plugin’s, and goes with it.
Child
A program started with greed.process.spawn.
pid
pid: number
write
write: (self: Child, text: string) -> boolean
Sends text to its input; false once that’s closed.
read
read: (self: Child) -> (string?, ("stdout" | "stderr")?)
Waits for the next piece of what it prints, and returns it with the output it came from, “stdout” or “stderr” (only with stderr = "stream"); nil once it exited and everything was read. Only in commands, event handlers and greed.spawn.
close
close: (self: Child) -> ()
Closes its input, which tells most programs to finish.
kill
kill: (self: Child) -> ()
Ends it (and with group, its process group) with KILL.
signal
signal: (self: Child, name: string) -> boolean
Sends it a signal by name, like “INT”, “TERM”, “HUP” or “QUIT”; with group, to its process group, even after it exited, as a shell signals a job. Returns whether it went.
wait
wait: (self: Child) -> (number?, string?)
Waits for it to exit and returns its exit code, or nil and the name of the signal that ended it, like “INT”.
stderr
stderr: (self: Child) -> string
The end of what it printed as errors so far.
TerminalRow
A line of a terminal: its text, and the parts with a style of their own
(byte offsets, 0-based, to exclusive), styled with inline names like
“=fg:red bold”.
text
text: string
spans
spans: { { from: number, to: number, style: string } }
images
images: { { from: number, id: number, col: number, row: number, cols: number, rows: number } }
Images on the row, as runs of cells from byte from: from the image’s
cell (col, row) on, of an image cols by rows cells. id is a
greed.image id, for a mark’s image.
links
links: { TerminalLink }
Links the program printed (OSC 8), as byte ranges and where they go.
wrapped
wrapped: boolean
Whether the line carries on on the next row: the program printed past the last column and the terminal wrapped it.
TerminalModes
The modes a terminal’s program set, from terminal:modes().
alternate
alternate: boolean
A full screen program, like an editor or a pager, is showing.
canonical
canonical: boolean
Input goes to the program a line at a time; off in raw mode, which editors and prompts set.
echo
echo: boolean
Typed text is echoed; off while a program reads a password.
mouse
mouse: boolean
The program asked for mouse events.
app_cursor
app_cursor: boolean
Arrow keys are sent in application mode.
bracketed_paste
bracketed_paste: boolean
Pastes are marked as pastes.
TerminalLink
TerminalLink = { from: number, to: number, uri: string }
TerminalScreen
What a terminal shows.
rows
rows: { TerminalRow }
cursor
cursor: { row: number, col: number }?
The cursor’s row (0-based) and byte offset in it, unless the program hid it.
alternate
alternate: boolean
Whether a full screen program, like an editor or a pager, is showing.
Terminal
A program running in a terminal. Two handles to the same terminal are
equal (==).
id
id: (self: Terminal) -> number
Its id, even after it was closed.
valid
valid: (self: Terminal) -> boolean
Whether it is still open. Other methods fail once it was closed.
screen
screen: (self: Terminal) -> TerminalScreen
scrollback
scrollback: (self: Terminal, from: number?) -> { first: number, rows: { TerminalRow } }
The lines that scrolled off the top, from line from (counting from
the terminal’s first line) on, or from the oldest one kept. first is
the number of the first line returned.
marks
marks: (self: Terminal, from: number?) -> { TerminalMark }
The places the shell marked (OSC 133) on line from (counting as
scrollback does) and after, oldest first: where a prompt starts,
where the typed command starts, where its output starts, and where it
was done, with its exit code if the shell said. col is a byte in the
line’s text.
marks_made
marks_made: (self: Terminal) -> number
How many marks the shell has made so far, to tell when there are new ones without asking for them all.
cwd
cwd: (self: Terminal) -> string?
The folder the shell last said it’s in (OSC 7), or the one it started in.
write
write: (self: Terminal, text: string) -> ()
Sends text to the program as if typed. This and the other methods that send input need “proc”: the plugin that started the terminal has it through the handle it got; others with one from an event need their own.
key
key: (self: Terminal, name: string) -> ()
Sends a key, e.g. “ctrl-c” or “up”, as a terminal encodes it.
paste
paste: (self: Terminal, text: string) -> ()
Sends pasted text, marked as a paste if the program asked for that.
resize
resize: (self: Terminal, rows: number, cols: number) -> ()
Changes its size, kept to between 1 by 1 and 1024 rows by 2048 columns.
wants_mouse
wants_mouse: (self: Terminal) -> boolean
Whether the program asked for mouse events, as editors and htop do.
modes
modes: (self: Terminal) -> TerminalModes
The modes the program set: the alternate screen, line input and echo (from the terminal’s settings), mouse, application cursor keys and bracketed paste.
mouse
mouse: (self: Terminal, kind: string, col: number, row: number, which: string?, mods: { ctrl: boolean?, alt: boolean?, shift: boolean? }?) -> boolean
Sends a mouse event at the program’s screen cell (col, row),
0-based, if it asked for that kind: kind as in a MouseEvent, with
a button or a scroll direction. Returns whether it was sent.
title
title: (self: Terminal) -> string?
What the program called its window, if it did.
notices
notices: (self: Terminal) -> { { title: string?, body: string } }
The notifications the program sent since this was last asked, oldest first (the latest 16): OSC 9;BODY or OSC 777;notify;TITLE;BODY, as many programs and shells send them.
progress
progress: (self: Terminal) -> { state: "going" | "error" | "busy" | "paused", percent: number? }?
How far the program last said it got (ConEmu’s OSC 9;4): “going” with percent 0 to 100, “error”, “busy” (no telling how far) or “paused”; nil when it hasn’t said, or said it’s done.
program
program: (self: Terminal) -> string
The name of the program it started, like “nu” or “cargo”: its file name, or the shell’s for a terminal started without a command.
exit_code
exit_code: (self: Terminal) -> number?
The program’s exit code, once it has ended.
busy
busy: (self: Terminal) -> boolean
Whether a program other than the one it started is in the foreground, like a command its shell runs. False once it has ended.
kill
kill: (self: Terminal) -> ()
Asks the program to end.
interrupt
interrupt: (self: Terminal) -> boolean
Interrupts what runs in the foreground, as ctrl-c does, even in the moment after it starts, before a typed ctrl-c would reach it. Returns whether it went.
close
close: (self: Terminal) -> ()
Ends the program and lets the terminal go; its handle stops working.
Terminals
Programs in terminals. A terminal belongs to the plugin that started it.
spawn
spawn: (spec: { command: { string }?, cwd: string?, env: { [string]: string | false }?, rows: number, cols: number, scrollback: number? }) -> Terminal
Starts command (the program, then its arguments; the user’s shell
without) in a terminal of rows by cols. Its output arrives as
“terminal.output” events and its end as “terminal.exited”.
scrollback lines are kept above the screen (default 10000). The
size is kept to between 1 by 1 and 1024 rows by 2048 columns. In
env, false leaves a variable out of what the program inherits.
TerminalMark
A place a shell marked in a terminal, from terminal:marks().
line
line: number
col
col: number
kind
kind: "prompt" | "command" | "output" | "done"
code
code: number?
The exit code, for “done”, if the shell said.
TerminalOutput
A terminal printed something; read it with terminal:screen().
terminal
terminal: Terminal
See Terminal.
TerminalExited
The program in a terminal ended.
terminal
terminal: Terminal
See Terminal.
code
code: number
signaled
signaled: boolean
Whether a signal ended the program, rather than its own exit.
UndoNode
A state of a buffer’s text in its undo tree, from buffer:undo_tree().
id
id: number
0 is the text as loaded; later states have higher ids.
parent
parent: number?
children
children: { number }
Oldest first; redo follows the last.
time
time: number?
When the step was last added to, in seconds like os.time(); nil for node 0.
HistoryEntry
A transaction applied to a buffer, from buffer:history().
id
id: number
author
author: "user" | "plugin" | "agent" | "external"
plugin
plugin: string?
The plugin, for edits a plugin made.
cause
cause: string?
Why: the command it was made for, “undo”, “redo”, …
group
group: number?
The undo group it was made in.
time
time: number
When, in seconds since 1970.
changes
changes: { { from: number, to: number, text: string } }
What it replaced, in the text before it, in order.
HistoryFilter
author
author: string?
plugin
plugin: string?
cause
cause: string?
group
group: number?
since
since: number?
limit
limit: number?
History
start_group
start_group: () -> ()
Edits until end_group become one undo step.
end_group
end_group: () -> ()
new_group
new_group: () -> number
A group id nothing has used yet, for set_group.
group
group: () -> number?
The group edits go into now, if any.
set_group
set_group: (group: number?) -> ()
Puts the edits that follow, in every buffer, into group (one used before
carries on), or with nil into none. Edits in a group undo as one step.
cause
cause: () -> string?
Why edits are being made: by default the command running.
set_cause
set_cause: (cause: string?) -> ()
Sets why the edits that follow are made, for the rest of this command.
undo_group
undo_group: (group: number) -> (number?, string?)
Undoes group in every buffer it changed, as one step. Returns how many
buffers changed (0 if it was undone already), or nil and why not, when
something was done on top of it since.
FloatSpec
How a floating view looks. Sizes are cells, or a share of the screen as a string like “60%” or “37.5%”, which keeps the float in proportion on clients with screens of other sizes; both default to “60%”.
title
title: string?
width
width: (number | string)?
height
height: (number | string)?
anchor
anchor: ("center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "cursor" | "above-cursor")?
Where it goes when x or y is left out: in the middle, at an edge
or in a corner. “cursor” opens it just below the cursor (or above,
near the bottom), like a completion menu; “above-cursor” prefers
above, like signature help.
focus
focus: boolean?
Whether the view takes focus. Defaults to true.
x
x: (number | string)?
Where the outside of the border goes, from the screen’s left and top
edges, in cells or like “37.5%”. Left out, the float goes where
anchor says on that axis. It’s always kept on screen.
y
y: (number | string)?
tab
tab: boolean?
Whether it belongs to the tab it opens in: shown only with that tab, and closed with it, like a floating terminal. Otherwise it floats over every tab, like a picker. Defaults to false.
shared
shared: boolean?
Whether every client is shown it, like a review meant for everyone. Otherwise only the client it opened for is (the one acting then), as with a picker or a prompt, unless it belongs to a tab, which every client showing the tab sees. Defaults to false.
label
label: MarkLine?
Text at the right end of the top border, e.g. “‹ 2/5 ›”, or pieces with styles of their own. “” takes it off.
See MarkLine.
footer
footer: MarkLine?
Text in the middle of the bottom border, as label takes it.
See MarkLine.
border
border: boolean?
Whether it has a border; defaults to true. Without one its text fills its whole box, like a one-line strip.
hidden
hidden: boolean?
Hides it: its view and buffer stay (a terminal keeps running), but
it isn’t drawn, greed.floats() leaves it out and focus moves on.
Focusing it shows it again.
CommandInfo
name
name: string
doc
doc: string
args
args: { ArgSpec }
usage
usage: string
How it’s typed, e.g. “kube-namespace [NAME]”.
owner
owner: string
The plugin that defined it.
source
source: string?
Where it was defined, e.g. “core/motions.luau:120”.
path
path: string?
The file and line it was defined on, when that file is on disk.
line
line: number?
BufferClosed
A buffer was closed. Only its id is left.
id
id: number
BufferChanged
buffer
buffer: Buffer
See Buffer.
from_line
from_line: number?
On “buffer.changed”: the first and last line (0-based, as the text is now) of what changed since the last “buffer.changed” for the buffer.
to_line
to_line: number?
ControlRequest
A request from the session socket, e.g. from greed ctl or an agent.
Answer it with greed.control.reply.
id
id: number
client
client: string
“socket” for the session socket (greed ctl, greed mcp), “ide” for Claude Code’s IDE connection.
connection
connection: number?
The session socket connection it came on, for greed.control.send;
nil for Claude Code’s IDE connection.
rpc_id
rpc_id: any
The JSON-RPC id as the client sent it, the one a later
notifications/cancelled names; nil for a notification.
method
method: string
params
params: any
ControlClosed
A session socket connection closed, after its last request came.
connection
connection: number
The connection, as ControlRequest.connection gave it.
Signal
wait
wait: (self: Signal) -> any
Waits until a value is sent, and returns it.
send
send: (self: Signal, value: any) -> ()
Sends value to whoever waits. Only the first send counts.
ProjectInfo
A project: a folder with its own main view and panels.
id
id: number
root
root: string
current
current: boolean
Whether it’s the one shown.
Projects
list
list: () -> { ProjectInfo }
Every open project, in the order they were opened.
current
current: () -> ProjectInfo
open
open: (root: string) -> number
Opens a project rooted at root, with an empty main view, and shows
it. Returns its id.
switch
switch: (id: number) -> boolean
Shows project id. False if there is none.
close
close: (id: number) -> boolean
Closes project id with its views and the buffers opened in it. The
last project can’t be closed; false then.
Images
Images for marks to show. Each is kept until forgotten.
load
load: (path: string) -> (number?, string?)
Reads a PNG, JPEG or GIF file. Returns the image’s id, or nil and why not.
decode
decode: (bytes: string) -> (number?, string?)
The same, from the file’s bytes.
size
size: (id: number) -> (number?, number?)
Its width and height in pixels.
cells
cells: (id: number) -> (number?, number?)
How many cells it covers at its own size on the attached screen.
cell_size
cell_size: () -> (number, number)
A cell’s width and height in pixels on the attached screen.
forget
forget: (id: number) -> ()
Scenes
Small vector drawings, as charts are, for a mark’s scene: each client draws one as well as it can (an image in a terminal with kitty graphics), and the text under it is what the others show. A spec is { alt, items }: alt says what it shows, and items are line (points, style, weight), area (points, base, fill, opacity), rect (at, size, fill, style, opacity), dots (points, style, weight), text (at, text, style, align) and group (items, clip), in cells from the top left. require("@scene") draws a spec in characters.
new
new: (spec: { alt: string, items: { any } }) -> number
Keeps a scene and returns its id.
set
set: (id: number, spec: { alt: string, items: { any } }) -> boolean
Makes spec what scene id shows, at its next version; false when there’s no such scene.
forget
forget: (id: number) -> ()
Pdfs
PDF documents.
open
open: (path: string) -> (PdfDocument?, string?)
Reads the PDF at path. Returns the document, or nil and why not. It waits like greed.sleep, so only in commands, event handlers and greed.spawn.
PdfDocument
A PDF read with greed.pdf.open. Pages count from 1.
pages
pages: number
size
size: (self: PdfDocument, page: number) -> (number?, number?)
A page’s width and height in points (1/72 inch).
render
render: (self: PdfDocument, page: number, scale: number?) -> (number?, string?)
Draws a page at scale pixels per point (1 if not given) and returns it as a greed.image id, or nil and why not. Forget the image when done with it. Waits like greed.sleep.
text
text: (self: PdfDocument, page: number) -> (string?, string?)
The text on a page, line by line from the top, or nil and why not. Waits like greed.sleep.
Htmls
Web pages as text to read.
read
read: (html: string, url: string?) -> HtmlPage
What the page html reads as: its main content as Markdown, without menus, footers and banners, as a browser’s reader view shows it; a page with no article in it, like a list of links, as all its text. url is where it came from, for its links. Waits like greed.sleep.
HtmlPage
A page read with greed.html.read.
title
title: string?
byline
byline: string?
excerpt
excerpt: string?
The page’s own summary of itself, when it has one.
text
text: string
The text, as Markdown: links, lists, tables and code kept.
article
article: boolean
Whether text is an article found in the page, rather than all of the page’s text.
TabInfo
A tab of the shown project: panes laid out side by side and one above another.
id
id: number
name
name: string?
The name it was given, if any.
current
current: boolean
Whether it’s the one shown.
zoomed
zoomed: boolean
Whether only its active pane is shown.
panes
panes: { View }
Its panes, left to right and top to bottom.
active
active: View
The pane keys go to while it’s shown.
See View.
Tabs
list
list: () -> { TabInfo }
The shown project’s tabs, in order.
current
current: () -> TabInfo
new
new: (buffer: Buffer?) -> number
Opens a tab after the shown one, with a pane showing buffer (or an
empty buffer), and shows it. Returns its id.
switch
switch: (id: number) -> boolean
Shows tab id, of whichever project, and its project. False if there’s no such tab.
close
close: (id: number) -> boolean
Closes tab id and its panes. The last tab can’t be closed; false
then.
rename
rename: (id: number, name: string?) -> boolean
Names tab id; nil or “” names it after what it shows again.
set_zoomed
set_zoomed: (zoomed: boolean) -> ()
Shows only the active pane of the shown tab, or all of them again.
layout
layout: (id: number?) -> any
How tab id (the shown one by default) lays out its panes, as a
PaneLayout, with sizes adding up to 1 in each split.
set_layout
set_layout: (layout: any, id: number?) -> ()
Lays tab id’s panes out as layout (a PaneLayout) instead. It
arranges the panes the tab has, so it has to hold each of them once;
opening and closing panes is view:split and view:close. A split
of one pane is that pane; splits nest at most 64 deep.
PaneLayout
A tab’s panes: a pane is its view, a split lays out its children side by
side (“row”) or one above another (“column”), sharing the room by
sizes, which are relative to each other (equal when left out).
PaneLayout = View | { split: "row" | "column", children: { PaneLayout }, sizes: { number }? }
PaneOpened
A pane was opened, beside from.
view
view: View
See View.
from
from: View
See View.
SessionInfo
A session running on this machine: an editor process of its own.
name
name: string
root
root: string?
The project it was started for.
build
build: string?
The build of greed it runs, as greed --version says it, if it said.
current
current: boolean
Whether it’s this session.
service
service: string?
The service whose owner it runs (its name is the service’s with .service after it), if it’s one.
Sessions
list
list: () -> { SessionInfo }
The sessions running on this machine, by name.
current
current: () -> string?
This session’s name, when the editor runs as one.
build
build: () -> string
Which build of greed this is, as greed --version says it.
fresh
fresh: () -> boolean
Whether the session was started with greed --fresh, to begin without what it had open before.
restoring
restoring: () -> boolean
Whether the session was started with greed --restore, or for an upgrade, to open what it had open before even after it was quit.
remote
remote: () -> boolean
Whether the attached client (or the last one) came over greed ssh; before any attached, whether greed ssh started the session.
attached
attached: () -> boolean
Whether a terminal or window is attached to the session.
program
program: () -> string?
Where the greed program running this editor is, to start greed mcp or greed ctl for this session.
status
status: (name: string) -> ({ [string]: any }?, string?)
What the session name on this machine says of itself, as its status tool gives it (schema, session, attention, agents), asked as an ordinary client, so asking can’t do anything there; or nil and why: it’s gone, its greed has no status, or it didn’t answer in time. It waits, so it works in a command, an event handler or greed.spawn.
start
start: (name: string) -> (boolean?, string?)
Starts the session name on this machine in the background, unless it’s running, and waits until it listens; true, or nil and why it didn’t start. The client stays where it is. A service’s session (NAME.service) works from a folder of its own. It waits, so it works in a command, an event handler or greed.spawn.
switch
switch: (to: { name: string?, path: string?, new: boolean?, host: string?, window: boolean?, back: boolean?, home: boolean? }) -> ()
Sends the attached client to the session name, or to the session for
the project path is in (opening it there), starting it if it isn’t
running. This session goes on without the client. With new, a new
session for path’s project, even when one is running for it. With
host, the session is on that machine, reached as greed ssh does.
With window, a window client opens it in another window and stays
on this session; a terminal goes to it as without. back goes to where
the client was before, on whichever machine, and home to the session
on the client’s own machine it was on last, or the one name names
there; back goes on its own, and home with a name at most.
Json
JSON. Tables with keys 1..n become arrays, other tables objects; an
empty table is an object unless it came from array.
encode
encode: (value: any) -> string
value as JSON. Text that isn’t UTF-8, like a program’s binary
output, has its broken bytes written as U+FFFD.
decode
decode: (text: string) -> (any, string?)
The value, or nil and why the text isn’t JSON. null becomes nil.
array
array: <T>(items: { T }?) -> { T }
Marks items (or a new table) to encode as an array even when empty.
is_array
is_array: (value: any) -> boolean
Whether value is marked to encode as an array, by array or by
decode, so a copy of it can be marked too.
SiktProblem
A mistake or a warning in a sikt program: its words, where it is in the program’s text (from its first byte to just after its last), what might help, and whether it’s only a warning.
SiktProblem = { message: string, at: { from: number, to: number }, help: string?, warning: boolean }
SiktPlace
Where a sikt match is in its text: from its first byte to just after its last, on line (from 1) where it starts.
SiktPlace = { from: number, to: number, line: number }
SiktRow
A match of a sikt program: its captures by name. integer, number, size (bytes), percent and duration (seconds) captures are numbers, the rest text; a capture that didn’t take part is missing.
SiktRow = { [string]: string | number }
SiktProgram
A compiled sikt program, to run as often as needed.
warnings
warnings: { SiktProblem }
What the program probably doesn’t mean, like a part that can never match.
captures
captures: { { name: string, type: string? } }
Its captures, each with its type (“text”, “integer”, “number”, “size”, “percent”, “duration”).
rows
rows: (self: SiktProgram, text: string, opts: { at: boolean?, text: boolean? }?) -> ({ SiktRow }, { SiktPlace }?)
The matches in text, each a row of its captures; with at, also where each is; with text, every capture as the text it matched (“1.5G” rather than its bytes). It runs on the editor’s thread, so for a lot of text use rows_many. An error when matching gives up, on a pattern that takes too many steps.
rows_many
rows_many: (self: SiktProgram, texts: { string }, opts: { at: boolean?, text: boolean? }?) -> ({ { SiktRow } }, { { SiktPlace } }?)
rows for each of texts, run on other threads and waited for like greed.sleep (commands, handlers, greed.spawn). The rows become Luau tables all at once when it’s done, so give it a few hundred texts at a time.
replace
replace: (self: SiktProgram, text: string) -> string
text with each match replaced as the program’s replace says; unchanged without one.
Sikt
sikt: patterns that read like sentences (year: 4 digit "-" month: 2 digit), for reading structure out of text. The language: https://github.com/johnae/sikt/blob/main/docs/language.md
compile
compile: (source: string, opts: { lines: boolean?, nocase: boolean?, modules: { [string]: string }? }?) -> (SiktProgram?, string?)
Compiles source, a sikt program, or gives nil and what’s wrong. It matches each line on its own unless lines is false; nocase ignores case; modules holds rule files by name for use "name".
check
check: (source: string, opts: { lines: boolean?, nocase: boolean?, modules: { [string]: string }? }?) -> { SiktProblem }
What’s wrong with source (compiled as compile would) and what it probably doesn’t mean, each with where it is: to mark them in a program as it’s written.
Control
Needs the “control” capability (and serve_ide “net” too).
reply
reply: (id: number, result: any, message: string?) -> ()
Answers request id with result, or with an error message. Every
request needs exactly one answer.
send
send: (connection: number?, method: string, params: any) -> boolean
Sends a notification of method with params to the session socket
connection a request came on (its connection), e.g. MCP’s
“notifications/tools/list_changed”. False if that connection has closed.
serve_ide
serve_ide: (folders: { string }, lock_dir: string?) -> number
Lets Claude Code find this editor with /ide: listens on a localhost
WebSocket and writes a lock file naming folders as open, in lock_dir
(default ~/.claude/ide). Its requests come with client “ide”. Returns
the port; calling it again replaces the connection.
ide_folders
ide_folders: (folders: { string }) -> ()
Names folders as open in the lock file serve_ide wrote, as when an agent’s workspace is added; Claude Code started from now on sees them, and those connected stay connected.
notify
notify: (method: string, params: any) -> ()
Sends a notification, e.g. “selection_changed”, to Claude Code.
SshAgentUse
A program in a session greed ssh started asks to sign with one of your ssh keys, through the client relaying your agent. Answer with greed.ssh_agent.answer; with no answer, or no handler, it may not.
id
id: number
The request, for greed.ssh_agent.answer.
client
client: number
The client relaying your agent, which handlers run as.
host
host: string?
The machine that client is on, if known.
SshAgent
Needs the “ssh-agent” capability.
answer
answer: (id: number, allowed: boolean) -> boolean
Answers “ssh_agent.use” request id: whether the program may sign with your key. False if it no longer waits (answered already, or it gave up).
ProfileRow
One row of greed.profile.stop(): what a plugin (nil for the editor itself) spent doing one thing, in all and at most once, in milliseconds.
ProfileRow = { plugin: string?, what: string, ms: number, longest: number, runs: number }
DebugLine
One line greed.debug.lines() returns: id counts up, at is milliseconds since the editor started, plugin is set for a plugin’s own lines.
DebugLine = { id: number, at: number, topic: string, plugin: string?, text: string }
Debug
Debug lines: what the editor, its clients and plugins say they’re doing, kept while their topic is on. Topics: keys, runs, frames, rpc, jobs, client, plugins (or plugin:NAME for one). Off, a topic costs next to nothing.
log
log: (...any) -> ()
Keeps a line from this plugin, its parts joined by spaces, when plugins or plugin:NAME is on; otherwise does nothing. Check on() first when making the parts costs something.
on
on: (name: string?) -> boolean
Whether this plugin’s lines are kept, or with name, whether that topic (or plugin:NAME) is on.
set
set: (name: string, on: boolean) -> ()
Turns a topic, plugin:NAME, or all on or off.
switch
switch: (words: string) -> ()
Switches topics as words say, with spaces between: a name turns it on, -name off, off everything, as :debug takes them.
off
off: () -> ()
Turns every topic off.
enabled
enabled: () -> { string }
What’s on.
topics
topics: () -> { string }
Every topic’s name.
lines
lines: (opts: { after: number?, limit: number?, topic: string?, plugin: string? }?) -> { DebugLine }
The lines kept, oldest first: those after the id after, of one topic or plugin, at most the last limit (1000).
clear
clear: () -> ()
Forgets the lines kept so far.
ClientAttached
A client attached, e.g. greed FILE in a session that was running. Handlers run as that client.
client
client: number
The client’s id.
path
path: string?
The file or folder it asked to open, if any.
terminal
terminal: boolean
Whether it asked for a terminal, e.g. greed ssh HOST --terminal.
shell
shell: boolean
Whether it asked for the project’s greed shell, e.g. greed --shell.
remote
remote: boolean
Whether it came over greed ssh.
ClientDetached
A client went; the session goes on. Handlers run as that client, just before it’s gone.
client
client: number
ClientPaste
Text pasted into the client from the system clipboard: a terminal’s paste, or a window’s paste keys (ctrl-shift-v, shift-insert, cmd-v). The core plugin puts it at the cursors.
client
client: number
The client it was pasted into, which handlers run as.
text
text: string
ViewClosed
A view was closed. Its handle no longer works, but its id can be
compared with view:id().
view
view: number
MouseEvent
What the mouse did, and what was under it.
client
client: number
The client whose mouse it was, which handlers run as.
kind
kind: "press" | "release" | "drag" | "move" | "scroll"
button
button: ("left" | "middle" | "right")?
For a press, release or drag.
dir
dir: ("up" | "down" | "left" | "right")?
For a scroll.
col
col: number
The screen cell, from the top left.
row
row: number
ctrl
ctrl: boolean
alt
alt: boolean
shift
shift: boolean
view
view: View?
The view under it, if any.
See View.
pos
pos: number?
The place in the view’s buffer under it: the character there, or the end of the line past it. Over a mark’s text, where the mark starts.
action
action: string?
The action of the mark whose text it’s over, or of the status line segment (with no view), if that has one.
x
x: number?
The cell in the view’s text, from its top left, right of the gutter.
y
y: number?
tab
tab: number?
The tab whose name it’s over, in the tab line.
border
border: ("top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right")?
On a floating view’s border (with view set), which part: “top” (the title’s), “bottom”, “left”, “right”, or a corner like “bottom-right”.
edge
edge: ("left" | "right" | "down")?
On the line between a pane or panel (view) and its neighbor, the side of view it’s on: “right” or “down” for panes, the side by the main view for panels. Dragging it resizes view with resize.
ViewResized
A view was drawn for a client with room for a different number of rows or columns of text than before. Handlers run as that client.
client
client: number
view
view: View
See View.
rows
rows: number
cols
cols: number
ViewScrolled
A view was drawn for a client starting at a different line than before. What a handler changes shows in the same frame, so a view can scroll another along with it. Handlers run as that client.
client
client: number
view
view: View
See View.
line
line: number
The 0-based line now at the top.
SelectionChanged
A view’s selection changed for a client, or it shows another buffer, since the last frame: told once a frame however many changes there were, whatever made them (keys, the mouse, undo, a plugin or an agent). Handlers run as that client.
client
client: number
view
view: View
See View.
ViewFocused
Another view has a client’s focus. from had it before; nil when it was
closed. Handlers run as that client.
client
client: number
view
view: View
See View.
from
from: View?
See View.
moved
moved: boolean
The focus was moved under the client rather than by it: what it had focused went out of sight by another client’s doing (another tab or project shown, a pane closed), or it followed the others again. Its half-typed keys were dropped.
OptionChanged
An option was set, with greed.option.set or :set.
name
name: string
value
value: OptionValue
Its value now, as the client it was set for has it.
See OptionValue.
client
client: number?
The client it was set for, when one got a value of its own.
FileChanged
A file watched with greed.fs.watch was written, created or removed.
path
path: string
PluginLoaded
A plugin was loaded (or reloaded) and its entry file ran.
name
name: string
dir
dir: string?
Its folder, for plugins loaded from one.
PluginUnloaded
A plugin was unloaded, and everything it registered removed.
name
name: string
CommandRun
client
client: number
The client it runs for, which handlers run as.
name
name: string
The command about to run.
keys
keys: string?
The keys that ran it, when keys did, e.g. “g g”.
count
count: number?
The number typed before the keys.
KeysPending
client
client: number
The client typing them, which handlers run as.
keys
keys: string
The unfinished key sequence, e.g. “space”; “” once it’s finished.
StatusSegment
A piece of the status line: plain text, or text with a style.
text
text: string
style
style: string?
A style name, e.g. “ui.statusline.mode”, drawn over “ui.statusline”.
action
action: string?
A command a click on it runs.
StatusContext
What a status line function gets, for the main view.
view
view: View
See View.
buffer
buffer: Buffer
See Buffer.
mode
mode: string
message
message: string?
The latest message or error, if there is one to show.
width
width: number
The width of the screen in cells.
StatusParts
Segments for each side. The space between is padded; if the line is too long, the last segment on the left keeps only its end.
left
left: { StatusSegment }?
right
right: { StatusSegment }?
Clipboard
Copied text. Each copy holds one piece per selection it came from, so pasting into the same number of selections puts each piece back.
set
set: (pieces: string | { string }) -> ()
get
get: () -> { string }?
The latest copy.
history
history: () -> { { string } }
Recent copies, newest first.
image
image: () -> string?
The image on the system clipboard of the client acting now, as PNG bytes, read on that client’s own machine (so with greed ssh, your laptop’s); nil when there’s none or the client can’t read it. Waits like greed.sleep.
ClientInfo
A client attached to the editor: a terminal or window, on this machine or over greed ssh.
id
id: number
name
name: string
Its kind and machine, like “tui@laptop”; a client coming back with the same name gets its cursors, focus and mode back.
kind
kind: string
“tui”, “gui”, “headless” (the editor’s own, with nothing attached) or “test”.
remote
remote: boolean
Whether it came over greed ssh.
size
size: { width: number, height: number }?
Its screen in cells, once it has said.
layout
layout: "follow" | "independent"
“follow”: it shows the project, tab and panes the other followers do, with its own focus and zoom. “independent”: a layout of its own.
status_line
status_line: boolean
Whether it shows the status line (set_status_line).
scaled_text
scaled_text: boolean
Whether it draws scaled text (a mark’s scale) bigger: the window does, and so does a terminal with kitty’s text sizing; others draw it at its usual size, in the room it would take.
color
color: number
Which of the peer colors (1 to 6) its cursors show in for the other clients, as ui.cursor.peer.N.
person
person: string
Who it belongs to: “owner”, the session’s owner, for now.
Client
The clients you see the editor through. Commands, keys and event handlers act for one client at a time: the one that typed, clicked or ran them, or the one an event is about.
current
current: () -> ClientInfo
The client the running code acts for.
id
id: () -> number
The id of the client the running code acts for: current().id, without building the rest. For keeping what each client has open apart, like a picker of its own.
list
list: () -> { ClientInfo }
Every client, in the order they attached.
notify
notify: (title: string, body: string?, client: number?) -> ()
Sends a notification to your desktop through a client: client (an id from list), or the one used last; a terminal shows it with its notification escape (OSC 9, or OSC 777 in foot and urxvt) and a bell, while it isn’t focused. Without a client attached it goes nowhere.
home
home: (client: number) -> ({ [string]: any }?, string?)
What the hub on the machine client (an id from list) runs on says, as its status gives it (with machine and machines), for a session on another machine to show what you have where you are; the client, attached over greed ssh, asks it as an ordinary client, so nothing there can be done through it. Or nil and why: the client has no hub to ask (a client here, an older greed) or didn’t answer in time. It waits, so it works in a command, an event handler or greed.spawn.
open
open: (link: string, client: number?) -> (boolean?, string?)
Opens the web or mail link link on the machine of client (the acting one by default), where you are, with its opener: true, or nil and why, like a client that can’t (only one attached over greed ssh can). It waits, so it works in a command, an event handler or greed.spawn.
set_layout
set_layout: (layout: "follow" | "independent", client: number?) -> boolean
Lays a client (the acting one by default) out on its own, “independent”, starting from a copy of the tabs, panes and panels it had, with views of its own; or has it “follow” the others again, closing those views (their buffers stay). Returns whether it changed.
set_status_line
set_status_line: (shown: boolean, client: number?) -> ()
Shows or hides the status line of a client (the acting one by default), its row going to the text while hidden, as slides do while a talk is shown: only on that client’s screen. Errors without such a client.
Diagnostic
A problem a language server found.
from
from: number
to
to: number
severity
severity: number
1 error, 2 warning, 3 information, 4 hint.
message
message: string
source
source: string?
server
server: number?
The id of the server that reported it.
code
code: any?
What the server knows it by, its code and data, to send back with it when asking it for fixes.
data
data: any?
LspError
The error a language server answered a request with.
code
code: number
message
message: string
data
data: any?
LspPosition
A position as language servers count it.
line
line: number
character
character: number
Lsp
Language servers. A language has a main server and may have others that
run beside it, like eslint beside TypeScript’s; each runs per project
root, started the first time a file that needs it is open, and started
again if it stops. A buffer has every one of its language’s that runs
for it, the main one first: functions taking a buffer use its first
unless given a server’s id (servers_of).
server
server: (spec: { language: string, name: string?, when: { string }?, command: { string }?, commands: { { string } }?, root_markers: { string }?, reads_only: boolean?, settings: { [string]: any }?, folder_setting: string?, init_options: { [string]: any }?, only: { string }?, except: { string }? }) -> ()
Sets a server for a language, e.g.
{ language = "rust", command = { "rust-analyzer" }, root_markers = { "Cargo.toml" } }.
Without name it’s the language’s main server; with one, a server that runs beside it, set and replaced by its name.
With commands, the first one whose program is installed runs, when
a file of the language first opens; with none installed, nothing does.
A server runs in the topmost folder with one of root_markers inside
the file’s project, or the project’s root without one. With when, it runs only for files under a folder that has one of those files, in the nearest such folder.
With reads_only, the server only reads the project’s files, never running its code, so it starts in a project nobody trusted (see trust).
settings are the server’s settings, sent once it’s initialized and what it gets when it asks for a section; init_options goes with initialize. A running server keeps the ones it started with until it’s restarted.
folder_setting names a setting that gets the folder the server runs in, as { uri, name }, for a server that reads it from its settings, as eslint’s does with “workspaceFolder”.
only and except name the features it’s used for, like “hover” or “format”, for plugins that pick one of a buffer’s servers for a feature: only those, when given, and never those in except.
remove
remove: (language: string, name: string?) -> ()
Stops starting the language’s server called name, or all of its servers without one; one running keeps running.
restart
restart: (language: string?) -> number
Stops the servers running for language (every language without one) and starts them again, as after they got stuck. Returns how many were running. Needs “proc”.
trust
trust: (folders: { string }?) -> ()
Lets servers start only in folders and the folders inside them, as a server runs a project’s code (a build script, a config file); nil lets them start anywhere. A server set up with reads_only starts anywhere. One held back starts once its folder is trusted. Needs “proc”.
waits
waits: (buffer: Buffer) -> boolean
Whether the buffer’s server is held back until its folder is trusted (trust): one is set up for its language and installed, runs the project’s code, and may not start where it would run.
servers
servers: () -> { [string]: { { string } } }
The commands set for each language’s main server, by language.
running
running: () -> { LspServer }
The servers running now, by language, name and root.
failures
failures: () -> { LspFailure }
The servers given up on, as they couldn’t start or kept stopping, by language, name and root; not tried again until their language is set up again or :lsp-restart. Not those that aren’t installed.
servers_of
servers_of: (buffer: Buffer) -> { LspBufferServer }
The buffer’s running servers, its language’s main one first and then the others in the order they were set up.
root
root: (buffer: Buffer) -> string?
The folder the buffer’s first server runs in, or would: nil without a file or a server set for its language.
request
request: (buffer: Buffer, method: string, params: any, server: number?) -> (any, LspError?)
Sends a request to server, one of the buffer’s (its first without one), and waits for the answer.
Returns the result, or nil and the error; a server that stops before
answering gives the error “the language server stopped”. Works in
commands and event handlers. “workspace/executeCommand” needs “proc”,
since a server’s commands can do anything.
uri
uri: (buffer: Buffer) -> string
The buffer’s file as a URI, for request parameters.
path
path: (uri: string) -> string?
The file path in a file:// URI.
position
position: (buffer: Buffer, pos: number, server: number?) -> LspPosition
Byte offset pos as server (the buffer’s first without one) counts positions. server may be any running server, like the one that named a place in this file before the file had a server of its own.
offset
offset: (buffer: Buffer, position: LspPosition, server: number?) -> number
The byte offset of a position as server (the buffer’s first without one) counts it; any running server, as for position.
diagnostics
diagnostics: (buffer: Buffer) -> { Diagnostic }
The buffer’s latest diagnostics from all its servers, where they are now: they move with
edits. They are marks in the buffer’s “diagnostics” namespace, with
{ severity, message, source, server } as their data.
problems
problems: () -> { LspProblem }
Every file’s latest problems, including files that aren’t open, with ranges as the server counts positions. Those in open files are where they are now.
capabilities
capabilities: (buffer: Buffer, server: number?) -> any
What server (the buffer’s first without one) said it can do (its ServerCapabilities),
or nil without a running server.
on_request
on_request: (method: string, handler: (params: any, server: number) -> any) -> ()
Answers requests of method from servers, e.g. “workspace/applyEdit”,
with what handler returns, given the asking server’s id. It can wait, e.g. to ask you; the server gets the answer when it returns.
on_notification
on_notification: (method: string, handler: (params: any, language: string, root: string, server: number, name: string) -> ()) -> ()
Hears notifications of method from servers that the editor doesn’t deal with itself, e.g. “$/progress”, with the language, root, id and name of the server that sent it.
LspBufferServer
One of a buffer’s servers (servers_of): its id, its name (its language’s for the main one) and what it can do.
id
id: number
name
name: string
capabilities
capabilities: any
only
only: { string }
The features it’s used for when there are any, and those it isn’t, as it was set up.
except
except: { string }
LspFailure
A language server given up on (failures).
language
language: string
name
name: string
Its name: its language’s for the main one.
root
root: string
The folder it ran in.
said
said: { string }
Why: the last lines it wrote to stderr, or why it couldn’t start.
LspServer
A language server that’s running.
id
id: number
language
language: string
name
name: string
Its name: its language’s for the main one.
root
root: string
The folder it runs in.
command
command: { string }
ready
ready: boolean
Whether it has answered initialize.
stderr
stderr: { string }
The last lines it wrote to stderr.
LspProblem
uri
uri: string
range
range: { start: LspPosition, ["end"]: LspPosition }
severity
severity: number
message
message: string
source
source: string?
DiagnosticsChanged
buffer
buffer: Buffer
See Buffer.
Message
What the status line is about to show. What a handler echoes shows instead, and isn’t told again.
text
text: string
error
error: boolean
Something failed: an error, or a command that refused.
ModeChanged
A client’s mode changed. Handlers run as that client.
client
client: number
from
from: string
to
to: string
DirEntry
name
name: string
dir
dir: boolean
FileInfo
kind
kind: "file" | "dir" | "other"
size
size: number
Size in bytes; 0 for a directory.
mode
mode: number
Its permission bits, like 420 (644 in octal, as string.format("%o", mode) shows).
modified
modified: number?
When it last changed, in seconds since 1970, where the system says.
Hash
SHA-256 digests as lowercase hex, for checking a download or telling whether some text changed, and random bytes for one-time codes.
sha256
sha256: (data: string) -> string
The digest of data.
random
random: (count: number) -> string
count (1 to 1024) bytes from the system’s random source, as lowercase hex: for a one-time code or a sign-in’s PKCE verifier.
sha256_file
sha256_file: (path: string) -> (string?, string?)
The digest of the file at path, read in pieces, or nil and why. Needs “fs.read”.
Compare
Comparing values the way filters do, the same in a view’s filter (level>=warn) and a table’s where (RESTARTS>0): numbers as numbers, with sizes (512Mi, 1.5G, 250m), % and durations (3d16h, 500ms); log levels in their order; anything else as text without minding case.
number
number: (text: string, durations: boolean?) -> number?
text as a number: its first word, with a size suffix, a % or a duration in seconds; with durations, a lone m is minutes (an AGE column) rather than thousandths (kubectl’s CPU). Nil when it isn’t one.
test
test: (have: string, op: string, want: string, durations: boolean?) -> boolean
Whether have passes op (=, !=, ~ has it in it, !~, <, <=, >, >=) against want. durations defaults to whether want is one.
order
order: (a: string, b: string, durations: boolean?) -> number
-1, 0 or 1 as a comes before, with or after b: numbers first, then log levels, then text.
is_duration
is_duration: (text: string) -> boolean
Whether text is a duration with a unit only durations have (45s, 2h, 3d), so a column of them takes 12m as minutes.
find
find: (text: string) -> (number?, number?, string?)
The first operator in text: where it starts and ends (as string.find gives) and the operator. At one place, the longest (<=, not <).
QueryRow
A row for greed.query.run: its text for words, its fields’ values by name (a string or a list), the flags it has, its name (for in:NAME) and the row it’s in (parent, its index in the list).
QueryRow = { text: string?, fields: { [string]: string | { string } }?, flags: { string }?, name: string?, parent: number? }
QuerySchema
What a query’s fields and flags mean, for greed.query.run: each field’s kind by name (“text”, “exact”, “value” or “date”), each flag’s by name (“row”, kept on the rows, or “computed”, worked out by the source, so rows that depend on it are a maybe), whether words match anywhere in the text rather than as whole words, whether fields it doesn’t name are loose (any field compares as a value, from each row’s own), whether words mind case, and the field holding the places a row is in besides its parent (a mail’s labels), which in:NAME matches too.
QuerySchema = { fields: { [string]: string }?, flags: { [string]: string }?, anywhere: boolean?, loose: boolean?, case: boolean?, places: string? }
Query
Running a query core.query parsed, with its dates read into the days they cover (from and to on a date field’s term).
run
run: (query: any, rows: { QueryRow }, schema: QuerySchema) -> ({ number }?, { number }?, string?)
The rows of rows that match query (all of them, for nil), by their index and in their order, and those of them that only might, where it depends on a computed flag. Nil and why for a query that can’t run, like a regex that doesn’t compile.
fold
fold: (text: string) -> string
text as queries compare words and values when case doesn’t matter: in lower case, with accents taken off (“Café” as “cafe”).
IndexItem
An item for index:write: its key, unique in the index, the parent key of the item it’s in, its name (for in:NAME), its text for words, its fields’ values by name (a string or a list) and its flags. words names the fields searched by word (text fields); without it, every field is, which costs more to write.
IndexItem = { key: string, parent: string?, name: string?, text: string?, fields: { [string]: string | { string } }?, flags: { string }?, words: { string }? }
Index
An index on SQLite, from greed.index.open or greed.index.writer, that queries core.query parsed run over. Its methods run on another thread and wait like greed.sleep, so only in commands, event handlers and greed.spawn.
search
search: (self: Index, query: any, schema: QuerySchema, view: { sort: { { field: string, descending: boolean } }?, limit: number? }?) -> ({ string }?, { string }?, string?)
The keys of the items matching query (every item, for nil), as schema says what its fields and flags mean, sorted and cut as view says; and of those, the ones that only might match, where it depends on a computed flag (then nothing is cut). Nil and why for a query that can’t run.
items
items: (self: Index, keys: { string }) -> ({ IndexItem }?, string?)
The items with keys, as they were put in (without words), in that order; keys it doesn’t hold are left out. For showing what search found. Nil and why when it can’t read them.
write
write: (self: Index, items: { IndexItem }) -> (boolean?, string?)
Puts items in, in one go, each in place of the one with its key, with what its text mentions in its field ref (see refs); an index from open can’t be written. True, or nil and why.
remove
remove: (self: Index, keys: { string }) -> (boolean?, string?)
Takes the items with keys out. True, or nil and why.
count
count: (self: Index) -> (number?, string?)
How many items it holds, or nil and why.
IndexModule
Indexes on SQLite: one file that one program writes and any number read.
open
open: (path: string) -> (Index?, string?)
The index at path to read, while another program may write it; nil and why, as when it isn’t there. Needs “fs.read”.
writer
writer: (path: string) -> (Index?, string?)
The index at path to write, made if it isn’t there, and made again when another Greed’s version of it is there. Needs “fs.write”.
refs
refs: (text: string) -> { string }
What text mentions that lives elsewhere, sorted, as an index keeps it in each item’s field ref: a Jira ticket’s key, group/repo#12 and repo#12 for an issue, !12 for a merge request, a commit’s hash, and any link’s host, path and query. An index also counts bare PLAT-9 or repo!3 once a link has shown what they are; this only reads links.
TextMatch
A match of a regex in some text, from greed.text.matches.
TextMatch = { from: number, to: number, text: string, groups: { string | false } }
Text
Reading lines of text as Greed does, so plugins read them the same way.
shape
shape: (line: string, items: boolean?) -> (number?, string?)
How far line is indented and the key it starts with (name: or "name":), as YAML, indented JSON and kubectl describe nest; nil for a blank line. With items, a list item’s - counts as indent, so - name: x is a key name two further in.
width
width: (text: string, tab_width: number?) -> number
How many cells text takes on screen from a line’s start, as Greed draws it: wide characters (CJK, most emoji) take two, a tab reaches the next stop, tab_width (default 4) apart.
matches
matches: (text: string, pattern: string, limit: number?) -> ({ TextMatch }?, string?)
The matches of the regex pattern in text, first to last (at most limit): where each starts and ends, as string.find says it, its text, and its groups by number (false for one that took no part). Nil and why for a bad pattern. Searches and filters on a buffer go through Buffer.find.
Fs
Reading and writing the file system. Failures return nil and a message.
A relative path goes from the shown project’s root, and ~ is your home
folder.
list
list: (dir: string, opts: { hidden: boolean?, ignored: boolean? }?) -> ({ DirEntry }?, string?)
The entries directly in dir, folders first, then by name. Hidden
entries and ones .gitignore excludes are left out unless asked for.
read
read: (path: string, limit: number?) -> (string?, string?)
The file’s text, or its first limit bytes.
read_bytes
read_bytes: (path: string) -> (string?, string?)
The file’s bytes as they are, for a file that isn’t text, like an image.
stat
stat: (path: string) -> (FileInfo?, string?)
What’s at path; nil if nothing is, and nil and why when it can’t tell, as when a folder above it can’t be read.
write
write: (path: string, text: string, opts: { private: boolean?, background: boolean? }?) -> (boolean?, string?)
Replaces the file’s contents with text, creating it and its folders
if needed. It’s written whole or not at all. With private, only you
can read it (mode 0600), and folders made for it are only yours.
With background, it’s written on another thread and the caller
waits like greed.sleep (commands, handlers, greed.spawn), so a slow
disk never holds the editor up.
mkdir
mkdir: (path: string) -> (boolean?, string?)
Makes the folder at path and any missing folders above it. Needs “fs.write”.
remove
remove: (path: string, opts: { recursive: boolean? }?) -> (boolean?, string?)
Removes the file, link or empty folder at path; with recursive, a folder and everything in it. Nothing being there counts as removed. It refuses (an error) the root, your home folder, a path with .. and a folder holding Greed’s approvals or secrets. Needs “fs.write”.
rename
rename: (from: string, to: string) -> (boolean?, string?)
Moves or renames from to to, replacing a file there. It refuses what remove does. Needs “fs.write”.
copy
copy: (from: string, to: string) -> (boolean?, string?)
Copies the file from to to, creating its folders. Needs “fs.read” and “fs.write”.
watch
watch: (path: string) -> ()
Watches the file at path: whenever it changes, from inside the
editor or out, plugins hear “file.changed”. It needn’t exist yet.
cwd
cwd: () -> string
The directory Greed was started in.
dirs
dirs: () -> { home: string?, config: string?, cache: string?, data: string?, temp: string?, brought: string? }
Your home folder, Greed’s config folder (where init.luau and plugins/ were read from), its cache folder, its data folder (where plugins made in the editor go when the config can’t be written), the system’s folder for temporary files and, on the far end of greed ssh, the copy of your config it brought.
grep
grep: (
pattern: string,
dir: string?,
opts: { hidden: boolean?, ignored: boolean?, limit: number? }?
) -> ({ GrepLine }?, string?)
The lines matching the regex pattern in the text files under dir
(default: the current directory), sorted by path and line. It searches
in the background and waits like greed.sleep (commands, handlers, greed.spawn).
Hidden and ignored files are skipped unless asked for; limit
(default 10000) caps the lines returned. A bad pattern gives nil and
why.
scan
scan: (dir: string, opts: { ext: string?, read: boolean?, hidden: boolean?, ignored: boolean? }?) -> { ScannedFile }
The files under dir, sorted by path (from dir), each with its size and when it was last written (seconds since 1970), and its text with read (not for binary or very big files). Only files ending .ext with ext; hidden and ignored files are skipped unless asked for. It walks in the background and waits like greed.sleep, so an index of many files can see what changed without holding the editor up.
ScannedFile
A file greed.fs.scan found.
ScannedFile = { path: string, size: number, modified: number, text: string? }
GrepLine
A line greed.fs.grep found.
path
path: string
Relative to the directory searched.
line
line: number
0-based.
text
text: string
The line, without its line break.
matches
matches: { { from: number, to: number } }
Byte offsets of the matches in text.
PluginCheck
What greed.plugin.check found. types.skipped says why types weren’t
checked; tests.error why the tests couldn’t run.
types
types: { ok: boolean?, output: string?, skipped: string? }
tests
tests: { passed: number?, failed: { { file: string, name: string, message: string } }?, error: string? }
warnings
warnings: { string }
What looks wrong once it’s loaded with the others: a command it replaces from another plugin, keys bound to commands that don’t exist.
Plugins
list
list: () -> { string }
The names of the loaded plugins, sorted.
unload
unload: (name: string) -> ()
Removes a plugin and everything it registered: commands, keys, options and event handlers. Fails while another loaded plugin requires it. To turn off a default plugin, call this from your config.
load
load: (dir: string, name: string?) -> string
Loads (or reloads) the plugin in dir and returns its name. With
name, a folder without a plugin.toml loads too, with init.luau as
its entry.
dirs
dirs: () -> { [string]: string }
The folder of each plugin loaded from one, by name.
check
check: (dir: string) -> PluginCheck
Checks the plugin in dir without loading it: strict types against
Greed’s API (if luau-analyze is installed), then its tests with the
loaded plugins. Waits, like greed.sleep, while it runs. A plugin that
needs approving is tested with only what you approved for it, so what
needs more fails with “needs approval”, through the plugins it
calls and the commands it runs too.
describe
describe: (dir: string) -> PluginInfo
What the plugin in dir is and asks for, from its plugin.toml.
pending
pending: () -> { PluginInfo }
The plugins waiting until what they use is approved.
approve
approve: (dir: string) -> string
Approves what the plugin in dir declares, loads it, and loads the plugins that waited for it. Returns its name. Fails when a plugin without “plugins” started what runs: approving is yours to do.
caller
caller: () -> string?
The plugin whose code called yours: the innermost other plugin on the stack, or the one whose command, handler or task is running; nil if none but yours.
started_within
started_within: (capability: string) -> boolean
Whether everything that started the code running now may use capability: you (keys, the command line, your config), or plugins that have it. A vouch doesn’t hide what started it. For actions only you should take, like accepting a review.
within
within: <A..., R...>(name: string?, f: (A...) -> R..., A...) -> R...
Runs f with ... within the limit of the plugin name too, as if it had started it: for running what a plugin registered (a formatter, a runner, a source) later, from your plugin, so it can do no more than its plugin may. Config and unknown names add nothing. It can wait.
cleanup
cleanup: (remove: () -> ()) -> string
Runs remove when the plugin whose code called yours (see caller) is unloaded or reloaded, so what it added to your registry goes with it; with no other caller, when yours is, for your own cleanup. Returns that plugin’s name.
handler
handler: <A..., R...>(f: (A...) -> R...) -> (A...) -> R...
For registries of handlers, like a service’s: f, a function of the plugin whose code called yours (see caller), wrapped to run as that plugin’s own, as its event handlers do: only its capabilities count, whoever calls it later. A function of any other plugin is an error, so no plugin gets another’s capabilities through it; with no plugin calling (config, tests), f as it is.
PluginInfo
A plugin, as greed.plugin.describe tells it, for a review.
name
name: string
dir
dir: string
requires
requires: { string }
capabilities
capabilities: { { name: string, what: string } }
What it declares, each with what it lets the plugin do in words.
missing
missing: { string }
The capabilities not approved yet; empty when it may load.
Style
How text looks. Colors are “red”, “bright-blue” and the other 16 terminal colors, “default”, or “#rrggbb”. Fields left out leave whatever is underneath, so styles layer.
fg
fg: string?
bg
bg: string?
underline
underline: (boolean | string)?
true, or “line”, “curl”, “dotted”, “dashed” or “double”.
underline_color
underline_color: string?
bold
bold: boolean?
italic
italic: boolean?
dim
dim: boolean?
reverse
reverse: boolean?
strikethrough
strikethrough: boolean?
rounded
rounded: boolean?
For floats (ui.float): rounded corners, in the window drawn as an outline instead of box lines, in a terminal as ╭╮╰╯. The built-in themes set it in the gui part, so terminals draw square boxes.
shadow
shadow: boolean?
For floats in the window: a soft shadow under them.
badge
badge: boolean?
For text in the window: its background as a badge, a box with rounded corners a little inside its cells, as motion hints have.
hover
hover: boolean?
For something pressable in the window, like a button: lit up while the mouse is over it, drawn by the window itself. Terminals don’t.
checkbox
checkbox: ("empty" | "checked" | "choice" | "chosen")?
In the window, drawn as a control over the cells of its text: a checkbox (“empty” or “checked”, for todos) or a choice (“choice” or “chosen”). Terminals show the text.
font
font: string?
The window’s font for the text: “mono”, the grid’s (gui-font), “prose”, a proportional one (gui-font-prose) fitted into the same cells, or a family’s name, like “Monaspace Radon”, drawn in the grid’s cells, or in the grid’s font when it isn’t installed. Terminals have only the one.
ThemeEntry
A theme entry: a style for every client, with changes for the terminal
(tui) or a graphical client (gui).
tui
tui: Style?
See Style.
gui
gui: Style?
See Style.
Syntax
The tree-sitter queries each language uses: “highlights” for highlighting,
“injections” for languages inside others (code blocks in Markdown), and
others (“textobjects”, …) that plugins read. The languages plugin sets them
from the queries/<language>/<kind>.scm files in plugins and your config.
set_query
set_query: (language: string, kind: string, source: string?) -> ()
Sets the kind query for language, or with nil takes this plugin’s away.
Errors if the language’s grammar can’t compile it. The newest one set is
used, and unloading a plugin takes its queries away.
query
query: (language: string, kind: string) -> string?
The kind query in use for language: the one set, the one set for the
language it shares a grammar with, or for “highlights” and “injections”
the one that comes with the grammar.
share_grammar
share_grammar: (language: string, other: string) -> ()
Lets language use the grammar of other, which has one, like Starlark
Python’s. It uses other’s queries too, except those set for it.
load_grammar
load_grammar: (language: string, path: string, symbol: string?) -> ()
Loads the grammar for language from a WebAssembly file, like one built
with tree-sitter build --wasm, so buffers in it get a syntax tree. symbol
is the grammar’s own name when it differs, e.g. “c_sharp” for “c-sharp”;
by default the language with “-” as “_”. Queries come separately.
Needs “fs.read”.
tags
tags: (dir: string?, opts: { limit: number? }?) -> { FileTags }
What the source files under dir (default: the current directory) define and use, from their syntax trees: the functions and types their “textobjects” query finds and how often each name appears, sorted by path. Hidden and ignored files are skipped; limit (default 10000) caps the files. It parses in the background and waits like greed.sleep. Needs “fs.read”.
FileTags
What one file defines and uses, from greed.syntax.tags.
path
path: string
Relative to the directory searched.
language
language: string
definitions
definitions: { { name: string, kind: "function" | "type", line: number, signature: string } }
Each with its 0-based line and its first line as signature.
references
references: { [string]: number }
How often each name appears in the file.
Theme
What style names look like. Everything on screen has one: “ui.text”, “ui.selection”, “ui.statusline.mode”, “ui.float.border”, “keyword”, “diagnostic.error”, or a name a plugin made up. Names fall back to their parent, so “markup.heading.1” uses “markup.heading” if it has no entry.
set
set: (entries: { [string]: ThemeEntry }) -> ()
Sets entries by name. Each changes only the fields it gives of the theme’s entry underneath, and replaces what was set for that name before.
base
base: (entries: { [string]: ThemeEntry }) -> ()
Replaces the base theme, the entries under those set with set: a
theme plugin calls it to switch themes without touching what your
config or other plugins set.
get
get: (name: string) -> ThemeEntry?
The entry for exactly name, if there is one.
EventName
The events greed.on and greed.off take; any other name is an error.
EventName =
Events
What greed.on(event, handler) hands each handler. Give the handler’s parameter the type named here, as in function(event: greed.BufferChanged), and the type checker catches a misspelled field. When each event happens is in Writing plugins; space h e (:describe-event) shows the same in the editor.
mode.changed
Its handler gets a greed.ModeChanged. A client’s mode changed. Handlers run as that client.
{
client: number,
from: string,
to: string,
}
buffer.changed
Its handler gets a greed.BufferChanged.
{
buffer: Buffer,
--- On "buffer.changed": the first and last line (0-based, as the text is
--- now) of what changed since the last "buffer.changed" for the buffer.
from_line: number?,
to_line: number?,
}
keys.pending
Its handler gets a greed.KeysPending.
{
--- The client typing them, which handlers run as.
client: number,
--- The unfinished key sequence, e.g. "space"; "" once it's finished.
keys: string,
}
command.run
Its handler gets a greed.CommandRun.
{
--- The client it runs for, which handlers run as.
client: number,
--- The command about to run.
name: string,
--- The keys that ran it, when keys did, e.g. "g g".
keys: string?,
--- The number typed before the keys.
count: number?,
}
lsp.diagnostics
Its handler gets a greed.DiagnosticsChanged.
{
buffer: Buffer,
}
message
Its handler gets a greed.Message. What the status line is about to show. What a handler echoes shows instead, and isn’t told again.
{
text: string,
--- Something failed: an error, or a command that refused.
error: boolean,
}
control.request
Its handler gets a greed.ControlRequest. A request from the session socket, e.g. from greed ctl or an agent. Answer it with greed.control.reply.
{
id: number,
--- "socket" for the session socket (greed ctl, greed mcp), "ide" for Claude
--- Code's IDE connection.
client: string,
--- The session socket connection it came on, for `greed.control.send`;
--- nil for Claude Code's IDE connection.
connection: number?,
--- The JSON-RPC id as the client sent it, the one a later
--- `notifications/cancelled` names; nil for a notification.
rpc_id: any,
method: string,
params: any,
}
control.closed
Its handler gets a greed.ControlClosed. A session socket connection closed, after its last request came.
{
--- The connection, as `ControlRequest.connection` gave it.
connection: number,
}
client.attached
Its handler gets a greed.ClientAttached. A client attached, e.g. greed FILE in a session that was running. Handlers run as that client.
{
--- The client's id.
client: number,
--- The file or folder it asked to open, if any.
path: string?,
--- Whether it asked for a terminal, e.g. `greed ssh HOST --terminal`.
terminal: boolean,
--- Whether it asked for the project's greed shell, e.g. `greed --shell`.
shell: boolean,
--- Whether it came over `greed ssh`.
remote: boolean,
}
client.detached
Its handler gets a greed.ClientDetached. A client went; the session goes on. Handlers run as that client, just before it’s gone.
{
client: number,
}
client.paste
Its handler gets a greed.ClientPaste. Text pasted into the client from the system clipboard: a terminal’s paste, or a window’s paste keys (ctrl-shift-v, shift-insert, cmd-v). The core plugin puts it at the cursors.
{
--- The client it was pasted into, which handlers run as.
client: number,
text: string,
}
buffer.opened
Its handler gets a greed.BufferChanged.
{
buffer: Buffer,
--- On "buffer.changed": the first and last line (0-based, as the text is
--- now) of what changed since the last "buffer.changed" for the buffer.
from_line: number?,
to_line: number?,
}
buffer.saved
Its handler gets a greed.BufferChanged.
{
buffer: Buffer,
--- On "buffer.changed": the first and last line (0-based, as the text is
--- now) of what changed since the last "buffer.changed" for the buffer.
from_line: number?,
to_line: number?,
}
buffer.closed
Its handler gets a greed.BufferClosed. A buffer was closed. Only its id is left.
{
id: number,
}
view.closed
Its handler gets a greed.ViewClosed. A view was closed. Its handle no longer works, but its id can be compared with view:id().
{
view: number,
}
view.resized
Its handler gets a greed.ViewResized. A view was drawn for a client with room for a different number of rows or columns of text than before. Handlers run as that client.
{
client: number,
view: View,
rows: number,
cols: number,
}
pane.opened
Its handler gets a greed.PaneOpened. A pane was opened, beside from.
{
view: View,
from: View,
}
view.scrolled
Its handler gets a greed.ViewScrolled. A view was drawn for a client starting at a different line than before. What a handler changes shows in the same frame, so a view can scroll another along with it. Handlers run as that client.
{
client: number,
view: View,
--- The 0-based line now at the top.
line: number,
}
selection.changed
Its handler gets a greed.SelectionChanged. A view’s selection changed for a client, or it shows another buffer, since the last frame: told once a frame however many changes there were, whatever made them (keys, the mouse, undo, a plugin or an agent). Handlers run as that client.
{
client: number,
view: View,
}
view.focused
Its handler gets a greed.ViewFocused. Another view has a client’s focus. from had it before; nil when it was closed. Handlers run as that client.
{
client: number,
view: View,
from: View?,
--- The focus was moved under the client rather than by it: what it had focused went out of sight by another client's doing (another tab or project shown, a pane closed), or it followed the others again. Its half-typed keys were dropped.
moved: boolean,
}
ssh_agent.use
Its handler gets a greed.SshAgentUse. A program in a session greed ssh started asks to sign with one of your ssh keys, through the client relaying your agent. Answer with greed.ssh_agent.answer; with no answer, or no handler, it may not.
{
--- The request, for `greed.ssh_agent.answer`.
id: number,
--- The client relaying your agent, which handlers run as.
client: number,
--- The machine that client is on, if known.
host: string?,
}
mouse
Its handler gets a greed.MouseEvent. What the mouse did, and what was under it.
{
--- The client whose mouse it was, which handlers run as.
client: number,
kind: "press" | "release" | "drag" | "move" | "scroll",
--- For a press, release or drag.
button: ("left" | "middle" | "right")?,
--- For a scroll.
dir: ("up" | "down" | "left" | "right")?,
--- The screen cell, from the top left.
col: number,
row: number,
ctrl: boolean,
alt: boolean,
shift: boolean,
--- The view under it, if any.
view: View?,
--- The place in the view's buffer under it: the character there, or the
--- end of the line past it. Over a mark's text, where the mark starts.
pos: number?,
--- The action of the mark whose text it's over, or of the status line segment (with no `view`), if that has one.
action: string?,
--- The cell in the view's text, from its top left, right of the gutter.
x: number?,
y: number?,
--- The tab whose name it's over, in the tab line.
tab: number?,
--- On a floating view's border (with `view` set), which part: "top" (the title's), "bottom", "left", "right", or a corner like "bottom-right".
border: ("top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right")?,
--- On the line between a pane or panel (`view`) and its neighbor, the side of `view` it's on: "right" or "down" for panes, the side by the main view for panels. Dragging it resizes `view` with `resize`.
edge: ("left" | "right" | "down")?,
}
option.changed
Its handler gets a greed.OptionChanged. An option was set, with greed.option.set or :set.
{
name: string,
--- Its value now, as the client it was set for has it.
value: OptionValue,
--- The client it was set for, when one got a value of its own.
client: number?,
}
plugin.loaded
Its handler gets a greed.PluginLoaded. A plugin was loaded (or reloaded) and its entry file ran.
{
name: string,
--- Its folder, for plugins loaded from one.
dir: string?,
}
file.changed
Its handler gets a greed.FileChanged. A file watched with greed.fs.watch was written, created or removed.
{
path: string,
}
plugin.unloaded
Its handler gets a greed.PluginUnloaded. A plugin was unloaded, and everything it registered removed.
{
name: string,
}
editor.started
Its handler gets nothing.
editor.quitting
Its handler gets nothing.
terminal.output
Its handler gets a greed.TerminalOutput. A terminal printed something; read it with terminal:screen().
{
terminal: Terminal,
}
terminal.exited
Its handler gets a greed.TerminalExited. The program in a terminal ended.
{
terminal: Terminal,
code: number,
--- Whether a signal ended the program, rather than its own exit.
signaled: boolean,
}









