This is a small utility to display a prompt much like the fish default.
- makes exactly 3 syscalls in
main()
: a singlegetcwd
,geteuid
andwrite
each. - Hardcoded for
TERM=xterm-256color
- When in
$PREFIX
, abbreviates it to$P/...
.
- compile & install:
musl-gcc -static fish_prompt.c -o fish_prompt
cp fish_prompt $SOMEWHERE/bin/
- use as your prompt:
# ~/.config/fish/functions/fish_prompt.fish
function fish_prompt --description "Write out the prompt"
# fish doesn't export these
command fish_prompt $status $CMD_DURATION
end
We use code verbatim from libunistring-1.0, which is licensed GPL3 and LGPL3. This is done to enable fully static linking with musl: some platforms (Android) have a huge overhead otherwise.
How this interacts with the EUPL is left as an excercise for the reader.