This page looks best with JavaScript enabled

Bracketed-paste problems in Bash-5.1

 ·  🎃 kr0m

In the latest version of Bash, I have experienced a certain problem where pasting from the middle mouse button does not work correctly. It pastes the text but does not execute the ENTERs. The version of Bash involved in my case is bash-5.1.4_1.

Apparently, the problem is in the new way of pasting text, the so-called “Bracketed paste mode” which is enabled by default.

If I paste an “ls -la\n” in the console, it pastes the text but waits for us to press ENTER to execute the command:

The solution to make it behave as usual is to edit our Bash configuration to execute the command bind ‘set enable-bracketed-paste off’ when the session is interactive. This way it will behave as we want without causing problems when running non-interactive scripts.

vi .bashrc

if [[ $- == *i* ]]; then
 bind 'set enable-bracketed-paste off'
fi

Exit the terminal and restart it so that the shell re-reads the configuration.

If you liked the article, you can treat me to a RedBull here