Okay, 12 years into working on Pinboard I think I got my color bash prompt to work without screwing up line wrapping
-
Show this thread
-
Now I want to see other people's bash prompts. I thought I was the height of cool using different colors per server, but it turns out I've had a garbage prompt for a decade. Show me your PS1's please!
22 replies 2 retweets 37 likesShow this thread -
Replying to @Pinboard
My time to shine! I obsessed over my bash prompt for a long, long time, and this was the result. Guided tour to follow whether you like it or not.pic.twitter.com/P2VodxlbAF
3 replies 3 retweets 28 likes -
First, there's the title bar string, including a short but informative date. It is prepended to the prompt if bash detects that it is running in an xterm-like terminal or in screen (which uses different escape codes).
1 reply 0 retweets 3 likes -
Then a newline, because I *hate* when the previous command output doesn't have one and so my prompt starts in the middle of the line. Then the exit status of the previous command, which is bolded if it is not zero (i.e. if it was unsuccessful). Then the usual user@host:dir stuff
1 reply 0 retweets 0 likes -
Then the command history number, which comes in handy for repeating commands with bash's ! history substitution. Then the $ or # ending. A few of the codes in between handle color. Most of them provide for various customizations using shell variables, without rewriting $PS1.
1 reply 0 retweets 0 likes -
The key thing is that for almost all of them (except the git-related bits) bash figures out what I want without spawning any more processes. I used to use
$PROMPT_COMMAND because it allowed all of these things to be done much more succinctly, until one day...1 reply 0 retweets 0 likes -
I had to use lastcomm to work out what the frack this vendor service was doing on my system, and found that the process account logs consisted almost entirely of the processes I was running to generate my own prompt. I swore that my command prompt would never fork() again.
1 reply 0 retweets 2 likes -
(Had to break that vow for git status integration, but that was definitely worth it.)
1 reply 0 retweets 0 likes -
What customizations? I'm glad you asked! Or let's be real - nobody asked. But you can't stop me, so there. The one I'm most proud of is highlighting. I use this to distinguish production systems from others, so that don't accidentally run a command in prod instead of dev.pic.twitter.com/s8mmeHqinU
2 replies 0 retweets 3 likes
I solve this by only having production servers
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.