Article 5MXPC Simplest ZSH AutoJump

Simplest ZSH AutoJump

by
dugan
from LinuxQuestions.org on (#5MXPC)
This is the simplest (and IMHO correct) way to set up an equivalent of autojump in ZSH:

Code:autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
zstyle ':completion:*:*:cdr:*:*' menu selection
zstyle ':chpwd:*' recent-dirs-default yes
zstyle ':completion:*' recent-dirs-insert always
zstyle ':completion:*:*:cdr:*:*' list-suffixeszstyle
zstyle ':completion:*:*:cdr:*:*' expand prefix suffix
alias j=cdrSee the zshcontrib manpage for the explanation.

The list-suffiszstyle and "expand prefix suffix" options are to get TAB-completion to work if you just enter a substring of a directory in your history and press TAB. It's from here: Moving to zsh, part 5: Completions

Or, if you'd prefer a more FISH-like experience where the CD command is augmented with history completion and everything can complete from the middle of a string:

Code:autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
zstyle ':completion:*:*:cdr:*:*' menu selection
zstyle ':chpwd:*' recent-dirs-default yes
zstyle ':completion:*' recent-dirs-insert both
zstyle ':completion:*' list-suffixeszstyle ':completion:*' expand prefix suffix
alias cd=cdrMy ZSH setup, btw, is Oh My ZSH with the fzf, history-substring-search, zsh-autosuggestions and zsh-syntax-highlighting plugins. It's pretty typical.latest?d=yIl2AUoC8zA latest?i=l8oGyHKa9Ck:yifUpK8wwfI:F7zBnMy latest?i=l8oGyHKa9Ck:yifUpK8wwfI:V_sGLiP latest?d=qj6IDK7rITs latest?i=l8oGyHKa9Ck:yifUpK8wwfI:gIN9vFwl8oGyHKa9Ck
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments