[openbeos] Useful function

  • From: "Michael Phipps" <mphipps1@xxxxxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Sat, 30 Nov 2002 21:42:41 -0500

This may be pretty trivial, but I thought it might help someone out there...

Getting around in a source tree can be something of a pain. I find myself 
frequently wanting to be in a totally different directory. 
Colleagues of mine, on the Unix boxes where I work, run a cron job to do an "ls 
-lR" nightly and store that in a text file. They created a command called "j", 
which jumps to the directory that you specify. Personally, I find that to be 
sort of hackish... And BeOS has a better way - queries. I put this into my 
.profile...

function j() {
for a in `query "name=$1"`
do
        if [ -d $a ]
                then
                        cd $a
                        echo $a
                        break
                fi
done
}   

Works for me. Short, simple, to the point. It will go to the *FIRST* occurence 
of a directory. A clever person could certainly modify this to list a menu of 
choices, which is what the original 'j' does. Since I don't need it yet, I 
haven't done it. ;-)



Other related posts: