If you work with terminals extensively, you may be tired of typing
cd to go
to directories, especially when directory names are very long.
z.lua is such a tool to make your life
easier by jumping to the desired directory smartly.
If you are using bash shell, you need to download the plugin manually. Down and
z.lua file and add
the following setting to your
# change /path/to/z.lua to the actual path of z.lua file eval "$(lua /path/to/z.lua --init bash enhanced once)"
antigen bundle skywind3000/z.lua
z.lua requires that the lua binary is in your PATH. The easiest way to
install lua binary is to install LuaDist. Just extract
it to somewhere on your system and add the path the
lua.exe to your system
Then, copy file
$CMDERROOT/vendor folder and add
$CMDERROOT/vendor to your system PATH.
Make sure to reboot your computer after you have updated the system PATH to make the change take effect.
How to use
First, you need to
cd to a few directories after installing z.lua to build
the cd history. After that, to go a directory containing keyword
foo, use the
z.lua supports command completion. To start completion, press
<Tab> after the
keyword, for example,
Sometimes, several directories may contain the same keywords. You can use
-i option to start interactive path selection:
z -i foo
All directories containing
foo will be listed with its index, you can then
type a index to go to a specific directory.
Jump backward to parent folder
To jump backward to parent directories, use
z -b command. Suppose that you
are in directory
~/github/foo/bar/util, to go to
foo directory, simply use
the following command:
z -b foo
Other useful settings are:
export _ZL_MATCH_MODE=1 # enhanced matching mode export _ZL_ECHO=1 # display the path after cd export _ZL_ADD_ONCE=1 # only add path if the $PWD is changed
We can also create alias for commonly-used command:
# alias for z.lua alias zi="z -i" # interactive selection alias zb="z -b" # jump backward
License CC BY-NC-ND 4.0