LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories
User Name
Password
LinuxQuestions.org Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.

Notices


Reply
  Search this Thread
Old 08-03-2021, 12:01 PM   #1
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,237

Rep: Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322
Simplest ZSH AutoJump


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=cdr
See 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-suffixes
zstyle ':completion:*' expand prefix suffix

alias cd=cdr
My ZSH setup, btw, is Oh My ZSH with the fzf, history-substring-search, zsh-autosuggestions and zsh-syntax-highlighting plugins. It's pretty typical.

Last edited by dugan; 08-03-2021 at 01:02 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] zsh - extend zsh completion blueray Linux - Newbie 1 10-17-2020 02:44 AM
ZSH -- Apple switching BASH => ZSH, what do you think? LQParsons Linux - Newbie 2 06-06-2019 10:01 AM
LXer: How to Setup ZSH and Oh-my-zsh on Linux LXer Syndicated Linux News 0 11-02-2017 12:42 AM
simplest way to connect to another computer? hobylinux Linux - Newbie 9 08-22-2003 01:30 AM
simplest file sharing between Win2k Pro and RH8... kublador Linux - Networking 3 03-22-2003 08:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories

All times are GMT -5. The time now is 09:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration