Show HN: Whetuu – a zero-config cross-shell prompt written in Zig

yamafaktory2 pts0 comments

whetū — an opinionated, zero-config cross-shell prompt written in Zig

~/install

One command

1. Run it. The installer detects your platform, checks the download against the published SHA256SUMS, puts the binary in ~/.whetuu/bin, and adds two lines to the config of the shell you actually use. Running it twice changes nothing.

$ curl --proto '=https' --tlsv1.2 -fsSL https://yamafaktory.github.io/whetuu/install.sh | sh<br>Copy

macOS and Linux · read the script · tarballs and checksums

2. Open a new shell. That is the whole install.

Would rather edit your own dotfiles? Run it with WHETUU_NO_MODIFY=1 and it prints the two lines instead of writing them. whetuu init prints them too, along with the file they belong in. Uninstalling is rm -rf ~/.whetuu plus those lines.

You need a Nerd Font. The prompt uses Nerd Font glyphs for the git branch, the language logos and the prompt character. Without one, those show as empty boxes.

~/demo

See it in a real shell

The prompt tracks the branch, the git status and the toolchain version. Pressing the up arrow opens the history picker, which filters as you type and runs what you pick.

demo

~/modules

What it shows

Left to right, each segment appears only when it is relevant.

user_hostuser@host in bold green, but only over SSH or when you are root, and then in bold red as a warning.

directoryThe current directory with $HOME collapsed to ~ . Keeps the anchor plus as many trailing directories as fit the width.

git branchBranch glyph and current branch, or (detached) , in magenta.

git stateAny operation underway, in yellow: (rebasing 2/7) , (merging) , (cherry-picking) . Read straight from .git , with no extra subprocess.

git statusConflicts, stashes, staged, modified, untracked, ahead and behind, in one bracketed group.

languageLogo and toolchain version in the brand colour, for 39 languages and tools . Detected from a project manifest, a source file extension, or an infra marker.

cmd_durationTimer glyph and elapsed time, when the last command ran for two seconds or more.

characterA star, purple by default or in the language brand colour. Turns red after a failed command.

~/picker

A history picker on the up arrow

Commands are recorded once they finish, and only when they exited cleanly, so typos never clutter the list. Each is stored with the directory it ran in. The picker opens scoped to the current directory and falls back to all history when there is none.

whetuu history

2d git commit -m "Cache toolchain versions"<br>1d cd ~/cf/platform && git push -u origin HEAD<br>17h docker exec -i PGPASSWORD=x db psql<br>14m nvim ~/.config/fish/config.fish<br>11m npm ci<br>󰦥

Rows are syntax highlighted. The command name, flags, paths, variables, quoted strings and operators each take a colour from your terminal theme, so the picker matches the palette you already run. A command too wide for the window loses its middle to a … rather than its end, which keeps a run of commands sharing one long prefix apart.

type Filter. Every word must match, ignoring case.

↑ / ↓ Move the selection. Up goes further back in time.

Ctrl+G Switch between this directory's history and all of it.

Tab Copy the selection into the search field to edit or extend.

Enter Run it. When nothing matches any more, runs the text as typed.

Esc Cancel, leaving whatever you had typed on the command line.

~/performance

Renders in about 2 ms

A prompt runs before every command, which makes it the one thing in your shell that has to be quick. Every module that reads the disk runs at the same time via std.Io, so a render takes about as long as its slowest probe rather than the sum of them all.

DirectoryRenderFor comparison

No repo, no toolchain2.3 ms—<br>Zig repo, 35 files3.0 mszig version alone: 3.1 ms<br>Monorepo, 8259 files20.2 msgit status alone: 19.3 ms

Measured with hyperfine --warmup 40 --runs 400 on a 13th gen i9-13900H, ReleaseFast, pinned to the performance cores on an otherwise idle machine. In the monorepo the whole prompt takes about as long as git status on its own.

A slow repository cannot hang your shell. Both subprocesses are bounded. Git gets 250 ms and the toolchain probe gets 200 ms, and they run at the same time, so the worst case is the larger of the two. Given a git that hangs for 30 seconds, the prompt still returns in 257 ms. It simply drops the git segment.

~/security

Nothing leaves your machine

A prompt sees every command you run, and the picker keeps them. That is a lot to hand a small tool, so here is exactly what whetuu does and does not do.

No networkThere is no socket, no HTTP client and no sync anywhere in the binary. No telemetry and no update check. There is no account and no server to opt out of.

Two filesRunning, whetuu writes exactly two. The history store, created with mode 600 and reset to it on every write, so one left readable by an older version corrects itself. And a cache of toolchain version strings at ~/.cache/whetuu/versions , which holds nothing else and can be...

whetuu prompt command shell history picker

Related Articles