Autojump not right out of the box in fedora 33

recently I upgrade to fedora 33, and I install autojump right now, I remember autojump is right out of the box in fedora, no need to add extra command in bashrc like ubuntu, open a new terminal ,I can use the j command,but when I cd some directories, autojump won’t remember it,even I restart my pc ,it doesn’t work.
j command is defined in /usr/share/autojump/autojump.bash,so it’s sourced since I can use j. fedora place in the global location /etc/profile.d/, will source /usr/share/autojump/autojump.bash so autojump should work out of the box, but it failed.
I had select “Run command as a login shell” in gnome-terminal, the same result comes, j can use ,but it won’t remember the cd directories.
only after I add “source /etc/profile.d/” in ~/.bashrc , autojump works well.

Where did you get autojump? A fedora repo or somewhere else?

Did you log out and back in or reboot after doing the install? If not then the contents of /etc/profile.d/ did not get processed for your current session.

1 Like

Check from a new user with default shell and profile configs to localize the cause of the issue.

I use “sudo dnf install autojump” to get autojump, in addition, I have tried log out and back in or reboot , but not work.

I have try a new user with bash and profile as you say, but I still get the same result, the j command can be uesd, but it won’t remember the cd directories

1 Like

I noticed the comment in the head of /etc/profile.d/
# NOTE: problems might occur if /bin/sh is symlinked to /bin/bash
but in fedora /bin/sh → bash
$ ll /bin/sh
lrwxrwxrwx. 1 root root 4 Jul 27 21:18 /bin/sh → bash
whether this cause the useless of autojump or not?

Check from your user session:

ls -l -a ~/.local/share/autojump
cat ~/.local/share/autojump/autojump.txt

[ljhui@thinkpad ~]$ echo ${SHELL} ${BASH} ${BASH_VERSION}
/bin/bash /usr/bin/bash 5.0.17(1)-release

[ljhui@thinkpad ~]$ ls -l -a ~/.local/share/autojump
total 8
drwxrwxr-x. 1 ljhui ljhui 56 Nov 5 14:55 .
drwx------. 1 ljhui ljhui 436 Nov 5 12:35 …
-rw-------. 1 ljhui ljhui 448 Nov 5 14:55 autojump.txt
-rw-------. 1 ljhui ljhui 27 Nov 4 15:51 autojump.txt.bak

[ljhui@thinkpad ~]$ cat ~/.local/share/autojump/autojump.txt
2.0 /home/ljhui/.local/bin
10.0 /home/ljhui/.config/autostart
38.729833462074176 /home/ljhui/Documents
20.0 /home/ljhui/Downloads
17.320508075688775 /home/ljhui/.local/share/applications
17.320508075688775 /home/ljhui/.local/share/icons
26.457513110645905 /home/ljhui/.local/share/gnome-shell/extensions
14.142135623730951 /home/ljhui/.local/share/gnome-shell
14.142135623730951 /home/ljhui/.local/share/gedit
17.320508075688775 /home/ljhui/Videos

1 Like

It looks like the paths are stored successfully.
Unfortunately, I don’t use this tool, so I’m not sure how to proceed with troubleshooting.
Perhaps you should file a bug report against it.

No, the path are not stored before I add “source /etc/profile.d/” in ~/.bashrc,autojump well works after adding that line, what trap me is that since /etc/profile.d/ is globally sourced, there is no need to add that.

You can perform debugging and analyze the logs:

for FILE in /etc/{profile,bashrc}
do sudo sed -i -e "1a set -x -v\nexec &> /tmp/log.${USER}.${FILE##*/}" ${FILE}

I just figure out what cause this! autojump keeps track of directories by modifying $PROMPT_COMMAND , but in system files /etc/bashrc and /etc/profile.d/ have defines for PROMPT_COMMAND, so even /etc/profile.d/ is globally sourced for all shell users, but $PROMPT_COMMAND would be override, so j command can used but autojump would not remember the cd directories whether you use login or non-login shell in gnome terminal, in general, when lauch gnome-terminal, the PROMPT_COMMAND would be “__vte_prompt_command”, but if autojump work well,
PROMPT_COMMAND show be “__vte_prompt_command ; autojump_add_to_database”, the autojump_add_to_database function will add to PROMPT_COMMAND
/etc/profile.d/ overwrites PROMPT_COMMAND improvement - simple hook function to preserve user custom prompts

1 Like