Fast terminal directory jumping
Go Makefile
Latest commit d3a6cba Sep 25, 2015 @baskerville Version 0.7
Failed to load latest commit information.
doc Fix frecency computation Sep 25, 2015
.gitignore Add Makefile May 18, 2013
LICENSE First commit May 17, 2013
Makefile Version 0.7 Sep 25, 2015
README.asciidoc Generate manual via `asciidoc` Jun 27, 2013
Z.go Remove debug trace Sep 25, 2015

README.asciidoc

Z(1)

Name

Z - Fast terminal directory jumping

Synopsis

Z [OPTIONS] [PATTERN …​]

Description

This is a small variation around rupa’s z.

Options

-a ITEM

Add the given item to the data file.

-d ITEM

Delete the given item from the data file.

-i PATH

Use the given file as data file.

Environment Variables

Z_DATA_FILE

Path to the data file (defaults to ~/.z).

Z_HISTORY_SIZE

Maximum number of items.

Help

Ensure that the data file exists before running Z.

Either create an empty one:

touch ~/.z

Or, if you are a z user, import your data file with:

mv ~/.z ~/.z.bak
awk -F '|' 'BEGIN {OFS="\0"} {print $3, int($2), $1}' ~/.z.bak > ~/.z

You can emulate z with:

z() {
    local dir=$(Z "$@" | head -n 1)
    pushd "$dir" > /dev/null 2>&1 || Z -d "$dir"
}

If your shell is Bash, add the following to ~/.bashrc:

export PROMPT_COMMAND='[ "$PWD" -ef "$HOME" ] || Z -a "$PWD"'

Else, if your shell is Zsh, add the following to ~/.zshrc:

chpwd() {
    [ "$PWD" -ef "$HOME" ] || Z -a "$PWD"
}

Frecency

The frecency is given by:

H / (0.25 + A * 3e-6)

Where H is the number of hits and A the age in seconds.

Author

Bastien Dejean <nihilhill at gmail.com>