[openbeos] Re: Useful function

> 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. ;-)

This is really cool.  Now I don't feel so bad about making my directory 
names so long.

Cheers
David


--
A long memory is the most subversive idea in America.


Other related posts: