Add a new `z --` command that jumps back to the last directory the user
stayed in for at least 5 seconds. The threshold is configurable via the
`_ZO_REST_THRESHOLD` environment variable (default: 5).
This is implemented entirely in the shell templates with no Rust binary
changes. Each shell hook now tracks dwell time per directory and records
the last "rested" directory in a session-local variable.
Supported across all 9 shells: bash, zsh, fish, posix, powershell,
elvish, nushell, tcsh, and xonsh.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fish ships with built-in completions for common commands like `j` (share/completions/j.fish for autojump). These override zoxide's completions when using `--cmd j`. Clear them before defining aliases.
Only ksh93 supports DEBUG traps, and the rest don't have any features
that can be used for setting up hooks. May as well use the POSIX
implementation for all ksh shells.
* 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.
* remove directory check
just skip the first argument and pass the rest as is. checking for directory
breaks cd'ing to symlinked directories
* undo some of the hackery
tests are failing
elvish uses lexical scoping for closure capture, as such all `oldpwd`
references within the script refers to the `oldpwd` defined at the top.
However, before-chdir hook is trying to assign to `oldpwd` within the
editor scope, which is not used by this script.
This manifested as a bug in which:
```
~
> mkdir -p /tmp/another
~
> z /tmp
/tmp
> z another
/tmp/another
> z -
~
> # The previous dir should be /tmp not ~!
```
Because the hook was updating a variable that was not used.
Fix the hook so that before-chdir assign to the proper upvalue.