support autocd option
In bash, when autocd option is set and user enters a directory name as a command, it results in a very specific call to cd: cd -- [directory name] zoxide's directory changing function passes all arguments to __zoxide_z as is, including the "--" first argument. By detecting this and skipping the first argument changing directory works with autocd set.
This commit is contained in:
parent
cbb8e77d60
commit
b50ee1d9ea
|
|
@ -102,7 +102,13 @@ function __zoxide_zi() {
|
||||||
|
|
||||||
\builtin unalias {{cmd}} &>/dev/null || \builtin true
|
\builtin unalias {{cmd}} &>/dev/null || \builtin true
|
||||||
function {{cmd}}() {
|
function {{cmd}}() {
|
||||||
|
if [[ $# -eq 2 && "$1" == "--" && -d $2 ]]; then
|
||||||
|
# This is how cd is called when bash's autocd option is set. To get the
|
||||||
|
# directory-changing behavior first argument must be skipped.
|
||||||
|
__zoxide_z "${@:2}"
|
||||||
|
else
|
||||||
__zoxide_z "$@"
|
__zoxide_z "$@"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
\builtin unalias {{cmd}}i &>/dev/null || \builtin true
|
\builtin unalias {{cmd}}i &>/dev/null || \builtin true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue