Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] pasted text keeps highlighted in terminal
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
xyxx
n00b
n00b


Joined: 14 Apr 2021
Posts: 7

PostPosted: Fri May 14, 2021 10:45 pm    Post subject: [solved] pasted text keeps highlighted in terminal Reply with quote

Hello Gentoo community,

I have a weird issue about copying and pasting in terminal. I sometimes copy commands from browser and then paste them into terminal; or just use double click and middle button within terminal to do this. Usually there's no highlight on pasted text. But now the pasted text keeps highlighted until new input from keyboard. Neovim and nano are not affected.

Last night I tried Clear Linux (the official kvm image) in qemu, and I noticed this issue immediately after I quit qemu. Could it be some bug related to qemu/kvm?

I'm using alacritty on X11. No desktop environment. WM is bspwm. I thought it might be some bug of alacritty, so I re-emerged it, no success. Then I emerged st (terminal from suckless.org) but st also has this issue.

Or could it be a new feature from certain recently updated package? If so I'd rather turn it off...

I have no idea how to fix because I don't even know what caused this... I hope someone could help me solve this problem. thanks.
_________________
Ich bin eine Maus.


Last edited by xyxx on Sat May 15, 2021 12:38 am; edited 1 time in total
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 2571
Location: Here and Away Again

PostPosted: Fri May 14, 2021 11:55 pm    Post subject: ><)))°€ Reply with quote

Probably 'bracketed paste' that was enabled in 'readline' a while ago.

See for example: https://forums.gentoo.org/viewtopic-t-1129137.html
_________________
Kindest of regardses.
Back to top
View user's profile Send private message
xyxx
n00b
n00b


Joined: 14 Apr 2021
Posts: 7

PostPosted: Sat May 15, 2021 12:38 am    Post subject: Reply with quote

Hi Chiitoo,

thank you, this is exactly the answer! However in the linked post, Ant P. wrote

Quote:
Put "set enable-bracketed-paste off" in inputrc. Doing this may be a security risk.


Then I searched and found this question on Security StackExchange: https://security.stackexchange.com/questions/39118/how-can-i-protect-myself-from-this-kind-of-clipboard-abuse

So it's actually a feature not a bug. Now I think I'd better keep this...
_________________
Ich bin eine Maus.
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 2571
Location: Here and Away Again

PostPosted: Sat May 15, 2021 12:49 am    Post subject: Reply with quote

Indeed, that is pretty much what I hoped for you to get from it. :]

I, too, found it weird at first, but now I actually like it, and prefer it, mostly due to sometimes having accidentally pasted multiple lines of what-have-you into a terminal...
_________________
Kindest of regardses.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21607

PostPosted: Sat May 15, 2021 2:31 am    Post subject: Reply with quote

Bracketed paste is a good thing. The highlighting mode, which is unfortunately controlled by the same flag, is more of a mixed bag. Some people dislike it for good reason, and cannot get rid of it without giving up bracketed paste.
Back to top
View user's profile Send private message
Syl20
l33t
l33t


Joined: 04 Aug 2005
Posts: 619
Location: France

PostPosted: Tue Jun 22, 2021 10:00 am    Post subject: Reply with quote

Hu wrote:
Bracketed paste is a good thing.

I don't think so.

Since... er... many years, I systematically add some "secure" aliases into my bashrc. Like :
Code:
alias rm='rm -iv'
alias mv='mv -iv'

and so on. And what happened ? Now, I systematically use "rm -f", to bypass the "-i" behaviour. All the time. Automatically. The cure is worse than the disease.

With this new "we protect you from yourself" feature, my new reflex is to systematically hit the return key. All the time. Automatically. Because I massively use pasted commands, and that behaviour makes me waste lots of time.
Back to top
View user's profile Send private message
qsmodo
Tux's lil' helper
Tux's lil' helper


Joined: 20 Jun 2021
Posts: 82

PostPosted: Tue Jun 22, 2021 2:00 pm    Post subject: Reply with quote

Syl20 wrote:
With this new "we protect you from yourself" feature, my new reflex is to systematically hit the return key. All the time. Automatically. Because I massively use pasted commands, and that behaviour makes me waste lots of time.


With bracketed past, if the copied ext contains hidden control characters, they will be obvious when pasting into the terminal. And it won't auto-execute the command if contains a newline character. You have a choice to not hit Return blindly or not. For those who use it appropriately, bracketed paste is positively, objectively an improvement.
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Tue Jun 22, 2021 6:24 pm    Post subject: Reply with quote

The point of it being a reflex explicitly makes it not a choice. It is the CLI version of clicking 'OK' in Windows and what most people seemingly complained about in Vista with its User Account Control.

I've gotten into the habit of using -i with cp and mv. I sometimes find myself hitting return too quickly, particularly if I'm doing a lot of work with file management. I've always disliked having to use -f with rm, and I become slightly "anxious" when I think about using -r (and "less slightly" when I do use it). These and similar commands seem like they'd benefit most from --pretend or --dry-run.

Having bracketed past is an objective security "good." That doesn't mean its implementation is objectively good.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21607

PostPosted: Wed Jun 23, 2021 1:44 am    Post subject: Reply with quote

Syl20 wrote:
Hu wrote:
Bracketed paste is a good thing.
I don't think so.

Since... er... many years, I systematically add some "secure" aliases into my bashrc. Like :
Code:
alias rm='rm -iv'
alias mv='mv -iv'
and so on. And what happened ? Now, I systematically use "rm -f", to bypass the "-i" behaviour. All the time. Automatically. The cure is worse than the disease.
I always remove those aliases as soon as I find them, because certain distributions are very bad about shipping those as defaults. I consider it better to just remove the alias outright, rather than always append a -f.
Syl20 wrote:
With this new "we protect you from yourself" feature, my new reflex is to systematically hit the return key. All the time. Automatically. Because I massively use pasted commands, and that behaviour makes me waste lots of time.
You use paste much more than I do. I find the bracketed paste to be almost always a positive, because I rarely paste a command in a ready-to-execute form. My pastes into a terminal fall into three categories:
  • Accidental due to an over-sensitive touchpad. Rare, but irritating.
  • Intentional partial command. Bracketed paste mode would have no effect here. I will finish out the command by hand, then execute it.
  • Intentional full command. Bracketed paste inhibits this running automatically. Usually, I like that I get a last chance to review it before it executes. This helps if the command was copied from a web page, as the browser may not have copied exactly the sequence I wanted (e.g. trailing garbage characters may have slipped in).
If you paste commands as much as you say, you should disable bracketed paste. Although, I would also question your workflow. What are you doing that you paste so much? Would you be better off storing these commands in scripts that you can run?
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2961
Location: Edge of marsh USA

PostPosted: Wed Jun 23, 2021 2:34 am    Post subject: Reply with quote

I like it, but it would have been a capital opportunity to broadcast the change in news rather than having to discover it through trial error.

I always alias cp, mv, and rm with cp -i, mv -i, rm -i. Those are life savers. I also have excellent backups.
_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
Syl20
l33t
l33t


Joined: 04 Aug 2005
Posts: 619
Location: France

PostPosted: Tue Jul 13, 2021 10:43 am    Post subject: Reply with quote

Hu wrote:
What are you doing that you paste so much? Would you be better off storing these commands in scripts that you can run?

For example, I replaced ntp by chrony on my seven boxes recently. About a dozen of commands, some with interactions, et some without. Unique usage.
I think seven boxes isn't enough to use softwares like ansible or puppet, that require some "scripting" for each task anyway. But it's enough to be bored when doing the same task on all of them. So I make the changes on one "test" box, and I copy-paste the commands into the others boxes' terminals.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21607

PostPosted: Wed Jul 14, 2021 1:14 am    Post subject: Reply with quote

For that many systems, I would have written up a straight-line script, probably with no error handling, but just collecting up the commands to be pasted. Then scp it to all the systems, and run it. Alternatively, I might have copied that into a tmux copy buffer and pasted from there. If the paste is done without -p, then tmux will not generate the bracketed-paste wrapper characters, and the receiving shell will treat it as typed.
Back to top
View user's profile Send private message
turtles
Veteran
Veteran


Joined: 31 Dec 2004
Posts: 1655

PostPosted: Tue Aug 03, 2021 2:52 am    Post subject: Re: ><)))°€ Reply with quote

Chiitoo wrote:
Probably 'bracketed paste' that was enabled in 'readline' a while ago.

See for example: https://forums.gentoo.org/viewtopic-t-1129137.html



https://security.stackexchange.com/questions/39118/how-can-i-protect-myself-from-this-kind-of-clipboard-abuse
Very cool new feature I tried to run the first echo command from that post
my terminal gave me a warning popup "The text you're trying to paste contains hidden control characters, do you want to filter them out?"
_________________
Donate to Gentoo
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum