letsBeePolite
letsBeePolite

Reputation: 2251

iterm2+ohmyzsh: stray characters on terminal from the previous command

Sometimes the commands are persisted in the terminal if I use the up arrow key to re-run the command.
Using backspace doesn't clean the whole terminal as seen in the screenshot.
git command can be seen existing multiple times.

This sometimes issue is seen even when the pervious command is edited, cursor becomes invisible and editing becomes impossible.

I am on Catalina.

zsh: stable 5.8 (bottled), HEAD

enter image description here

Upvotes: 1

Views: 226

Answers (1)

Praveen Kariyanahalli
Praveen Kariyanahalli

Reputation: 11

parse_git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1="\033[01;32m\]\u@\h\[\033[01;33m\]:\w\[\033[01;36m\]\$(parse_git_branch)\[\033[00m\]$ "

I saw similar issues with the stray partial previous commands still lingering. Removed the custom PS1 settings, do NOT see the issue anymore.

Upvotes: 0

Related Questions