Pasted text in Gnome Terminal in 21.04 is always highlighted

In Ubuntu 21.04, when text is pasted into Gnome Terminal, the text is always highlighted.

  • It appears as if the text is selected, but it is only highlighted.
  • If you right-click on this highlighted text, the "Copy" option is actually disabled.
  • Clicking in the terminal or clicking on the highlighted text does not un-highlight the text.
  • The only way to un-highlight the pasted text is to type a key.
  • If you try to select the highlighted text by clicking and dragging the mouse pointer, the text color actually inverts, and the text looks like it is not selected, when it in fact is selected. enter image description here

This confusing behavior is not present in Ubuntu 20.04.

  • In Ubuntu 20.04, when text is pasted into Gnome Terminal, the text is not highlighted.
  • Then, selecting the text highlights it, as expected. enter image description here

How to revert this confusing behavior of Gnome Terminal in Ubuntu 21.04, so it behaves like Gnome Terminal in Ubuntu 20.04 ?


Solution 1:

I also noticed this behavior after upgrade to 21.04. Don't think this as a bug: It is a new "default setting" in Bash 5.1.

First check:

$ bind -v | grep bracketed
set enable-bracketed-paste on

Then, try to disable (for the current session):

$ bind 'set enable-bracketed-paste off'
$ bind -v | grep bracketed
set enable-bracketed-paste off

And retry your findings in that terminal session. This is also explained in: https://stackoverflow.com/questions/35611134/bash-bracketed-paste-is-it-supported

I would suggest living with this new default setting of Bash, since it prevents the accidental middle-clicking or copy/pasting of multiple lines (consisting of possibly malicious commands) from the clipboard.

Solution 2:

This is a new "feature" in Bash. Should be reverted to previous defaults as soon as possible, IMO.

I'm seeing this bug in default MATE Terminal on fresh installation of 21.04 too,

screencast

so I have reported it to launchpad as bug 1926256 . Please mark yourself as affected by this bug and add a comment about GNOME Terminal use-case.

Solution 3:

As suggested here, you can change the Gnome Terminal highlight color to something other than white, so it does not conflict with the "bracketed paste" feature of bash.

  1. Click on the header bar menu button in Gnome Terminal

    Click "Preferences"

    Under "Profile" in the left pane, select your profile (i.e. "Unnamed")

    Click the "Colors" tab

  2. Check-mark "Highlight Colors"

  3. Click the Background color box (the second box)

  4. Enter the hexadecimal value for the highlight color you want to use.

    You may want to chose one of the colors from the official Ubuntu Color Pallet:

    • Aubergine... #924D8B
    • Ubuntu Orange... #E95420
    • Light Orange... #F29879
  5. Click the Select button to apply your change.

After making this change:

  • The "bracketed paste" text will be highlighted in white, per the changes to bash.

    (See "AND THIS IS PASTED" text in the screenshot).

  • Text that you select using gnome-terminal will be your chosen color from step 4 above.

    (See "THIS IS SELECTED" text in the screenshot).

Changing Gnome Terminal Highlight Background Color