Saturday, August 18, 2007

My bash Profile

Here it is (with some client-relevant stuff deleted).

Far and away the handiest customizations are the short question-mark aliases for history | grep and ps ax | grep.

Update: here's a Pastie where I use both the ? aliases. I try to start Mongrel, but it won't start. I can't remember if I left it running, so I do a ps? mongrel and find out no, it's not running. Then I do a ? mongrel to see what I've done with Mongrel recently.

Obviously this is easy stuff, but compacting it down makes it really quick and fun to use. Also, since it becomes a habit to just hit ? when you want the system to tell you something - which is very intuitive - you have that option even in situations when you're tired from overwork and wouldn't naturally remember something that clever. It kind of turns the clever part invisible.

5 comments:

Ben Smith said...

Did you really have to say "(with some client-relevant stuff deleted)"? I mean, do your readers really care?

Giles Bowkett said...

Well, um - One of my readers obviously has an opinion about it, that reader being you. I don't know, it just seemed precise.

Eric-Olivier Lamey said...

You might want to try bash completion. It does ssh hosts completion too, and a lot more! Just "sudo port install bash-completion" if you are using MacPorts on Mac OS X.

Justin George said...

"ps aux | grep"

You should find out about the magic that is pgrep.

http://www.computerhope.com/unix/upgrep.htm

Also, as I learned in my forays into the emacs, ctrl-r will start a reverse-incremental search on your bash history (or at least, as much as is in your up-arrow memory).

Matt said...

I'm a fan of pgrep because it can be found on any system, but it's just not as good as 'ps | grep'.

For example, say I'm running a ferret drb server that I started using script/runner. If I pgrep for 'ferret', I get nothing. I'll have to pgrep for 'ruby' to get anything, but I'll get all my ruby processes. In contrast, 'ps aux | grep ferret' ('psg ferret' in my bash profile) returns the process I'm looking for.

You'd think pgrep would be cooler, but it ain't.