Autojump: Autocomplete in zsh (with oh-my-zsh) not working

Created on 18 Feb 2015  ·  20Comments  ·  Source: wting/autojump

Sorry, if I am missing something obvious, but hopefully you might be able to tell me what that is.

I have installed autojump with brew in my setup of zsh (version 5.0.7) and oh-my-zsh but don't seem to be able to use tab autocompletion, instead I am just getting the files and folders of the current dir.

I've added the [[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh line to my .zshrc and also tried enabling the autojump plugin that comes with oh-my-zsh (should I?). In any case, I wasn't able to get the tab completion working. Everything else works ok.

What am I missing? Thanks!

All 20 comments

For me as well. TABbing in autojump is not doing anything...

Tabbing in autojump is stil not doing anything.

+1,I am just getting the files and folders of the current dir too. why ??? I installed autojump with brew ,but it's not working

In mac, it's not working; but in ubuntu it's OK

My fix for this issue is -
1) Execute the zshrc in the bash first, and then change the SHELL, say -
$~/.zshrc
$ZSH

Provided you have followed the installation steps given here - https://github.com/robbyrussell/oh-my-zsh/blob/master/README.markdown

P.S : It worked in mac for me

FWIW, I'm on Mac too (with zsh). Had this problem a while ago, but it's been fixed for a while for me.

I've got the same problem:

image

Same here. Any updates?

With oh-my-zsh, the autojump completion works.
Without oh-my-zsh, the completion does not work.

I installed autojump through homebrew. I made sure
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
is in my ~/.zshrc

autojump v22.5.3
zsh 5.7.1 (x86_64-apple-darwin19.0)

I think I've found the solution while reading Moving to zsh
Without on-my-zsh, I need to run
autoload -Uz compinit && compinit
I also found a similar command in ~/.oh-my-zsh/oh-my-zsh.sh
autoload -U compaudit compinit
I guess the key thing is the compinit.

(If my solution also works for you, please give me a thumb up. 😃)

@boyoungzheng your solution worked for me, except it's adding annoying double underscore ("__") after the typed text:

so:
$ j tmp<tab><tab>

turns into:

$ j tmp__

tmp__1__/bla/tmp-something
tmp__2__/bla/another-tmp
...

there are also few identical suggestions, which seem like a bug.
but good enough for me :)

@boyoungzheng your solution worked for me, except it's adding annoying double underscore ("__") after the typed text:

so:
$ j tmp<tab><tab>

turns into:

$ j tmp__

tmp__1__/bla/tmp-something
tmp__2__/bla/another-tmp
...

there are also few identical suggestions, which seem like a bug.
but good enough for me :)

Did you manage to fix this? I'm having the same problem. Autocomplete works but it just shows two underscores.

@MauritsDescamps no, I haven't managed to solve it.

Anyone find a fix for this yet? I'm stuck with Maurits' issue also.

Well apparently it's it's a feature:

ZSH tab completion fixed.

ZSH behavior now matches Bash behavior. However it requires the compinit module to be loaded. Add the following line to ~/.zshrc:

autoload -U compinit; compinit

To use type:

j

A menu showing the top database entries will be displayed. Type in any number followed by to complete the entry.

@shaungrady Interesting. Ok I ran that and got some initial warnings about insecure directories. That was easy to resolve by running compaudit and fixing the permissions those the directories listed.

The markup in that file isn't right so I had to read the RAW form of the README to see what it was saying. It said to type j followed by space followed by 2 tabs and the enter the number you want to jump to but that just pops up two underscores for me. However, I can do j xTABTAB to expand to x__1_foo x__2_bar and enter 2 to jump to bar.

If this is the best it functions that's fine, but something still seems a little off to me. Thanks.

Hi, i add de plugin autojump un .zshrc file, and works.
MacOS Catalina V10.15.7
autojump v22.5.3

plugins=(git autojump)

Hi, i add de plugin autojump un .zshrc file, and works.
MacOS Catalina V10.15.7
autojump v22.5.3

plugins=(git autojump)

And move the source $ZSH/oh-my-zsh.sh line from .zshrc at the end of the same file.

I really think @shaungrady has solved this issue by saying to add autoload -U compinit; compinit to get completion to work. (man zshcontrib). The plugins=(autojump) thing is only necessary if you use oh-my-zsh but that plugin is just a script (autojump.plugin.zsh) that sources the autojump profile script.

If you don't use oh-my-zsh, like I don't, you still have to source the script (which will be in a different location depending on what OS and/or how you installed it, e.g., for me on MacOS installing autojump with Homebrew, it's in /usr/local/etc/profile.d/autojump.sh).

In summary, the steps whether you use oh-my-zsh or regular zsh are:
1) In .zshrc, source the autojump profile script (or if using oh-my-zsh just have plugins=(autojump) source it for you.
2) In .zshrc, make completion work by adding autoload -U compinit; compinit -y
3) Start completing things by typing j foo[tab][tab] and when the menu pops up, enter the directory number and enter.

@rkulla I did experience the same issue on Ubuntu 18.04, oh-my-zsh .

I did add the autoload -U compinit; compinit -y in my zshrc as suggested and I got the tab completion working now ! Thank you !

Was this page helpful?
0 / 5 - 0 ratings