Recently I stumbled over an article, about how to customize your shell prompt. What really surprised me, is that it lacked one of the most basic tips I learned nearly 20 years back: Always display a timestamp in the prompt, to be able to check how long a process is running or when it ended. (Don’t need it daily, but every so often it saves my butt. ;-)) The other trick is to always have a colorful prompt, to easily discern where output from programs start/stop. In total my PS1 looks like this (with GIT status at the end): [\e[32m]\u[\e[m]@[\e[35m]\h[\e[m] [\e[36m]\A[\e[m] [\e[37m][[\e[m][\e[31m]\w[\e[m][\e[37m]][\e[m]$(__git_ps1 “(%s)”)$
My question is, what customization, tips and tricks do you have for the shell prompt?
I make it green for an ssh session, and red when I’m root. That’s it, nothing fancy.
Damn it! That is such an obvious great idea, I feel like an idiot! Thank you very much! :-)
Any advice/guide how to change the color for ssh sessions?
Definitely! Much more user-friendly and expandable than configuring PS1 manually.
If you like customizing your shell, there are really cool things one can do with zsh.
I have mine set up with suggestions to complete the name of the program, or even command line options for it.
I got different colors for Kubernetes clusters. Like green for testing cluster, yellow for development and red for production. Always taking a Quick Look before I do something
This sounds awesome. Do you change the color based on the selected cluster? Do you set an environment variable?
Most prompt customizers have an option for showing how long last command ran and whether it succeeded/failed or simply prompt timestamp, it’s often default. I use Tide, there’s also Starship and a number of others. You can also roll your own ofcourse.