A decade ago, I started my first job that required me to use Linux as my laptop's operating system. I was offered a range of variants, including Gentoo, if I was so inclined, but since I had used Ubuntu briefly in the past, I opted for Ubuntu Lucid Lynx 10.04.
machinename ~/path/to/folder $
machinename ~/path/to/folder $
I think after a decade with a near-identical prompt, I have earned the title of curmudgeon, if only as a sign that I have preferences and habits that go against what the cool kids are doing nowadays.
As if to prove my curmudgeonly point, I wanted to change my terminal to match my old one. Getting a setup that looks and feels like Lucid Lynx on Mac isn't simple and took some time.
My biggest recent change was moving from Bash to zsh and migrating my Bash hacks. But that was only one of the major shifts. I learned many new-fangled lessons that I now bestow onto you, dear reader.
Coreutils forgives flag order
Moving from Ubuntu to macOS wasn't too much of a shift until I started thinking I was losing my Unix-foo. I'd try running basic operations like removing folders and be told that I was invoking
It turns out that the GNU-style utilities may look like BSD-style utilities, but one of the biggest usability differences is flag order. The order in which unnamed parameters are listed does not line up. For instance:
Here's the familiar GNU-style command to remove a directory:
$ rm path/to/folder -rf
This contrasts with the BSD-style version of the same command:
$ rm path/to/folder -rf rm: path/to/folder: is a directory rm: -rf: No such file or directory
I got around this by installing Coreutils through Homebrew. This brings GNU utilities to macOS and makes flag order more forgiving by allowing me to not have to remember flag order for commands that are deeply ingrained into my muscle memory.
iTerm2 is powerful
I'm not sure of any operating system where power users are happy with the default terminal. In macOS land, I settled on iTerm2, which allows me more flexibility than the base OS's terminal application. One of my favorite iTerm power features is being able to use Command+D and Command+Shift+D to split panes vertically and horizontally. There are many more tricks to be learned, but easy split panes alone can make iTerm2 worth the switch from the default option.
One reason even a curmudgeon of a user customizes a terminal prompt is to gain some situational awareness. I enjoy it when a terminal gives me context and answers all the questions that come to mind. Not just what folder I'm in, but: What machine am I on? Is this a Git repository? If so, what branch am I in? Am I in a Python virtual environment?
Answers to these questions go into a category of terminal extensions that can be called "context-aware plugins."
For the current Git branch, I used this parse_git_branch() method (there is a similar plugin for Oh My Zsh, if you're using that). For Python, virtualenv prefixes to the prompt automatically. Oh My Zsh has so many plugins, you're sure to find something to improve your life.
As for my local machine? I just place it directly in the PS1 format because I'm basic like that, and macOS doesn't really let you name your machines.
Multi-line prompts are fine
The observant reader may notice the one change in my prompt over a decade is that it's now two lines. This is a recent change that I'm slowly learning to love because all those plugins I mentioned earlier make my prompt looonnngggg. You can navigate only so deep in a filesystem before you start having line-wrapped command inputs trying to do anything basic. And with that comes occasional redraw issues and readability concerns.
The suggestions I received about resolving this revolved mostly around, "Oh, you're using zsh? Use Powerlevel10k!" Which is fine for those who aren't stuck in their ways, like me. But I was able to learn from these themes and take a small bit of suggestion from them.
What I've done is to add a
$'\n' before the final
$ in my prompt, which allows my context-aware information—current machine, current folder, current GitHub branch, current virtualenv, and the like—to all live on one line, and then my commands can be entered without issues.
The only problem I've found is learning where to look. I'm used to having my eyes start at the center of the line because that's where the prompt used to start. I'm slowly learning to look left to the prompt, but it's a slow process. I have a decade of eye training to undo.
Use what works for you
If you prefer a certain style or tool, then you are absolutely valid in that preference. You can try other things, but never think you have to use the latest and greatest just to be like the cool kids. Your style and preferences can change over time, but never be forced into changes that aren't comfortable for you.
Join us next time, when Aunty Katie complains about IDEs.