autojump icon indicating copy to clipboard operation
autojump copied to clipboard

-bash: PROMPT_COMMAND: readonly variable

Open SmallPineApp1e opened this issue 2 years ago • 2 comments

When I installed autojump by git clone xxx && install.py, I added that code in my ~/.bashrc and source it

[[ -s /home/zengzhijie/.autojump/etc/profile.d/autojump.sh ]] && source /home/zengzhijie/.autojump/etc/profile.d/autojump.sh

but it reminded me "-bash: PROMPT_COMMAND: readonly variable", and autojump didn't work, can someone help me? :(

SmallPineApp1e avatar Oct 11 '23 05:10 SmallPineApp1e

See what you get if you do echo $PROMPT_COMMAND. In my case it showed that USER_PROMPT_COMMAND is run at the end of PROMPT_COMMAND. I then edited ~/.autojump/share/autojump/autojum.bash (change as appropriate if your shell isn't bash) to replace the line

PROMPT_COMMAND="${PROMPT_COMMAND:+$(echo "${PROMPT_COMMAND}" | awk '{gsub(/; *$/,"")}1') ; }autojump_add_to_database"

with

USER_PROMPT_COMMAND="${USER_PROMPT_COMMAND:+$(echo "${USER_PROMPT_COMMAND}" | awk '{gsub(/; *$/,"")}1') ; }autojump_add_to_database"

. That got autojump working for me.

justsz avatar Apr 24 '24 14:04 justsz