Add 'z -' capability to bash and zsh

This commit is contained in:
Ajeet D'Souza 2020-03-11 01:58:40 +05:30
parent 34ab8f3f8b
commit 15b30206df

View File

@ -157,18 +157,20 @@ case "$PROMPT_COMMAND" in
esac
z() {
if [ $# -ne 0 ]; then
if [ "$#" -eq 0 ]; then
cd "$HOME"
elif [ "$#" -eq 1 ] && [ "$1" = "-" ]; then
cd "-"
else
_Z_RESULT=$(zoxide query "$@")
case $_Z_RESULT in
case "$_Z_RESULT" in
"query: "*)
cd "${_Z_RESULT:7}"
;;
*)
echo -n "${_Z_RESULT}"
echo -n "$_Z_RESULT"
;;
esac
else
cd "${HOME}"
fi
}
"#;
@ -220,18 +222,20 @@ _zoxide_precmd() {
}
z() {
if [ $# -ne 0 ]; then
if [ "$#" -eq 0 ]; then
cd "$HOME"
elif [ "$#" -eq 1 ] && [ "$1" = "-" ]; then
cd "-"
else
_Z_RESULT=$(zoxide query "$@")
case $_Z_RESULT in
case "$_Z_RESULT" in
"query: "*)
cd "${_Z_RESULT:7}"
;;
*)
echo -n "${_Z_RESULT}"
echo -n "$_Z_RESULT"
;;
esac
else
cd "${HOME}"
fi
}
"#;