feat: add z -- to jump to last rested directory#1182
Closed
douglasjsellers wants to merge 1 commit intoajeetdsouza:mainfrom
Closed
feat: add z -- to jump to last rested directory#1182douglasjsellers wants to merge 1 commit intoajeetdsouza:mainfrom
z -- to jump to last rested directory#1182douglasjsellers wants to merge 1 commit intoajeetdsouza:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
z --command that jumps back to the last directory the user stayed in for at least 5 seconds_ZO_REST_THRESHOLDenvironment variable (default: 5 seconds)How it works
Each shell hook now tracks how long the user stays in a directory. When the user changes directories, if they were in the previous directory for >=
_ZO_REST_THRESHOLDseconds, that directory is saved as the "last rested" directory. Runningz --jumps to it.State is session-local (shell variables), similar to how
z -/$OLDPWDworks.Time sources (chosen to avoid unnecessary forking)
$SECONDS$SECONDSdate +%sdate +%s[DateTimeOffset]::Now.ToUnixTimeSeconds()(time:now)[unix]date now | format date '%s' | into int`date +%s`time.time()Test plan
cargo testpasses (template syntax validation)cd /tmp && sleep 6 && cd /var && z --jumps to/tmpcd /tmp && sleep 1 && cd /var && z --does NOT update last restedz --with no prior rest prints error_ZO_REST_THRESHOLD=2lowers the threshold🤖 Generated with Claude Code