The problem I have happens after a ssh connection has been ended by closing my MacBook (putting it in stand-by mode). I come back and it's written broken pipe.

When I click on the terminal window, a succession of characters appear. If I click several times, then the combination of these characters will appear the same number of times.

By moving my cursor, I can change the combination of letters...
Here, between every line, I moved my cursor somewhere else on my Desktop.

The strange behaviour in image

The content of my ~/.bash_profile is:

# Tell ls to be colourful
export CLICOLOR=1
export LSCOLORS=Exfxcxdxbxegedabagacad

# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'

export TERM="xterm-color"
PS1='\[\e[0;33m\]\u\[\e[0m\]@\[\e[0;32m\]\h\[\e[0m\]:\[\e[0;34m\]\w\[\e[0m\]\$ '

# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
export PATH

# added by Anaconda3 5.2.0 installer
export PATH="/anaconda3/bin:$PATH"


  • macOS High Sierra version 10.13.5

6 Answers 6


You have somehow activated the terminal's mouse tracking mode. This is usually used by terminal applications which accept mouse input (like vim), which can interpret these character sequences as mouse events. The shell does not support mouse input, so it displays these sequences directly.

You can turn off mouse tracking mode by running the reset command in the terminal.

  • 1
    It works. but I don't understand why it works? reset is a command to the shell, while mouse tracking mode is for the terminal app. I guess that reset does not disable terminal app's mouse tracking, so it preventing the shell accepting mouse actions?
    – bruin
    Sep 2, 2022 at 1:10
  • The terminal is emulating a (heavily modified) old-fashioned physical terminal, a DEC VT102 to be specific, and you could change their behavior by sending certain character sequences to it. The reset command sends the "reset" sequence to the terminal.
    – Mike
    Feb 15 at 2:01

I just had this issue and going to view > Allow (or disallow) mouse reporting will solve it.

enter image description here

  • This should be the correct answer.
    – Instein
    Oct 12, 2022 at 16:35
  • @Instein Not necessarily, because a person may need Mouse Reporting enabled for other apps e.g. Vim as mentioned above
    – ptrin
    Jun 27, 2023 at 15:27

I realized if you use Tmux and a session disconnects this happens if you have enabled the mouse on function within Tmux.

I discovered this because I had two terminals open on my server using the same terminal program (Termius on mac). One terminal I was using Tmux and the other one I was not. Tmux had mouse option set to on so I could resize panes, click between windows, etc within Tmux

ONLY the Tmux terminal exhibited this behavior when I reconnected both terminals after the computer had gone to sleep and I reconnected. So upon reconnect the Tmux terminal (even though the reconnected session was not yet attached back to tmux) held onto the mouse aware setting and would insert characters on every click.

There are several fixes. The easiest is to just use the RESET command in the terminal. You can also quit your terminal program completely and restart it then login.

I am looking into setting a bash login to automatically send clear command to the terminal as soon as I log in.


I am using iterm2 and got the same issue. Please go to and uncheck "Session" -> "Terminal State" -> "Mouse Reporting".


When the Terminal (well, one of its ttys, anyway) is not accepting keyboard input in a reliable manner and needs a hard reset, either:

A.) hold down the ⌥ and ⌘ keys, and tap the R key [option-command-r]; or:
B.) Invoke the same action under the "Shell" dropdown menu of Terminal.app:

Terminal Hard Reset


I faced this issue on Windows Terminal. The command line always wrote different weird characters. The solution for me was to open a vim page and close.


and quit vim with

  • 1
    Nice! I discovered that the command vim +q will do it all at once. (So no explicit quitting within vim is necessary.)
    – J-L
    Mar 8, 2022 at 20:04
  • I had to do a similar thing but with tmux Mar 11, 2023 at 0:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .