diff --git a/README.md b/README.md index d982db8..5222f5a 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,38 @@ Licensed under MIT license. ## Features -* 10x times faster than fasd and autojump -* 3x times faster than rupa/z -* supports: Posix Shell, Bash, Zsh and Windows Cmd +- 10x times faster than fasd and autojump +- 3x times faster than rupa/z +- supports posix shells: bash, zsh, dash, sh, busybox, and etc. +- supports Windows cmd (with clink) and cmder +## Install +- bash: + put something like this in your `.bashrc`: + eval "$(lua /path/to/z.lua --init bash)" + +- zsh: + put something like this in your `.zshrc`: + eval "$(lua /path/to/z.lua --init zsh)" + +- posix shells: + put something like this in your `.profile`: + eval "$(lua /path/to/z.lua --init posix)" + +- Windows (with clink): + copy z.lua and z.cmd to clink's home directory + Add clink's home to `%PATH%` (z.cmd can be called anywhere) + Ensure that "lua" can be called in `%PATH%` + +- Windows Cmder Install: + copy z.lua and z.cmd to cmder/vendor + Add cmder/vendor to %PATH% + Ensure that "lua" can be called in %PATH% + +## Customize + +- set $_ZL_CMD in .bashrc/.zshrc to change the command (default z). +- set $_ZL_DATA in .bashrc/.zshrc to change the datafile (default ~/.zlua). +- set $_ZL_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself. +- set $_ZL_EXCLUDE_DIRS to an array of directories to exclude. diff --git a/z.lua b/z.lua index c51891b..ec7bac6 100644 --- a/z.lua +++ b/z.lua @@ -8,7 +8,7 @@ -- -- * 10x times faster than fasd and autojump -- * 3x times faster than rupa/z --- * supports: Bash, Zsh, Posix Shells and Windows Cmd +-- * supports: Bash, Zsh, Posix shells and Windows cmd -- -- USE: -- * z foo # cd to most frecent dir matching foo @@ -17,6 +17,7 @@ -- * z -t foo # cd to most recently accessed dir matching foo -- * z -l foo # list matches instead of cd -- * z -c foo # restrict matches to subdirs of $PWD +-- * z -e foo # echo the best match, don't cd -- -- Bash Install: -- * put something like this in your .bashrc: @@ -1136,8 +1137,9 @@ _zlua() { else local dest=$("$ZLUA_LUAEXE" "$ZLUA_SCRIPT" --cd $arg_type $arg_subdir "$@") if [ "$dest" ] && [ -d "$dest" ]; then - [ -n "$arg_echo" ] && echo "$dest" - if [ -z "$_ZL_NOBUILTIN" ]; then + if [ -n "$arg_echo" ]; then + echo "$dest" + elif [ -z "$_ZL_NOBUILTIN" ]; then builtin cd "$dest" else cd "$dest" @@ -1285,11 +1287,12 @@ if /i "%ListOnly%"=="-n" ( if exist !NewPath!\nul ( if /i "%EchoPath%"=="-e" ( echo !NewPath! + ) else ( + pushd !NewPath! + pushd !NewPath! + endlocal + popd ) - pushd !NewPath! - pushd !NewPath! - endlocal - popd ) ) ) else (