3 ms·
PS1 in Go? Overkill, doesn't come close.
by cutler 3y ago
PS1 in Go? Overkill, doesn't come close.
- rollcat 3y agoDepends on what you're trying to do. If you're shelling out to git(1) or docker(1), rather than e.g. recursively checking for the presence of .git in parent directories, or inspecting ~/.docker/config.json, then the fork+exec overhead is already quite significant. Next if you're parsing ~/.docker/config.json in shell, you're most likely either asking for trouble or (again) shelling out to jq. Writing it all in an interpreted language means you're paying the cost of interpreter startup, which on underpowered systems can take hundreds of milliseconds even when idle. OTOH loading a static binary to memory happens only once, and with Go you can trivially cross-compile. I also have a fallback shell one-liner, without any of the fanciness like displaying the current git branch: https://github.com/rollcat/etc/tree/master/cmd/prompter#i-like-the-prompt-but-your-code-sucks https://github.com/rollcat/etc/tree/master/cmd/prompter#i-li...