News for hackers. Stuff that matters.
Re:Pure Bash Bible by cutler on Wednesday August 09, 2023 @07:25PM (#37069766)
PS1 in Go? Overkill, doesn't come close.
Re:Pure Bash Bible by rollcat on Thursday August 10, 2023 @12:00PM (#37077877)
Depends 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-li...