Reverse Search and edit with customized PS1, shows a different command and executes a different command
Thanks for filing an issue! Please answer the questions below so I can help you.
- iTerm2 version:3.1.5
- OS version:
- Attach com.googlecode.iterm2.plist here (drag-drop from finder into this window)
- Attach a debug log, if possible. Instructions at https://iterm2.com/debuglog debuglog.txt
- Are you reporting a performance issue or a hang? Please attach a sample. Instructions at https://gitlab.com/gnachman/iterm2/wikis/HowToSample
- Are you reporting a crash? Please attach the crash log. Instructions at https://gitlab.com/gnachman/iterm2/wikis/crash-logs
Detailed steps to reproduce the problem:
- Doing a reverse search, (ctrl+r) in bash and try to edit the command.
- When working on modifying the commands, cursor is shown at one place, and it edits at a different place.
- I have a customized PS1 which shows the git branch name,
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
PS1="\[\e[1;32m\]\W \[\e[1;35m\](\$(parse_git_branch))\[\e[1;32m\]\$\[\e[0m\] "
- I customize the history by the following command.
export HISTSIZE=50000
export HISTFILESIZE=500000
shopt -s histappend
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
What happened: Reverse Search and edits, displays one command and executes a different command. iTerm2_ReverseSearch_Edit_bug
I attached a quick time movie of the issue. You will see that end and start of the commands are inside the prompt and # adding a comment shows it at one place. Using up arrow to retrieve the last command, shows a different one.
What should have happened: Reverse Search and edits are broken. I have learnt to work around by making the command first a comment using #, then editing it using the up arrow keys again. This have caused me to execute wrong commands.
Edited by George Nachman