Skip to content
inxbitPublic

About

Fast terminal output highlighter focused on network devices and Unix systems

Topics

Resources

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

PrismTTY

PrismTTY

website crates.io docs.rs CI release license

PrismTTY makes dense SSH, network-device, and Unix/Linux terminal output easier to scan in real time. It is a fast ChromaTerm-style CLI wrapper with network-focused built-in profiles.

Website: prismtty.com.

Quick Demo

Animated PrismTTY terminal demo

Preview

Real PrismTTY output over synthetic fixtures (invented hosts, documentation-range addresses):

Highlighted PrismTTY terminal output

Dynamic PrismTTY profile switching

What This Is / What This Is Not

PrismTTY is a live terminal-output highlighter for shells, SSH sessions, pipes, and logs.

It highlights output that is already flowing through your terminal, including:

  • prompts
  • interfaces
  • IP addresses
  • protocol state
  • counters
  • severity
  • common vendor terms

PrismTTY is not:

  • an NMS
  • a configuration-management tool
  • a source of truth
  • a SIEM
  • a log platform
  • a device inventory system

It does not log in to devices by itself, collect inventory, push configuration, or store operational data.

Install

PrismTTY builds and is tested on macOS and Linux. Every install method provides the same three commands: prismtty, plus the ptty and ct aliases. All three run the same binary; ct matches ChromaTerm's command name so existing ChromaTerm habits and scripts keep working.

Homebrew

Install the latest release from the PrismTTY Homebrew tap:

brew install inxbit/tap/prismtty

The Homebrew formula installs prismtty, ptty, ct, bundled profiles, and shell completions. It also installs the required PCRE2 runtime dependency.

If another package already owns ct in the Homebrew prefix (the chart-testing and coreos-ct formulae install one), the formula leaves its own ct unlinked under libexec, keeps the name out of the completions it installs, and says so at the end of the install; prismtty and ptty are linked as usual. The choice is made when PrismTTY is installed. If the other package arrives later, its link step stops at PrismTTY's ct, and unlinking PrismTTY as Homebrew then suggests removes all three commands; run brew link --overwrite for the other package instead, then brew reinstall inxbit/tap/prismtty. If an earlier PrismTTY install stopped at the link step, run brew link prismtty after upgrading: Homebrew keeps a formula unlinked across an upgrade or a reinstall.

Cargo

Install from crates.io:

cargo install --locked prismtty

Cargo builds PrismTTY from source and installs the command binaries. You need Rust 1.85 or newer plus PCRE2 and pkg-config available on your system. --locked builds with the dependency versions audited for the release.

For cargo install on macOS, install the native build dependencies first:

brew install pcre2 pkg-config

For cargo install on Debian/Ubuntu, install:

sudo apt-get install libpcre2-dev pkg-config

Cargo installs the binaries only. Shell completions for zsh, bash, and fish live in completions/; copy the file for your shell into its completions directory.

For fish, also link prismtty.fish under the ptty and ct names, because fish only loads a completion file named after the command being completed:

cd ~/.config/fish/completions
ln -s prismtty.fish ptty.fish
ln -s prismtty.fish ct.fish

The bash-completion on-demand directory works the same way: install prismtty.bash there as prismtty, ptty, and ct, or source it from ~/.bashrc.

GitHub Release

Prebuilt release archives and checksums are available on the latest release page.

Each release archive contains the binaries, license/readme files, example profiles, and shell completions. Its .tar.gz.sha256 checksum is a separate file next to it on the release page. The binaries load PCRE2 at run time: from Homebrew (brew install pcre2) on macOS, and from the system libpcre2-8 on Linux. The Linux binaries require glibc 2.34 or newer and any x86-64 CPU, are built and tested on Ubuntu 22.04, and load the system's libpcre2-8.so.0 and libgcc_s.so.1.

Build Locally

Build from a checkout with:

cargo build --release

The project builds these user-facing binaries:

  • prismtty
  • ptty
  • ct

Release packages can be built with:

scripts/package-release.sh

The release workflow generates a Homebrew formula from the actual release checksums and uploads it as prismtty.rb with the release artifacts. The published tap formula lives in inxbit/homebrew-tap.

Usage

ptty /bin/zsh
ptty ssh router.example.net
prismtty --profile cisco < show-tech.txt
prismtty profiles test cisco fixtures/cisco.txt
prismtty --reload

The recommended interactive workflow is to start one wrapped shell from your terminal profile:

ptty /bin/zsh

From inside that shell, run normal ssh, telnet, or console-wrapper commands. PrismTTY dynamically switches profiles from observed login banners and prompts, then keeps the selected remote profile locked for the session. Normal command output such as interface descriptions cannot churn the profile in the middle of the session. Nested remote sessions are still supported: a typed remote-jump command arms the next strong banner or repeated prompt to push a new profile, and connection-close markers pop back to the previous profile. If a connection attempt fails with a message PrismTTY does not recognize and a device prompt follows it, a later close line that names an outer host can leave the remote profile active.

Leaving a device that you reached from another device returns to the first device's colors when the output shows the end of that connection. After you type or paste exit, quit or logout, or press Ctrl-D on an empty line (a line edited with the arrow keys, Tab, Ctrl-W or another control key, or recalled from history, does not count; Backspace and Ctrl-U do), PrismTTY needs [Connection to NAME closed by foreign host], where NAME is the host you typed in the ssh, mosh or telnet command, and then, as the first prompt after it, exactly the prompt you were at when you opened that connection, ending within the first 512 bytes after the echo of your exit line (bytes as received, escape sequences not counted), with both lines within 3 seconds. A complete prompt line confirms at once, unless it follows an Enter alone. A waiting prompt confirms when the next line you type there, with at least one character before its Enter, is followed by exactly the bytes you typed, with nothing else shown in between and your Enter matched by a carriage return or a line feed. The colors change at that line end: the prompt line and the part of the command shown before it are drawn in the colors of the device you left, unless the echo comes in the same read as the line end, as in a paste; everything after the line end is read in the parent's colors like any output, so a banner there switches to the next device. An Enter alone does not confirm; the next line typed at the prompt shown again for it does, if that prompt still ends within the 512 bytes after the echo of your exit line. At a waiting prompt, Backspace, Ctrl-U, Tab, Ctrl-C, other output, and a parent that does not echo keep the child's colors, as do keys typed before the prompt appeared. After Ctrl-] and quit (or q, qu, qui) in telnet, PrismTTY needs telnet's own telnet> quit line (or the shorter word you typed) within 4,096 bytes, ending after your Enter, then Connection closed. or Connection closed as the first non-blank line within 256 bytes, with no time limit, and every telnet in the chain must have announced its escape character (Escape character is '^]'.). A telnet that drops with a bare Connection closed. keeps its colors. The close messages PrismTTY already recognized, such as Connection to NAME closed. or Connection closed by foreign host., still end a connection as before, and Shared connection to NAME closed., which ssh prints through a shared connection (ControlMaster), now does too. These lines are trusted, and the bytes after the prompt cannot show which program printed them: a device, or a logout script on it, that prints the bracket and the exact parent prompt while you are still connected, such as a saved session log, switches the colors early, as does one that prints the bracket and the exact parent prompt and then exactly the bytes you type. A program you run inside a connection that shows ssh's own close line on a line of its own, such as a tool that runs ssh for you on a jump host, can end that connection's colors early in the same way when no ssh was typed inside that connection. Only colors change, except that with --show-profile and an unread stderr, the confirming read, and terminal output with it, waits until stderr drains.

After a command you run at the local shell switches the colors, such as cat of a saved device log, the laptop's colors may come back after the shell's next prompt, if these checks pass: that command's own job has ended and the shell has no other job left. PrismTTY checks once the prompt has been quiet for 250 ms, or at your next key, and the check can decline; anything it cannot find out counts as no, and the changelog lists each check. A prompt's helper whose parent has ended and that is not in the shell's own process group, such as powerlevel10k's gitstatusd, does not hold the colors back. The colors stay as before while the shell has any job in the background or stopped, for commands that run no job of their own (builtins, job control off), after a line that starts with exec, and for sessions opened by typing ssh, mosh, telnet, screen, cu, minicom or picocom. When a job has made a check decline and then ends, the colors do not come back while nothing more is drawn: the next check comes with the same prompt drawn again, with the end of a later command, or with your next key if it was the listing of the shell's processes that did not prove the shell alone. A line you start typing after other output has followed the prompt is not checked; the colors can come back when the next command that runs a program, typed at a drawn prompt, ends, if the checks pass. A program started at the moment the colors come back (its line entered while the check runs, or pasted with its Enter) can start in the laptop's colors, as one started just after, and is colored once it identifies itself. PrismTTY cannot tell which program wrote a line: a program that is no longer the shell's job (it left the shell's session, or the process that started it has ended) and keeps writing to the terminal is drawn in the laptop's colors once the prompt is back, even while it is still connected; ssh -f and screen -dm leave the job on purpose. Only colors change, with the same --show-profile exception.

Interactive mode is designed to preserve shell line editing and typed command echo, including zsh prompts that use decorative Unicode prompt markers such as ╰─○, ❯, or ➜. Output that stops on a byte that could begin a UTF-8 character, such as a Latin-1 é (byte E9), is held: the byte is shown when more output arrives or the output ends.

Use stdin mode for noninteractive output from files or pipes:

prismtty --profile cisco < show-tech.txt
journalctl -xe | prismtty --profile linux-unix

When PrismTTY reads a file or a pipe, highlighting pauses while the alternate screen that full-screen programs such as less and vim draw on is active, and resumes when that screen is closed or the terminal is reset. Output that ends before then, such as a log cut off while a pager was open, stays unhighlighted from the switch on.

A wrapped command runs in the current directory. Descriptors above 2 that the caller passes (ptty cmd 3<file, ptty diff <(a) <(b)) reach the command as they would without the wrapper. When stdin is not a terminal (a script, a CI job, or ptty make < /dev/null), the command reads that stdin directly while its output still goes through the PTY and is highlighted. If the command cannot be found or run, PrismTTY exits with 127 or 126, as a shell does; otherwise it exits with the command's own status. When the output goes to a regular file (ptty make > build.log), or to a pipe while stdin is not a terminal, the command's PTY starts with output processing off, so LF and CR LF line ends are saved as the command wrote them; the command can change that setting. With the keyboard on a terminal and the output in a pipe (ptty ssh host | tee log) the PTY keeps its usual output settings, because the pipe usually leads back to that terminal. With stdin redirected and the output on a terminal (ptty make </dev/null), the PTY keeps its usual settings too, so a recording of that terminal's output holds an extra carriage return on each line (CR CR LF); on screen the lines look the same. This is on purpose: the PTY ends each line with CR LF itself, so the lines still start at the left edge if another program turns off the terminal's output processing during the session.

A command killed by a signal is reported as 128 plus the signal number, as a shell does, with one exception: when SIGINT (Ctrl-C) kills the command, PrismTTY ends by SIGINT too, after restoring the terminal, so a loop typed at a shell prompt stops after one Ctrl-C as it does without PrismTTY. In a shell $? is still 130; a program that reads the wait status sees the signal (Python's subprocess reports -2, make prints Interrupt). PrismTTY keeps 130 when it was started with SIGINT ignored or blocked. A script that runs with the terminal on its stdin, and a zsh or dash pipeline where PrismTTY is not the last command, still go on after one Ctrl-C, because those shells stop only when they receive the Ctrl-C themselves and PrismTTY, holding the terminal in raw mode, receives it instead.

When PrismTTY itself is sent a signal that ends it, such as SIGTERM, SIGHUP, SIGINT or SIGQUIT, and the command is still running, PrismTTY passes the signal on to the command's process group and, as before, kills what is left of that group as soon as the command exits, or after two seconds. If the command exited by itself (its wait status is an ordinary exit, even one that came near or after those two seconds), PrismTTY, which gives the terminal back as soon as it takes the signal, as before, then draws the output that reached it and exits with the command's exit code, so a command that cleans up on SIGTERM and exits 0 gives 0. If the command was killed by a signal or could not be collected, or that normal end does not complete within about four seconds of the signal, the end is abrupt, as before: PrismTTY exits with 128 plus the signal it was sent, and output not yet drawn can be lost. It ends by SIGINT instead when it was sent SIGINT and the command died from it, so a command that dies from SIGINT after PrismTTY was sent SIGTERM still gives 143. The four seconds count while PrismTTY is not stopped; on macOS a PrismTTY that leads its terminal's session also waits, as it exits, while output it wrote to that terminal is still unread. The exit code describes the command PrismTTY started, not the rest of its process group: 0 does not mean that every process in the group finished cleanly. PrismTTY acts on the first such signal recorded before the final pending-signal check in its shutdown handoff, including one recorded while the session is ending; a later recorded one does not replace it. If none is recorded by that check, PrismTTY gives the signals back to their previous actions. Give-back and any reinstallation of PrismTTY's handlers each use one sigaction per signal, so a signal during either transition can take its previous action or reach PrismTTY's handler, except that SIGUSR1 and SIGUSR2 are given back last and never once such a signal is recorded. When such a signal is recorded just after they were given back, PrismTTY first puts its handler back on those of them it had caught, unless that sigaction fails; one of them that is being delivered as that happens can still take its previous action. A handler that entered earlier but records such a signal only after the final check has no taker; that signal does not change the session's otherwise determined result. After give-back completes without reinstallation, later signals take their previous actions. On macOS, a SIGTSTP, SIGTTIN, SIGTTOU or SIGCONT delivered on another of PrismTTY's threads at the moment its default action is put back can end PrismTTY by that signal instead of stopping or continuing it; at a normal end PrismTTY has already tried to restore the terminal then.

SIGUSR1 and SIGUSR2 sent to PrismTTY are passed to the command it started, alone, while it runs, unless PrismTTY inherited them ignored or blocked, and do not end PrismTTY themselves; like any signals of one kind they can coalesce. When PrismTTY records a signal that ends it, SIGUSR1 and SIGUSR2 sent after the record are no longer passed on, and each of PrismTTY's threads that takes one of them after that blocks both for itself (on macOS, and on Linux on x86-64 and ARM64), so a flood of them does not hold up that end; elsewhere they are not passed on after the record, but each one is still taken, so a flood of them can still hold up that end. When the command ends without such a signal, the two stay caught only until PrismTTY gives its signals back, when the caller's previous actions resume: until then a flood of them can delay the end, and after that one whose previous action is the default ends PrismTTY. A worker that handles SIGUSR1 while the command PrismTTY started ignores it gets nothing, and a shell that leaves SIGUSR1 at its default action dies from it and ends the session; to reach a server started through a shell, start it with exec, or send the signal to the server's own pid. A signal that PrismTTY inherited as ignored or blocked, as nohup leaves SIGHUP and a script's background job leaves SIGINT and SIGQUIT, is not passed on and does not end PrismTTY: PrismTTY leaves it as its caller set it, as before. This holds for SIGUSR1 and SIGUSR2 as for the signals that end it.

To page the output of a command that needs no keyboard, take the terminal off its stdin:

ptty show-report </dev/null | less -R

PrismTTY then leaves the terminal to the pager. Without </dev/null, PrismTTY and the pager both read the keyboard and both set the terminal's modes, and quitting the pager while the command still runs can leave the terminal in the pager's mode; stty sane puts it back.

On Linux 4.12+ the session normally ends once the wrapped command has exited and its output is drawn, even if a background job holds the terminal (its later output may not be shown); with an older kernel or no spare descriptors it waits for the terminal's end. A line discipline other than N_TTY can lose output.

Important options:

  • -p, --profile <name> forces one or more profiles.
  • --no-auto-detect uses only generic unless profiles are forced.
  • --no-dynamic-profile disables profile switching inside wrapped interactive shells.
  • -c, --config <file> loads a ChromaTerm-compatible YAML file.
  • --strip-ansi removes existing ANSI before PrismTTY styles output.
  • --sanitize strips window-title, clipboard (OSC 52), and other OSC/DCS string escapes from program output, as hardening against escape injection from untrusted remote devices. It assumes a terminal that really reads UTF-8 when the locale variables name UTF-8; PrismTTY infers that from their text and checks nothing. There an isolated invalid raw byte from 80 to 9F in ordinary text is kept as text, and a terminal that reads 8-bit bytes runs it as a C1 control, so --sanitize and --strip-ansi let raw C1 controls, an OSC 52 opened by 9D included, through to it. On a terminal --sanitize does not neutralize every incomplete control at the end of input, and it promises nothing about what another process writes to the same terminal. See SECURITY.md.
  • --show-profile prints profile selections and transitions to stderr. With auto-detection on, a selection that stays generic is not reported, so a session that never leaves generic prints nothing.
  • --local-echo locally echoes printable typed keys for no-echo device sessions.
  • --no-minimal-reset uses full SGR resets in interactive streams for terminal emulators that ignore minimal foreground/background resets. It can also be enabled with PRISMTTY_NO_MINIMAL_RESET=1 or PRISMTTY_NO_39_49_RESETS=1.
  • --trace-io <file> appends hex-encoded PTY input/output plus rendered-output diagnostics.
  • -R, --rgb forces RGB color output.
  • --pcre is accepted for ChromaTerm compatibility; PCRE2 is always used.
  • -b, --benchmark prints per-rule timing and match-count data.
  • -r, --reload asks running PrismTTY sessions to reload config.

Profile commands:

prismtty profiles list
prismtty profiles show cisco
prismtty profiles validate ~/.config/prismtty/profiles.d/my-vendor.yml
prismtty profiles test cisco fixtures/cisco.txt

Configuration

PrismTTY loads built-in profiles first, then user rules. By default it checks:

  • ~/.chromaterm.yml
  • ~/.chromaterm.yaml
  • ~/.config/chromaterm/chromaterm.yml
  • ~/.config/chromaterm/chromaterm.yaml
  • ~/.config/prismtty/config.yml
  • ~/.config/prismtty/config.yaml
  • /etc/chromaterm/chromaterm.yml
  • /etc/chromaterm/chromaterm.yaml
  • ~/.config/prismtty/profiles.d/*.yml
  • ~/.config/prismtty/profiles.d/*.yaml

ChromaTerm-style rules are supported directly:

rules:
  - description: IPv4
    regex: '\b192\.0\.2\.\d+\b'
    color: f#00ffff

Rules match bytes, not characters. A class like [äöü] is the set of bytes those letters are made of, so it also colors other letters that share one of those bytes, such as é, ß and ñ. To match characters, start the rule with (*UTF), as in regex: '(*UTF)[äöü]'. Since 1.3.12 such a rule keeps working past bytes in the output that are not valid UTF-8.

Native profile files add metadata:

profile:
  name: custom-router
  inherits: [generic]
  detection:
    - CustomOS
rules:
  - description: custom interface
    regex: '\bcust\d+/\d+\b'
    color: f#00ffff bold

Profiles under ~/.config/prismtty/profiles.d/ are first-class profiles: they appear in profiles list, can be shown with profiles show, can inherit built-in or other user profiles, and participate in auto-detection through their detection hints.

Built-in profiles are bundled data-driven profile files compiled into the binary. Their private runtime detection metadata is intentionally not part of the public user profile schema yet. If a user profile under profiles.d includes profile.runtime, profiles validate and normal startup loading reject it as a reserved field.

Reload

Long-running ptty /bin/zsh sessions register themselves in a small runtime directory, by default prismtty-<uid> in the system temporary directory. That is $TMPDIR when it is set, as it normally is on macOS, where it points to a per-user directory under /var/folders; on Linux without TMPDIR it is /tmp. Run this after editing ~/.chromaterm.yml or files under ~/.config/prismtty/:

prismtty --reload

The next output chunk in each running PrismTTY session reloads the active config. Only sessions watching the same runtime directory see the reload request. Set PRISMTTY_RUNTIME_DIR to override the runtime directory, which is useful for tests or isolated sessions. An existing directory keeps its mode; one that other users can write to is refused, which only disables live reload for that session. PrismTTY owns pids.d and reload inside that directory: each session sets pids.d to mode 0700 and deletes every regular file in it whose name is not the number of a running process. Do not point the variable at a directory that has a pids.d or a reload of your own.

The name prismtty-<uid> is easy to predict. In a temporary directory that other users can write to, such as /tmp on Linux without TMPDIR or a shared directory named by TMPDIR, another local user who creates that name first disables live reload for your sessions. Those sessions still show and highlight their output, and each prints prismtty: live reload disabled for this session and the reason. To avoid it, set PRISMTTY_RUNTIME_DIR to a private directory, such as one in your home, or set TMPDIR to a private one. The default temporary directory on macOS is a per-user one that only you can write to, also when TMPDIR is unset, so it is not affected.

Built-In Profiles

  • generic
  • juniper
  • cisco
  • arubacx
  • versa
  • arista
  • fortinet
  • palo-alto
  • linux-unix

These profiles are clean-room curated rule sets for prompts, interfaces, addresses, protocol states, syslog severity, operational status, counters, and common vendor terms.

The built-in rule sets and detection hints live as bundled profile data rather than hardcoded vendor branches. Adding or adjusting a built-in profile should start from the bundled profile file and its tests, while user profiles continue to use the public schema shown above. Bundled runtime metadata can also include private negative_signals that block only startup prompt matcher detection; weak detection hints, strong banner signals, and runtime prompt transitions are not blocked by those exclusions.

Interactive dynamic mode keeps built-in vendor selection conservative. After a specific profile such as generic, cisco or generic, juniper is selected, normal command output cannot add another vendor profile. Strong login banners can still switch profiles, and typed nested remote commands can switch after the next strong banner or repeated prompt.

Fortinet is intentionally more permissive from a local-shell baseline only. A single hostname # Fortinet prompt can promote to generic, fortinet, which supports local shell wrappers such as fw that show neither a FortiOS banner nor an explicit ssh command. Other prompt-only vendor switches still require repeated evidence or a typed remote-jump command.

When PrismTTY is launched as an iTerm profile command, it strips iTerm's native shell-integration variables from the child shell to avoid nested integration marks. The stripped values are preserved under PRISMTTY_PARENT_* names for dotfiles that need session or profile context. For example:

_iterm_session_id="${ITERM_SESSION_ID:-${PRISMTTY_PARENT_ITERM_SESSION_ID:-}}"

if [[ $_iterm_session_id =~ w[0-9]+t0p0 ]]; then
    fastfetch
fi

Feedback Wanted

Testing feedback is especially useful for the built-in profile coverage:

  • Cisco IOS, IOS XE, IOS XR, NX-OS, and ASA-style output
  • Juniper Junos
  • Fortinet FortiGate and FortiOS shells
  • Palo Alto PAN-OS
  • Arista EOS
  • Aruba CX
  • Versa
  • Linux and Unix administration output
  • Custom profile files for other vendors, appliances, and terminal workflows

Open an issue with the platform, the command, and a scrubbed snippet of the output.

Contributing

See CONTRIBUTING.md for development setup, the CLI module layout, fixture and privacy policy, and the pull request checklist.

Benchmark

Run the built-in throughput benchmark example:

cargo run --release --example throughput

The example runs router dump, syslog, and mixed-ANSI samples. Runtime benchmark mode is available in normal use:

prismtty --benchmark --profile cisco < show-tech.txt >/dev/null

Replay Fixtures

Replay fixtures under fixtures/replay/ are synthetic. They exist to protect profile detection and streaming coloring behavior across chunk boundaries without checking private device output into the repository.

Run the replay suite with:

cargo test --test replay

When adding a new replay case, use invented hostnames, documentation-range IP addresses, and minimal command output that preserves only the token shape needed for the rule under test. Do not copy real terminal captures into this directory.

License

MIT. See LICENSE.

About

Fast terminal output highlighter focused on network devices and Unix systems

Topics

Resources

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages