autojump not working because PROMPT_COMMAND is __vte_prompt_command
Flimm opened this issue · comments
autojump
is not working for me. It was not adding directories to autojump -s
, even though I was sourcing /usr/share/autojump/autojump.sh
in .bashrc
(in Ubuntu 21.10, according to the instructions in /usr/share/doc/autojump/README.Debian
.
Under known issues, the documentation says that PROMPT_COMMAND
should not be overwritten. So I decided run this command to troubleshoot:
$ echo "$PROMPT_COMMAND"
__vte_prompt_command
Clearly, something is wrong here, as autojump
's code is not in PROMPT_COMMAND
.
After doing some digging, I found this code in /etc/profile.d/vte-2.91.sh
:
case "$TERM" in
xterm*|vte*)
[ -n "${BASH_VERSION:-}" ] && PROMPT_COMMAND=__vte_prompt_command
[ -n "${ZSH_VERSION:-}" ] && precmd_functions+=(__vte_osc7)
;;
esac
I changed one line so that it now looks like:
case "$TERM" in
xterm*|vte*)
[ -n "${BASH_VERSION:-}" ] && PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ;} __vte_prompt_command"
[ -n "${ZSH_VERSION:-}" ] && precmd_functions+=(__vte_osc7)
;;
esac
And now autojump
works as expected.
Note that newer versions of Bash accept an array PROMPT_COMMAND
variable (as an alternative to a normal string variable). It would be good if all this code was updated to treat PROMPT_COMMAND
as a Bash array some day.