mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2024-12-28 03:45:06 +00:00
f9f1db8f30
We should append `_zoxide_precmd` to `precmd_functions` within an array literal, not by itself.
30 lines
511 B
Bash
30 lines
511 B
Bash
#!/usr/bin/env sh
|
|
|
|
_zoxide_precmd() {
|
|
zoxide add
|
|
}
|
|
|
|
[[ -n "${precmd_functions[(r)_zoxide_precmd]}" ]] || {
|
|
precmd_functions+=(_zoxide_precmd)
|
|
}
|
|
|
|
z() {
|
|
if [ $# -ne 0 ]; then
|
|
_Z_RESULT=$(zoxide query "$@")
|
|
case $_Z_RESULT in
|
|
"query: "*)
|
|
cd "${_Z_RESULT:7}"
|
|
;;
|
|
*)
|
|
echo "${_Z_RESULT}"
|
|
;;
|
|
esac
|
|
fi
|
|
}
|
|
|
|
alias zi="z -i"
|
|
|
|
alias za="zoxide add"
|
|
alias zq="zoxide query"
|
|
alias zr="zoxide remove"
|