Friday, September 22, 2006

Geeky Friday: Shorter directory path in command prompt

Gina Trapani, editor over at lifehacker.com, has been diving deep into cygwin and command line goodness for a while. Earlier this week, she posted an article about customizing the command prompt. I added a comment about my shorter directory path, but I'll replicate here, because I have better control over the formatting of the code (and, I guess, for the people who read me, but not lifehacker):

I sometimes find having the full directory path in the prompt to be overwhelming, so I've created this small bash function which shows just the last two parts of the path:

short_dir ()
{
    if [ "$PWD" = "$HOME" ]; then
        echo '~'
    else
        the_dir=`dirname "$PWD"`;
        the_base=`basename "$PWD"`;
        the_dir_base=`basename "$the_dir"`;
        if [ "$the_dir_base" = '/' ]; then
            the_dir_base="";
        fi
        echo "$the_dir_base/$the_base"
    fi

}
Add a call to this to your prompt, don't forget to escape the backquotes:

export PS1="\`short_dir\`\$ "

So, if your current directory is /usr/local/man/man1, your prompt would look like:

man/man1$

You can, of course, sprinkle in other bash prompt special characters, such as "\h" for the hostname:

export PS1="(\h) \`short_dir\`\$ "

produces: (myhost) man/man1$

Monday, September 18, 2006

Anime for beginners

I think it's time to try anime. Based on various reviews and the fact that it won an Oscar a few years ago, Spirited Away has been in my list of movies to rent for a long time, but I've never gotten around to renting it. Now ranting tech blogger, Steve Yegge has written a long post about why he likes anime and gives some recommendations.
Tags:

Thursday, September 14, 2006

Diary of Ironman Preparation (no, not mine)

"A few days ago I was thinking about doing something good with my life. Instead I decided I would sign up for Wisconsin Ironman."

   -- Thus begins my cousin's new blog chronicling his year of preparation for the race on September 9, 2007.