Autojump: Unable to enter the directory, simply print out

Created on 13 Jan 2016  ·  12Comments  ·  Source: wting/autojump

My system is ArchLinux, autojump Installation by pacman.
Profile with oh-my-zsh, but I can not configure how good it

➜  /home/king  >autojump
/home/king/AndroidStudioProjects/yjy-android
➜  /home/king  >autojump -s
10.0:   /home/king/.AndroidStudio1.5/config
10.0:   /home/king/.oh-my-zsh
10.0:   /home
10.0:   /home/king/GitProjects/dash-to-dock
10.0:   /home/king/back
10.0:   /home/king/usb
10.0:   /home/king/autojump
14.1:   /home/king/PythonProjects
14.1:   /usr/share/zsh/functions/Zle
14.1:   /home/king/vimtest
14.1:   /home/king/GitProjects
14.1:   /home/king/android/.repo
14.1:   /home/king/.AndroidStudio1.5
17.3:   /home/king/Downloads/genymotion
24.5:   /home/king/android
28.3:   /home/king/AndroidStudioProjects
37.4:   /home/king/Downloads
44.7:   /home/king/AndroidStudioProjects/yjy-android
________________________________________

307:     total weight
18:  number of entries
0.00:    current directory weight

data:    /home/king/.local/share/autojump/autojump.txt
➜  /home/king  >autojump -v
autojump v22.2.4

in the .zshrc

[[ -s /etc/profile.d/autojump.zsh ]] && source /etc/profile.d/autojump.zsh
plugins=(git autojump)

I'm sure these files are present

➜  /home/king  >ls /etc/profile.d 
android-sdk.csh                 autojump.fish  jre.csh             perlbin.csh
android-sdk-platform-tools.csh  autojump.sh    jre.sh              perlbin.sh
android-sdk-platform-tools.sh   autojump.zsh   locale.sh           vte.sh
android-sdk.sh                  gpm.sh         mozilla-common.csh
autojump.bash                   gradle.sh      mozilla-common.sh

Most helpful comment

You're not supposed to use it directly, you're supposed to be using the j function to jump to previously visited directories.

All 12 comments

My other computer is a normal, and I can not understand why so

Same issue currently. Running fedora 23.

Please read the usage section or man pages.

@wting I have read, but the problem still exists. Can not access the directory, it will only print out the directory

➜  ~ j yjy
/home/king/AndroidStudioProjects/yjysh
➜  ~ j -v
autojump v22.3.0
➜  ~ j -s
10.0:   /home/king/AndroidStudioProjects/yjysh
10.0:   /home/king/gitProjects/autojump
10.0:   /home/king/gitProjects
________________________________________

30:  total weight
3:   number of entries
0.00:    current directory weight

data:    /home/king/.local/share/autojump/autojump.txt


This relates to #154, but let's keep conversation here. @turing-king: Try this:

$ echo $SHELL
$ which j
$ declare -f j

@wting

➜  yjysh git:(release) ✗ echo $SHELL
/bin/zsh
➜  yjysh git:(release) ✗ which j
j: aliased to autojump
➜  yjysh git:(release) ✗ declare -f j
j () {
    if [[ ${1} = -* ]] && [[ ${1} != "--" ]]
    then
        autojump ${@}
        return
    fi
    setopt localoptions noautonamedirs
    local output="$(autojump ${@})" 
    if [[ -d "${output}" ]]
    then
        if [ -t 1 ]
        then
            echo -e "\\033[31m${output}\\033[0m"
        else
            echo -e "${output}"
        fi
        cd "${output}"
    else
        echo "autojump: directory '${@}' not found"
        echo "\n${output}\n"
        echo "Try \`autojump --help\` for more information."
        false
    fi
}

j should not be aliased to autojump, it's overriding the j shell function.

@wting Direct use has no effect

➜  ~ autojump -s
10.0:   /home/king/gitProjects/autojump
10.0:   /home/king/gitProjects
10.0:   /home/king/AndroidStudioProjects
17.3:   /home/king/AndroidStudioProjects/yjysh
________________________________________

47:  total weight
4:   number of entries
0.00:    current directory weight

data:    /home/king/.local/share/autojump/autojump.txt




➜  ~ autojump yjy
/home/king/AndroidStudioProjects/yjysh

➜  ~ declare -f autojump
➜  ~ 


You're not supposed to use it directly, you're supposed to be using the j function to jump to previously visited directories.

@wting Thanks ~

I still have this problem

echo $SHELL return /bin/bash
which j returns nothing
declare -f j returns the function j

Can someone help me out ?

@tuananh how do you initialize autojump? This is what I have in my shell rc file (Fedora distribution):

[[ -s /etc/profile.d/autojump.sh ]] && source /etc/profile.d/autojump.sh
Was this page helpful?
0 / 5 - 0 ratings