|« Today's roads, tomorrow||It's official »|
Thu, Sep 15, 2011
When you have multiple checkouts of a codebase, and work in multiple terminals, it's easy to suffer a momentary confusion about where you're executing a command, and break something important when you thought you were working in a safe place.
This is something I've been thinking about fixing for a while, but then two of my co-workers asked me to come up with something for this issue as well, so I finally got off my posterior and did something that (IMHO) is actually quite cool :)
So what I now have is a bash prompt that looks in your current directory, and also all parent directories, for a file named .ps1_alert and if it finds one (or more) it puts the alert in that file into your prompt, in bright red.
All you have to do is add \[\033[01;31m\]$(__ps1_alerts "(%s)")\[\033[00m\] to your bash prompt. This is easy:
This works instantly, but only for the current shell: Add the code to your PS1 in your .bashrc file to make it stick.
Then just save this perl script as /usr/bin/__ps1_alerts and the prompt will start to work:
And now, put a .ps1_alert file in anywhere you need it, and you're away.
I think this is cool :o)
|<< <||> >>|