The same zsh everywhere
I’d been getting tired of zsh being a little different on every machine in the house. I already had a shared config in workbench, so in theory this was solved, but in practice what I got depended on which host I’d logged into and which account I was using. I asked Claude for some sensible defaults and aliases, color wherever possible, history that updates across shells and is easy to search (with fzf, probably), and maybe thefuck, plus whatever else it would recommend.
It started by looking at what each host was actually running. None of the servers had starship, so every one of them fell back to zsh’s bare default prompt. Root had zsh on some hosts and bash on others, the copy of the config in /etc/skel (which new accounts start from) was out of date on every server that had one, and video and deskliam didn’t have zsh at all. The config itself was mostly fine. It just hadn’t ended up in the same places.
Most of the additions were straightforward: eza for listings, bat for previews, fd and ripgrep, zoxide for jumping between directories, a key to put sudo in front of a line, and short aliases for git and systemd. The one rule is that a standard command keeps doing what it normally does, so there’s no rm -i and cat isn’t secretly bat, if only because pasted scripts (and agents) expect the real thing. Where there’s no theme, the prompt uses the terminal’s own 16 colors, so a server picks up the theme of whatever I’m connecting from.
thefuck was more interesting. Its last upstream release is from 2022, so the first question was whether it still ran at all, and it does: Arch builds it for the current Python, and it turned git brnch into git branch without any trouble. But to work out what went wrong it runs the failed command again, and it does that before asking you anything. Claude tested this with a small script that wrote a line to a log each time it ran, then failed. The confirmation only covers the fix. That’s fine for a typo in a git command and a good deal less fine for something that got halfway through as root, so the package is only on the workstations, and the function never loads for root.
History took the most attempts. zsh’s share_history saves each command as it’s run, but a shell that’s sitting idle doesn’t see the others’ new commands right away. Claude tried to have Ctrl+R read them first, and also to have the Up arrow stick to the current shell’s own commands, and tested it by driving two real shells side by side. The first version made the other shell’s commands show up under Up, which was exactly what the Up change was supposed to prevent. The second used a temporary history list, and after that Up skipped the most recent command. The fix for that brought up the wrong command after picking something in Ctrl+R. Going back to the simple version without the Up change left duplicates in the shell’s list, and in one run Up did nothing at all after a cancelled search. At that point it went back to zsh’s and fzf’s normal behavior, which passed the same tests. The catch is that Ctrl+R only finds another shell’s commands after you’ve run a command in the current one (pressing Enter on an empty line isn’t enough, which we know because the first explanation said it was, and the test disagreed). atuin is built for live history, but it’s another database for every user, and I decided fzf was enough.
I did ask for one change after the first round. I rely on visual indicators to remind me where I am, so I wanted user@host to be purple locally and green on a remote machine, while root’s name could stay red in both. SSH sets a variable called SSH_CONNECTION, which sounds like all you’d need, but there were two problems. The agent’s terminal windows connect over SSH to the same machine, so they’d have been green when they should be purple; if both ends of the connection have the same address, it now counts as local. The other problem was that sudo drops the variable, so a root shell on a server would have had a purple, local-looking hostname, which is about the worst place to get that wrong. sudo has a setting to keep a particular variable, so each host now has a one-line rule for that one. (su - still drops it, so I’ll be sticking with sudo -i.)
The rollout went to virttom first, along with a throwaway account that had links planted where the config should go. The installer used to write as root, which isn’t a great idea in someone else’s home directory, so it now writes as the account’s own user, and it moved the links aside without touching what they pointed to. It also used to delete local.zsh, the file meant for your own settings, whenever it refreshed a copied config. That’s fixed too. After that came the rest of the servers, which turned up one more: when the installer replaced an old file in /etc/skel, it put the backup in /etc/skel as well, so every new account would have started out with a copy of it. Those backups have been moved, and new ones go to root’s home instead. The new rollout script also failed to start the first time because git had been told to ignore the executable bit. And when it came time to write the summary, it turned out there were 14 servers and VMs, not the 15 Claude had been reporting all along. The script had been given the right list, at least.
To check the result, Claude opened SSH sessions on all 16 remote hosts and looked at the actual prompts, including root’s after sudo -i, and compared every config with the repo. The only prompt marked wrong was on laptom, and that was the checker’s fault: it didn’t recognize the theme’s exact shade of green. The only configs that didn’t match were mine on desktom and laptom, which is on purpose, since those come from my own clones and I review changes before I pull them. The command behind fleet-sudo works through root’s new shell on every host, although that was tested without the smart card. Liam stayed logged in on deskliam throughout, and the curfew timers are still there (sorry, Liam). A fresh desktop login there hasn’t been tested, though its login script does support zsh. Bri’s remote desktop wasn’t restarted, so its terminals may stay on bash until it is. The Steam Machine was left out, since it runs SteamOS.
So zsh is now the login shell for me, root and new accounts on all 17 machines, for Bri on the two hosts where Bri has an account, and for Liam on deskliam. The agent has the same config, but its login shell was left alone, because zsh can break remote commands that were written for bash. A single script, common/deploy-shell, does the rollout and can be run again safely, and the instructions for setting up a new host now include it, which I think matters more than any of the aliases. The config was never really the problem; it was getting the same copy everywhere. It’s working beautifully so far.