In recent Linux distributions, you’ll find that when pasting or drag’n’drop files into terminal, the text is always selected and highlighted.
I was first encountering this issue when working in Ubuntu 21.04. Now, Fedora, Manjaro and many other Linux also have the same ‘issue’. And, I’ve even got used to this terminal behavior.
This is indeed a feature, but not bug!
According to the release note of Bash 5.1, it’s a feature called “active region”:
The most visible new feature is in Readline: the addition of `faces’, which highlights the text between the point and mark (the region, so this is also called the ‘active region’). This was added to show visibly the text inserted by bracketed paste, and also marks the text found by incremental and non-incremental history searches.
If you don’t like this behavior, then the solution is turning off either bracketed paste or active region.
Turn Off Bracketed Paste or Active Region
To turn off this feature, user can simply add a rule into either ‘/etc/inputrc
‘ or ‘.inputrc
‘ file.
1. Firstly, open terminal and run command to get your bash version:
bash --version
2. Then, run command to edit the config file:
- For all system users, run command to edit
/etc/inputrc
file:sudo nano /etc/inputrc
- For current user only, edit the
.inputrc
file in user’s home directory.nano ~/.inputrc
Replace nano
in command with your favorite text editor, such as gnome-text-editor for Fedora, Ubuntu 22.10+, or gedit for Ubuntu 22.04 and earlier.
3. Finally, add a new line into the file and save it.
- For bash 5.1.x, turn off bracketed paste by adding new line:
set enable-bracketed-paste off
- For bash 5.2 and higher, there’s a separate control of the active region. User can disable it while leaving bracketed paste enabled, by adding line:
set enable-active-region off
When done editing the config file, press Ctrl+X, type y and hit Enter to save it!
And, text pasted into terminal will no longer highlighted by default at next login.