You are not logged in.

#1 2009-02-10 18:12:53

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Navigate through your filesystem faster with autojump!

Hi all,

One of the most used shell commands is "cd". A quick survey among my friends revealed that between 10 and 20% of all commands they type are actually cd commands! Unfortunately, jumping from one part of your system to another with cd requires to enter almost the full path, which isn't very practical and requires a lot of keystrokes.

To address this problem, I've created a little tool called autojump. Autojump is a faster way to navigate your filesystem. It works by maintaining a database of the directories you use the most from the command line. The jstat command shows you the current contents of the database. You need to work a little bit before the database becomes useable. Once your database is reasonably complete, you can "jump" to a directory by typing:

j dirspec

where dirspec is a few characters of the directory you want to jump to. It will jump to the most used directory whose name matches the pattern given in dirspec.

EXAMPLES

j mp3

could jump to /home/gwb/my mp3 collection, if that is the directory in which you keep your mp3s.

jstat

will print out something in the lines of:

...
54.5:    /home/shared/musique
60.0:    /home/joel/workspace/coolstuff/glandu
83.0:    /home/joel/workspace/abs_user/autojump
96.9:    /home/joel/workspace/autojump
141.8:    /home/joel/workspace/vv
161.7:    /home/joel
Total key weight: 1077

The "key weight" reflects the amount of time you spend in a directory.

To install,

yaourt -S autojump

You need to source /etc/profile in your .bashrc for this to work. Your terminal might also need restarting after the installation.

Last edited by lardon (2009-02-12 08:36:03)


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#2 2009-02-11 16:21:52

kousi
Member
Registered: 2009-01-22
Posts: 5

Re: Navigate through your filesystem faster with autojump!

Ha!  That seems quite useful.  You've now made me want something similar with all user-specified jumps

j t
jump to my torrents

j d
jump to my downloads

j w
jump to my web files

But kudos to your more advanced one.  Keep up the good work.

Offline

#3 2009-02-11 16:31:57

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: Navigate through your filesystem faster with autojump!

Thanks for the feedback!

Note: you actually can do what you want with the current autojump, because "downloads" and "web" don't contain a t (only "torrents" does), and so on. If if that weren't the case, usually two or three letters are enough. I've been using it for a few months now, and now I couldn't live without it smile


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#4 2009-02-11 17:06:34

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Navigate through your filesystem faster with autojump!

kousi wrote:

Ha!  That seems quite useful.  You've now made me want something similar with all user-specified jumps

I'd just use alias or environment variables for this.

This is a very interesting project. How does autojump determine which directories are most common? Do you have to use the tool when changing directories so it can determine which directories are most used? Or does it parse the bash history for cd/pushd commands?

Dusty

Offline

#5 2009-02-11 17:13:05

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: Navigate through your filesystem faster with autojump!

Dusty wrote:

This is a very interesting project. How does autojump determine which directories are most common? Do you have to use the tool when changing directories so it can determine which directories are most used? Or does it parse the bash history for cd/pushd commands?
Dusty

It does it by pure magic smile. Seriously, it uses the bash PROMPT_COMMAND environment variable, which is a command that executes each time the prompt is displayed, to increment the counter of the current directory. That way it's fully automated, doesn't intrude in your workflow, and continously adapts to the way you work. It's much more flexible than static, user-specified jumps.

The database is stored in ~/.autojump_py, and is a python pickle file.

Last edited by lardon (2009-02-11 17:13:53)


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#6 2009-02-11 17:29:39

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Navigate through your filesystem faster with autojump!

lardon wrote:

It does it by pure magic smile. Seriously, it uses the bash PROMPT_COMMAND environment variable, which is a command that executes each time the prompt is displayed, to increment the counter of the current directory. That way it's fully automated, doesn't intrude in your workflow, and continously adapts to the way you work. It's much more flexible than static, user-specified jumps.

Smart! I'll have to try it. Just as soon as I get back to my Arch.

The database is stored in ~/.autojump_py, and is a python pickle file.

I'd suggest sqlite, pickles have a tendency to bite you when you want to extend something.

If cactus jumps in here with a picture of pickles biting people, my day will be complete. Send in the tacos.

Dusty

Offline

#7 2009-02-11 17:33:08

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: Navigate through your filesystem faster with autojump!

Dusty wrote:

The database is stored in ~/.autojump_py, and is a python pickle file.
I'd suggest sqlite, pickles have a tendency to bite you when you want to extend something.
Dusty

The pickle only stores a dictionnary smile. Anyways, even though this works great already, it's mainly a proof of concept. If the idea catches on, I think the best would be to integrate it directly into bash.

Last edited by lardon (2009-02-11 17:33:20)


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#8 2009-02-11 17:57:49

evr
Arch Linux f@h Team Member
Registered: 2009-01-23
Posts: 554

Re: Navigate through your filesystem faster with autojump!

cool project, I just tried it out and it works pretty nicely.

Offline

#9 2009-02-11 18:02:28

koch
Member
From: Germany
Registered: 2008-01-26
Posts: 369

Re: Navigate through your filesystem faster with autojump!

yeah, something to play with smile
sounds pretty nice.

Offline

#10 2009-02-12 08:37:23

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: Navigate through your filesystem faster with autojump!

Note: if you want to make changes to autojump, please fork the github project: http://wiki.github.com/joelthelion/autojump

That way I can merge in your changes if they are interesting, and everybody can benefit.


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#11 2009-02-13 15:19:21

WhiteMagic
Member
Registered: 2007-03-01
Posts: 85

Re: Navigate through your filesystem faster with autojump!

Sounds like a nice tool, will give it a try. I'm using apparix at the moment since it is a little more comfortable than simple alias definitions.

Offline

#12 2009-02-13 15:47:36

freakcode
Member
From: São Paulo - Brazil
Registered: 2007-11-03
Posts: 410
Website

Re: Navigate through your filesystem faster with autojump!

As a side note: instead of cd'ing, try

pushd

and

popd

.

Offline

#13 2009-06-30 22:22:15

dum8d0g
Member
Registered: 2007-10-23
Posts: 7

Re: Navigate through your filesystem faster with autojump!

Hi! I found a bug, what should I do?

Offline

Board footer

Powered by FluxBB