Since upgrading to 10.13 (I think that was the release), macOS has supported bracketed paste mode. This is extremely annoying, because I frequently find myself getting garbage characters in Bash that I have to then manually delete. And unfortunately, Terminal.app provides no checkbox for disabling that support.

I tried solving the problem by adding

bind 'set-enable-bracketed-paste off'

to my .bash_profile file, which mostly worked, but afterwards, I could no longer type or paste the letter 'p'.

At first, I thought that my keyboard was dying (it's one of the new ones that does), but the problem went away in other apps, and also didn't reproduce in terminal windows where I was ssh'ed into a remote Linux box.

I tried all the obvious things ("stty sane", export TERM=vt100, etc.), but the problem persisted. It was particularly fun trying to edit the .bash_profile file to remove that line without being able to type or paste the letter 'p'. :-)

Now that my keyboard is working again, does anyone have any idea why disabling bracketed paste would cause a single letter to be treated as an invalid character when typed or pasted into Bash on the command line? Is there some obscure config file that might be tweakable to fix this? Is it a buggy version of Bash?

Worth noting: the bug does not occur when running bash as 'sh'. Also, the failure does not appear to depend on the value for that parameter, e.g.

bind 'set-enable-bracketed-paste'
bind 'set-enable-bracketed-paste on'

both cause the 'p' key to stop working as well.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.