2

"2" helps you to jump between folders in your unix shell. It's just my attempt to guess where you want to navigate and help you with less typing.

how it works

Here's a screencast to see what I'm talking about.

A tiny script integrated with your shell populates the directories database while you are jumping around.

Later, when you want to cd somewhere you just type a few letters (hints) - "2" will find the most suitable directory path using the fuzzy search and brings you there.

If you want to know more - "2" has two parts (what a coincidence!). The first is a piece of a shell script (now zsh and bash are supported). This scripts monitors your moves around the filesystem tree and provides and alias for "2" and a hotkey for interactive mode (see below what it means).

The second piece is a tool written in Go. It reads and writes the directories database and performs the actual search. The reasons I added a separate tool is to optimize search speed. But to tell you the truth - I didn't want to torture myself with writing a search algorithm in Bash :)

install

$ hg clone ssh://hg@bitbucket.org/zserge/2
$ cd 2
$ go build
$ sudo cp 2 /usr/local/bin
$ sudo mkdir /usr/local/share/2
$ sudo cp bashrc /usr/local/share/2
$ sudo cp zshrc /usr/local/share/2

Then add the following lines to your .bashrc or .zshrc depending on what shell you use:

export _2IGNORE="/tmp/*"
source /usr/local/share/2/bashrc # or zshrc

The second line integrates "2" into your shell and the first line is used to configure it (to make it ignore some paths)

tricks

If you want "2" to understand you better first set up the ignored paths. I personally don't like it to remember my /tmp and all its subfolders because they are located in the tmpfs and there is no sense to store these paths in the persistent database. Also, I don't want it to remember my home directory (but still remember the subdirectories).

You can put a list of ignored paths into the _2IGNORE environment variable separated by colons. In my case it looks like:

export _2IGNORE="/tmp/*:/home/serge"

The star at the end of the path means a mask.

Next, the hints that are closer to the end of the path are more important, thus for hint "sys" it's more likely to go to /usr/include/sys than to /sys/kernel/debug.

Hints are matched in the order you type them.

Another thing to remember is that extra importance have hints that match the parts of the path after the separators: hint "inc" points /usr/include more obviously than hint "clu" even though "clu" is closer to the end of the path.

That's all you need to know. Happy "2"-ing!

interactive mode

If you want to see what path matches your hints the best you can try interactive mode. It's still in its very early days, but might help someone.

To activate interactive mode type Ctrl+2 in zsh or Alt+2 in bash.

other info

"2" is an open source software and is distributed under MIT license.