-
Notifications
You must be signed in to change notification settings - Fork 147
FAQ
fz is a bash/zsh plugin that seamlessly adds fuzzy search to tab completion of z.sh. z.lua can work with it for better completion result, just define a _z function and pass all the arguments to _zlua before sourcing fz.sh:
function _z() { _zlua "$@"; }
source /path/to/fz.shIf you are using zsh with antigen, initialize them like this:
antigen boundle skywind3000/z.lua
antigen boundle changyuheng/fz
function _z() { _zlua "$@"; }Paste this script in your .bashrc / .zshrc:
function j() {
if [[ "$argv[1]" == "-"* ]]; then
z "$@"
else
cd "$@" 2> /dev/null || z "$@"
fi
}When you are using j xxx it will first try cd xxx and then z xxx if cd failed.
Issue #46 asked for a script to import some history path from bash command history after a fresh install of z.lua and @antonalekseev provided two script below:
for bash:
fc -ln -10000| sed -e 's|^'[[:blank:]]' ||'|grep -o "^cd [~/].*"|sed -e "s|cd ||" -e "s|~|$HOME|" -e 's|\\ | |' -e "s|/$||"|sort|uniq|while read -r d; do test -d "$d" && echo "$d|1|0"; done >> ~/z.lua
for zsh:
fc -ln 0|grep -o "^cd [~/].*"|sed -e "s|cd ||" -e "s|~|$HOME|" -e 's|\\ | |' -e "s|/$||"|sort|uniq|while read -r d; do test -d "$d" && echo "$d|1|0"; done >> ~/z.lua
These two scripts above can be used for pre-warm .zlua database.
Define a new zii shell function to override z -I:
function zii() {
local $dir="$(z -l "$@"|fzf --nth 2 --reverse --inline-info --tac +s -e --height 35%)"
[ -n "$dest" ] && cd "$dir"
}or just ignore the frecent order:
function zii() {
local $dir="$(z -l -s "$@"|fzf ---reverse -e --height 35%)"
[ -n "$dir" ] && cd "$dir"
}