17

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 ?

1
  • I would look through ~/.bashrc: it contains a lot of definitions for customized behaviour (already pre-set by the Ubuntu release). There are code comments explaining what is what. Maybe you can spot something there?
    – Levente
    Apr 26, 2021 at 21:55

4 Answers 4

12

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.

4
  • From your linked post, does .inputrc have to reside in the user's home directory? Is there a way to make this "fix" global for all users and all terminal windows?
    – Enterprise
    May 16, 2021 at 14:06
  • I just saw your comment on Bug #1926256 about not disabling this globally.
    – Enterprise
    May 16, 2021 at 14:31
  • Beginning with bash 5.2, the shell can be configured to use custom colors for the pasted text. See bugs.launchpad.net/ubuntu/+source/bash/+bug/1926256 comment 22.
    – egmont
    May 17 at 13:01
  • The main issue isn't the highlighting but the fact that it repeatedly overwrites the clipboard whilst multitasking.
    – Xen
    Sep 15 at 4:56
3

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.

6
  • N0rbert, I thought this was a setting. It is disappointing that this is a bug, but good to know that it has been acknowledged and will be fixed. I also noticed the Ctrl+Shift+A issue, but thought it was a side-effect of this problem. Nevertheless, you read my mind. I will be sure to mark myself as impacted by both of the above bugs.
    – Enterprise
    Apr 27, 2021 at 13:19
  • This is a completely wrong answer; I've explained why in the linked bugreport.
    – egmont
    May 13, 2021 at 22:26
  • Someone changed the defaults. This matters, @egmont .
    – N0rbert
    May 14, 2021 at 11:39
  • Indeed it matters, although it was obvious from OP's question. Your blaming the terminal, however, was incorrect. I see that now you've edited your answer to fix it, thanks for that!
    – egmont
    May 14, 2021 at 19:34
  • N0rbert, I appreciate you taking the time to create the two bug reports. I've marked myself impacted; let's see where it goes. Also, the behavior in Bug #1922276 remains after applying the "fix" @FedonKadifeli suggested, so this may indeed be unrelated.
    – Enterprise
    May 16, 2021 at 14:12
2

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

1
  • All this good, but it is not expected. Some developers change the defaults. It would be better if these smart developers will do this for us. Moreover the above is not universal solution - it will not work for MATE Terminal, Xfce Terminal and so on.
    – N0rbert
    May 17, 2021 at 6:22
1

To get rid of this globally, add set enable-bracketed-paste off at the end of the /etc/inputrc.

Creating a .inputrc file in the home directory may cause some strange behavior, such your Home button stop working in terminal.

3
  • Please do not disable bracketed paste mode, do not recommend to others to do it. Bracketed paste mode is an important security measure against accidental malicious pastes. In bash 5.1 you can just get used to the current weird behavior or change the terminal's highlight colors, as per another answer here. In bash 5.2 you can also configure the shell's bracketed paste colors, see e.g. bugs.launchpad.net/ubuntu/+source/bash/+bug/1926256 comment 22.
    – egmont
    May 17 at 12:59
  • @egmont I only use the server version of Linux and mostly access it with PuTTY for several years, and I don't remember making an accidental copy-paste any "malicious" and/or "harmful" commands. In my case, this feature has been more of a nuisance than a help. Anyway, I'll leave the answer for anyone who wants to disable it because it took me a while to find a solution that worked. It's up to each individual to decide whether they will disable this feature or not, depending on their needs. May 31 at 21:45
  • The main issue isn't the highlighting but the fact that it repeatedly overwrites the clipboard whilst multitasking.
    – Xen
    Sep 15 at 4:57

You must log in to answer this question.

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