use autojump effectively with tmux

Autojump is a nice little tool that learns from your cd history and then allows you to directly jump to a directory with just a few - even fuzzy - characters of the path by just issuing something along the lines of

# destination path is abc/def/ghi

j ab/hi

The tj command (read tmux-jump) is a very small helper function that makes use of autojump, but instead of directly cd'ing, it opens a new tmux window and there jumps to the selected directory. It also sets a proper name for the tmux window.

The Code

tj() {
    DIR=$(autojump $1)
    NAME=$(basename $DIR)
    tmux new-window -c $DIR -n $NAME

How to use it

Put the code into a file, e.g. tmux-jump.zsh and source it. If you like it, add the command to source it to one of your shell initialization scripts.

Then instead of j, run tj. If no path is found within the autojump database, nothing will happen. Otherwise, a new tmux window with a shell will be opened in the found directory.