'Autojump on mac OS X returning path, but not jumping to desired directory

The problem I have on OS X Yosemite:

autojump v22.2.4 (https://github.com/joelthelion/autojump), via the alias

j

returns the path that I would like to jump to, but does not perform the actual jump.

The sad workaround is copying the returned path and adding it to a cd command.

j work   
/Users/peterlustig/Documents/workspace/
# now copy the resulting path manually
cd /Users/peterlustig/Documents/workspace/ 

The problem persists in both terminal and iterm2. I followed the post-installation instructions after

brew install autojump 

and added

[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh

to my ~/.bash_profile.

EDIT:

jc work

lets me jump to my 'workspace' directory (after printing the path to the workspace directory). Now, what is the problem with

j

?



Solution 1:[1]

I got it working, I suggest you do the following:

  1. Check which shell your running:

    ps -op $$
    
    # im runnning
    PID   TTY        TIME    CMD
    43977 ttys012    0:00.11 -bash
    
  2. If you like me installed via brew then you probably added (there .sh files):

    [[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh
    

I'm running bash and was not aware there are different shells to include:

     # have a look in:
     /usr/local/etc

     # you should see mutliple shell scripts to include (depending on your env):
     autojump.bash -> ../Cellar/autojump/21.7.1/etc/autojump.bash
     autojump.sh -> ../Cellar/autojump/21.7.1/etc/autojump.sh
     autojump.zsh -> ../Cellar/autojump/21.7.1/etc/autojump.zsh
  1. For me, there is no /usr/local/etc/profile.d only /usr/local/etc. Change the command to:

    # ~/.bash_profile
    # i append this as my last line, that seems to work
    [[ -s $(brew --prefix)/etc/autojump.bash ]] && . $(brew --prefix)/etc/autojump.bash
    
  2. Logout of your Terminal and login, that should work.

Solution 2:[2]

This helped me https://github.com/wting/autojump/issues/511#issuecomment-362142038:

You have to cd <dirname> first than autojump will remember it for you the next time you call j <dirname>

Solution 3:[3]

It seems this bug exists in the latest version of autojump(22.5.1). autojump command just printouts the directory path, but does not changes the directory.

I did the following things - 1.) Added the following line to my ~/.zshrc file

[[ -s `brew --prefix`/etc/autojump.sh ]] && . `brew --prefix`/etc/autojump.sh

2.) Then simply created a alias which pipes the autojump to cdcommand

alias j=autojump | cd

Hope this works for you guys.

Solution 4:[4]

I use bash on OSX. It was not working for me either. The problem was that I hadn't manually changed to any directories. Once I did that, it worked as advertised.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Roger
Solution 2 Alexander Yalunin
Solution 3 ARK
Solution 4 Chad