espressostreamdocs
On this page

CLI guide

espresso is one binary with subcommands. espresso --help lists them all, and espresso <command> --help lists the flags of one command. Flags can be written with one dash or two (-c and --title both work). They go before the file argument or after it.

Command What it does
rec record a shell or a command into a .cast file
play replay a recording in the terminal
cat print a recording's output without timing
convert convert between asciicast v2 and v3
edit cut, redact, speed up or shorten pauses
scan list likely secrets in a recording
upload upload a recording to an espresso server
auth log in to a server, check or remove the login
stream record and stream live, through a server or from your machine
mark add a marker to the running recording from a script
shell-integration print a snippet that marks every command
agent-hooks print hooks for an AI coding agent
version print the version

rec

espresso rec [file] [-c CMD] [--login] [--record-input] [--idle-limit S] [--title T]
             [--format v2|v3] [--append] [--overwrite]
             [--headless] [--window-size CxR] [--trace-exec] [--redact-default] [--redact RE] [--agent]

Starts your shell ($SHELL) in a new pseudo-terminal and records everything it prints, with timing, until the shell exits. Without a file name it writes espresso-YYYYMMDD-HHMMSS.cast in the current directory and prints the name. It never uploads anything.

espresso rec                         # record the shell
espresso rec build.cast -c 'make'    # record one command (run with /bin/sh -c); exits with its exit code
espresso rec --title "Deploy" demo.cast
Flag Meaning
-c CMD, --command CMD record this command instead of the interactive shell
--login start the shell as a login shell
--title T title stored in the header
--idle-limit S players shorten pauses longer than S seconds (stored in the header; the file keeps the real timing)
--record-input also record what you type. Off by default, because it would include passwords you type
--format v2|v3 file format (default v3)
--append continue an existing recording
--overwrite replace an existing file
--no-shell-marks don't turn shell-integration marks into markers
--no-status don't show pause/marker feedback in your terminal
--headless no terminal needed: fixed-size terminal, nothing shown, needs -c (agents, CI)
--window-size CxR terminal size when there is no terminal (default 120x40 headless, else 80x24)
--trace-exec also record every program the session runs into <file>.trace.jsonl, e.g. demo.cast.trace.jsonl (Linux)
--redact-default mask secrets in the trace and in markers
--redact RE mask matches of an extra regular expression (repeatable)
--agent shorthand for --headless --trace-exec --redact-default

The last six flags are mostly for automated recordings. See Agent recordings.

Keys while recording. Ctrl-] is the prefix key:

Keys Action
Ctrl-] p pause or resume; paused time is left out, and a paused marker is added
Ctrl-] m add a marker named marker N
Ctrl-] M add a marker with a name you type (Enter adds it, Esc cancels)
Ctrl-] Ctrl-] send a literal Ctrl-] to the program

Feedback for these keys appears briefly in the bottom-right corner of your terminal. It is never part of the recording (--no-status turns it off).

What rec does to your environment. The recorded program gets your environment unchanged, plus ESPRESSO_RECORDING=1 and ESPRESSO_CONTROL (the path of the recording's control socket, used by mark). When the recording ends, even after a crash or a signal, espresso switches off the terminal modes the program left on (alternate screen, mouse reporting, bracketed paste, hidden cursor, and so on) and gives your terminal back in a usable state.

Crash safety. The file is written as the session runs and flushed at least every couple of seconds. If espresso is killed, the file is still readable, minus at most the last line.

play

espresso play <file|url|-> [--speed X] [--idle-limit S] [--loop] [--pause-on-markers]

Replays a recording in your terminal at its original speed. - reads from standard input. A URL must point at the .cast file itself, for example https://casts.example.org/api/v1/recordings/<id>.cast.

Flag Meaning
--speed X playback speed (default 1)
--idle-limit S shorten pauses to at most S seconds (default: the recording's own setting; -1 for none)
--loop start again at the end, forever
--pause-on-markers pause at each marker

Keys: space pauses and resumes, q or Ctrl-C quits.

cat

espresso cat <file|url|->...

Writes all the output of one or more recordings to standard output at once, with escape sequences kept. espresso cat demo.cast | less -R pages through it.

convert

espresso convert <in> <out> [--format v2|v3] [--overwrite]

Converts between asciicast v2 and v3 (default v3). The conversion loses nothing: fields one version doesn't have are carried along, and other readers ignore them. See File format.

edit

espresso edit <in> <out> [--cut A-B]... [--redact RE]... [--redact-str S]... [--redact-default]
              [--speed X] [--idle-limit S] [--in-place] [--overwrite]

Writes an edited copy of a recording.

Flag Meaning
--cut A-B remove the time range from A to B. Times are seconds, m:ss or h:mm:ss, measured in the original recording. Repeatable
--redact RE mask every match of a regular expression (Go RE2 syntax). Repeatable. A group named s ((?P<s>…)) masks only that group
--redact-str S mask a literal string. Repeatable
--redact-default mask everything the built-in secret patterns match
--speed X speed factor (2 = twice as fast)
--idle-limit S shorten pauses longer than S seconds, for good
--in-place allow <out> to be the same file as <in>
--overwrite replace an existing <out>
espresso edit demo.cast short.cast --cut 0:10-0:42 --idle-limit 2
espresso edit demo.cast demo.cast --in-place --redact-str 'hunter2'

Redaction covers output, recorded input, markers and the title, including a secret that was printed in several pieces. Each masked secret becomes [REDACTED]. The timing stays as it was. A recording that has an exec trace (demo.cast.trace.jsonl next to demo.cast) is edited together with its trace.

Privacy: scan and redact

espresso scan <file>

Lists the likely secrets in a recording, masked, and exits with status 1 if it found any. The built-in patterns cover:

  • authorization and API-key headers, and passwords in URLs
  • --password=/--token= style flags, and --password VALUE pairs
  • *_TOKEN=/*_SECRET= style assignments
  • tokens from GitHub, GitLab, Slack, AWS, Google, Stripe, Anthropic, OpenAI and npm
  • JWTs and PEM private keys

They catch the common cases, not everything. Before you make a recording public, watch it.

Markers made by shell integration contain the command lines you ran, so a secret typed as a command argument shows up there too. scan and edit check markers as well as output.

upload

espresso upload <file> [--server URL] [--visibility unlisted|public|private] [--title T] [--yes [--allow-secrets]] [--scan]

Shows a summary first: size, duration, title, visibility, server and the first lines of output. It notes recorded keyboard input and lists likely secrets, then asks Upload? [y/N]. After the upload it prints the recording's URL.

Flag Meaning
--server URL server to upload to (default: the one you logged in to)
--visibility V unlisted (default), public or private. Agent recordings default to private
--title T title (default: the recording's)
--yes don't ask. Refuses to upload if likely secrets were found…
--allow-secrets …unless this is given too
--scan only list likely secrets, then stop (exit 1 if any)
--no-redact agent recordings: upload without masking secrets

Without a terminal (in a script), upload refuses unless --yes is given. The visibilities:

  • public: listed on the server's home page, on your profile and in search.
  • unlisted: not listed anywhere; anyone with the link can watch it.
  • private: only you, when signed in. Admins can't see it either.

If the recording has an exec trace (<file>.trace.jsonl, e.g. demo.cast.trace.jsonl), it is uploaded with it.

auth

espresso auth login  [--server URL]
espresso auth status [--server URL]
espresso auth logout [--server URL]

login asks for an API token (typed input is hidden), checks it against the server, and saves it in ~/.config/espressostream/credentials.json ($XDG_CONFIG_HOME if set, %APPDATA%\espressostream on Windows), readable only by you (mode 0600). You can get a token in two ways: create one on the server's Settings page, or ask an admin to run espresso-server admin create-token. Without a terminal, login reads the token from one line of standard input.

status shows who you are logged in as; logout deletes the saved token.

Which server is used: --server, else $ESPRESSO_SERVER, else the last server you logged in to.

stream

espresso stream --local ADDR [file] [rec flags...]
espresso stream [--server URL] [--visibility V] [file] [rec flags...]

Records exactly like rec, takes the same flags, and streams the session live at the same time. It also saves the .cast file as usual, unless you pass --no-save.

  • Through a server (espresso stream): uses the token from auth login and prints a viewer link (/s/<id>). Visibility defaults to unlisted (private with --agent). When the stream ends, the server saves it as a normal recording, unless the server is set to not save streams.
  • From your machine (espresso stream --local :8080): serves a viewer page itself and prints its URL. :PORT listens on 127.0.0.1 only; use 0.0.0.0:8080 to share on your network. There is no login: anyone who can reach the address can watch.

Viewers can pause a live stream and scrub back through what they've received; L (or the "Live · behind by …" button) returns to the live edge. See the player keys.

Flag Meaning
--local ADDR serve the viewer yourself instead of using a server
--server URL espresso server (default: the one you logged in to)
--visibility V unlisted, public or private (server streams)
--no-save don't write the local .cast file
--no-redact don't mask secrets in the streamed output (agent streams)

Viewers who join late see the screen from the last full-screen clear onward, and then the live output. Agent streams (--agent, --redact-default, --redact RE) mask secrets in the output before it leaves your machine. The local file is not masked.

mark

espresso mark [LABEL...]          add a marker (and start a step) in the current recording
espresso mark --exit N            end the current step with exit status N
espresso mark --hook claude-code  read a Claude Code hook event (JSON) on stdin

For scripts and agents running inside a recording: espresso mark "running tests" adds a chapter at that moment. Outside a recording it does nothing and exits 0, so it is safe to leave in scripts.

shell-integration

espresso shell-integration zsh|bash|fish|pwsh

Prints a snippet for your shell's startup file. Inside a recording, it marks the start and end of every command (OSC 133). The recording then gets a marker $ <command> when a command starts and exit <status> when it ends, and the web player shows each command as a chapter with its exit status.

eval "$(espresso shell-integration zsh)"     # ~/.zshrc
eval "$(espresso shell-integration bash)"    # ~/.bashrc, bash 4.4 or newer
espresso shell-integration fish | source     # ~/.config/fish/config.fish; fish 4 sends the marks itself

Outside espresso rec the snippet does nothing, so it doesn't conflict with your terminal's own shell integration. pwsh prints a "not available yet" note. Marks from other sources (fish 4, terminal integrations) are used too. --no-shell-marks on rec ignores them.

Notes: in bash the label comes from history, so a command kept out of history shows as $ (command). A pasted multi-line command gives one marker in zsh and fish, and one per line in bash.

Environment variables

Variable Used by Meaning
ESPRESSO_SERVER upload, auth, stream default server URL
ESPRESSO_RECORDING set by rec 1 inside a recording
ESPRESSO_CONTROL set by rec control socket of the running recording (used by mark)
SHELL rec the shell to record