Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I was just at a lecture, where I noticed the lecturer using a command (probably aliased) to jump to a specific folder.

Example:

~/code$ j sciproj
~/projects/sciproj2011/$

This looked quite slick, so I started wondering:

Is this a standard utility, and if so, what is the name?

I have two theories as to how it works:

  1. It can both create, delete and jump to aliases directly from the command-line in the style of the example, without having to set up aliases in a configuration file or script or whatnot manually.

  2. It searches the home directory for a folder matching the name and jumps to it.

The second option seems a bit slow, however, so the first would be preferred.

share|improve this question
2  
github.com/joelthelion/autojump –  sagarchalise Feb 11 '11 at 11:54

2 Answers 2

up vote 6 down vote accepted

As an addition to sagarchalise's comment:

It's in natty: http://packages.ubuntu.com/natty/autojump

Should work in older releases as well.

share|improve this answer
    
Excellent; looks like the thing he was using. –  Sebastian Paaske Tørholm Feb 11 '11 at 12:34
    
It's not in maverick, is it? –  Stefano Palazzo Feb 11 '11 at 13:02

How about this?

function j() { for dir in ~/projects/$@*; do if [ -d $dir ]; then cd "$dir"; fi; done ;}

It finds the nearest possible match. So say I have a dir listing like this:

~/projects/
~/projects/apples/
~/projects/apples-and-pears/
~/projects/cabbage/

j a will match both apples* dirs but as apples-and-pears is the later, it will cd into that last, and that's where you'll end up (the flaw in this function). j c will put you in ~/projects/cabbage/.

Bung that into a terminal to test it and when you're happy, just plonk it on the end of ~/.bashrc.

Edit: I've also been playing around making a find variant but it's not as good (slower and less accurate). Feel free to hack around with it though.

function j() { cd $(find ~/projects -maxdepth 1 -type d -name "$@*"); }
share|improve this answer
    
It's gonna be reeeaaaally slooooww... –  ulidtko Feb 11 '11 at 16:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.