Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] zi cd with zero args or -[[:digit:]] argument will jump to the last N dir #330

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

psprint
Copy link
Contributor

@psprint psprint commented Jul 6, 2022

PR makes zi cd with no arguments or with a -[[:digit:]] argument jump to last Nth visited dir, e.g.: to the last one (most recent, -1 or no arguments), or to one before last (-2 given as argument, i.e.: zi cd -2), and so on. This stack essentially works as cd -[[:digit:]] except that the last dir on the stack is -1, not -0 (i.e.: just like Zsh array indices).

Description

The stack is set up on 1150 …1500 size varying between the two numbers (when 1500 is exceeded, 1150 is enforced). The code is pretty simple.

Motivation and Context

My completion got broken and I've couldn't complete plugin ids for zi cd <TAB>. I then thought that a stack of recent visited dirs with zi cd can be a good alternative to automatic pids completion.

PS. I've fixed my completion now :)

Related Issue(s)

Usage examples

# Go to the last visited dir
zi cd
zi cd -1
# Go to  Nth counting from the end of the list of visited directories
zi cd -2
zi cd -3
zi cd -7
# etc..

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@github-actions github-actions bot added the zinit label Jul 6, 2022
zinit-autoload.zsh Outdated Show resolved Hide resolved
@vladdoster vladdoster changed the title Make zi cd with no arguments or with a -[[:digit:]] argument jump to last Nth visited dir [feat] zi cd with zero args or with a -[[:digit:]] argument jump to last N^^th visited dir Jul 15, 2022
@vladdoster vladdoster changed the title [feat] zi cd with zero args or with a -[[:digit:]] argument jump to last N^^th visited dir [feat] zi cd with zero args or with a -[[:digit:]] argument jump to last **N**th visited dir Jul 15, 2022
@vladdoster vladdoster changed the title [feat] zi cd with zero args or with a -[[:digit:]] argument jump to last **N**th visited dir [feat] zi cd with zero args or with a -[[:digit:]] argument jump to the last N dir Jul 15, 2022
@vladdoster vladdoster changed the title [feat] zi cd with zero args or with a -[[:digit:]] argument jump to the last N dir [feat] zi cd with zero args or -[[:digit:]] argument will jump to the last N dir Jul 15, 2022
@psprint
Copy link
Contributor Author

psprint commented Jul 16, 2022

It's possible to easily test the PR with pr command from tj/git-extras via git pr {number}.

last or -2, or -3, etc. last visited directory with `zi cd …`. This
stack essentially works as `cd -[[:digit:]]` except that the last
dir on the stack is -1, not -0 (i.e.: just like Zsh array indices).
@psprint
Copy link
Contributor Author

psprint commented Jul 16, 2022

I've done the comment update, after some fine tuning of it.

@vladdoster
Copy link
Member

It seems reasonable to update _zinit to expose this feature. Thoughts?

@psprint
Copy link
Contributor Author

psprint commented Jul 17, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants