Command Line Kung Fu at Ruby on Rails October Meeting

Originally posted October 23, 2009
Brian Dailey

Brian Dailey is a LAMP-stack developer with a wide range of experience in the development world. Get in touch!

For more articles on the development trade, see the Blog.

A lot of the material I went over was from the NYPHP presentation that I gave earlier this year, but I did spend a little more time on functionality specific to the bash prompt.

A couple of the things that seemed to generate the most enthusiasm:

Some of the attendees had their own useful suggestions. Daniel Nelson pointed out that Ctrl+N and Ctrl+P is faster than using arrow keys to navigate through your command history. He also pointed out that you could pass command output into arguments using parenthesis. For example:

$ diff <(ls -l) <(ls ../ -l)

That's pretty slick if you ask me!

A lot of PHP guys showed up, so there was some interest in a small function I wrote to parse out information from the information pages. Here it is in it's full glory:

phpargs() {
    curl -s$1 | \
    sed -n '/<div class="methodsynopsis dc-description">/,/<\/div>/p' | \
    sed 's/<[^>]*>//g' | tr -d "\n"

It's pretty basic, but if you add this to your bash profile you can run it by passing a function name.

$ phpargs strpos
     int strpos    ( string $haystack   , mixed $needle   [, int $offset = 0  ] )

Again, if you're reading this and you're not checking out your local user groups, then I encourage you to do so! Even smaller cities often have user groups and they are a valuable place to both learn things and share what you know.

Related Links