I gave a bit of my time today, to an attempt at packaging Starship for Guix. After having it on Nix for a while now, since it was a simple to setup prompt, with very sane defaults.
Simple to setup as just adding starship.enable = true; to the home configuration. Little did I know, this little maneuver was gonna cost me over 80k lines of Rust. The binary is almost the size of the entirety of Emacs-nox, with somewhere close to 700 transitive dependencies.
I knew it was a nontrivial Rust program, but never really realized, just how very nontrivial. Well, until I went to try and package it, since packaging brings out the truth from a piece of software.
I gave up after a few version collisions and such, which the automatic importer didn’t manage to solve. Not because I’d give up so easily, but because I reconsidered if it was really worth it. Am I really using all of this? Do I need to be notified that the directory I am in contains a C source file and immediately see the version of the compiler? No, I said to myself. So, I inspected how the prompt generation works, read through the manual, and rolled my own fairly quickly with a bit of help from a very convenient website.
Obviously I don’t want to put a big block of Shell gibberish into my config, so I bound a few variables and it’s immediately quite a bit nicer and understandable.
(let* ((default-color "\\[\\e[0m\\]") (color (lambda (color text) (string-append (case color ((red) "\\[\\e[91m\\]") ((blue) "\\[\\e[96m\\]") ((pink) "\\[\\e[95m\\]") ((salmon) "\\[\\e[38;5;218m\\]") ((green) "\\[\\e[92m\\]")) text default-color))) (hostname "\\H") (pwd "\\w") (exit-status "$?") (jobs "\\j") (prompt "\\$") (git-branch "$(git branch 2>/dev/null | grep '\"'\"'*'\"'\"' | colrm 1 2)")) (mixed-text-file "bashrc-ps1" "PS1='\\n\\n" (color 'red hostname) "@" (color 'blue pwd) "\\n" "[" (color 'pink exit-status) "] {" (color 'salmon jobs) "} " (color 'green git-branch) "\\n" prompt " " "'"))
Going from this:
michal_atlas in 🌐 hydra in dotfiles on master [!⇡] ❯
To this:
hydra@~/cl/dotfiles [127] {3} master $
Obviously both with a bit of colour.
[91mhydra[0m@[96m~/cl/dotfiles[0m [[95m127[0m] {[38;5;218m3[0m} [92mmaster[0m $
The 127 and the 3 signify the exit code and number of background jobs respectively.
The message today is not about bloat, please don’t take it that way, it’s about reconsidering what you need and want.
I am convinced there are people with so many confusing environments, platforms and projects, that Starship is entirely worthwhile.
But I am not that someone, and these 189 characters to me personally sufficiently replace the prior 2’281’795.
PS1='\n\n\[\e[91m\]\H\[\e[0m\]@\[\e[96m\]\w\[\e[0m\]\n[\[\e[95m\]$?\[\e[0m\]] {\[\e[38;5;218m\]\j\[\e[0m\]} \[\e[92m\]$(git branch 2>/dev/null | grep '"'"'*'"'"' | colrm 1 2)\[\e[0m\]\n\$ '
Especially for something that runs every time a prompt is to be shown to me.
Know what you run, even small adjustments can have massive but at first hidden implications.