Skip to content

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

Technology

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.

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 <shell> 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.

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.

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.

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.

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.

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.

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.


Source: Hacker News — This article was automatically imported from the source. Read full article at original source →

HA
Originally published by Hacker News yamafaktory.github.io
Visit original article

Gram Slattery

Leave a Comment