r/programming • • Oct 15 '20

Don't Copy Paste Into a Shell

https://briantracy.xyz/writing/copy-paste-shell.html
935 Upvotes

213 comments sorted by

View all comments

Show parent comments

5

u/liamnesss Oct 15 '20

Reading about it more, the feature seems to be called "bracketed paste", which wraps the pasted characters so the shell can differentiate them from ordinary keyboard input. If the terminal emulator does not implement this, then surely there is no way for zsh to make this differentiation - which would explain the behaviour I'm seeing.

I've asked a few people this and not got an answer - which terminal emulator are you using in combination with zsh that you've observed this behaviour with?

2

u/Cpcp800 Oct 15 '20

I'll put in my 2c. I've used zsh for years and every emulator I've used has supported bracketed paste. So a small incomplete list would be.

  • Termite

  • (u)Xterm

  • Terminology

1

u/liamnesss Oct 15 '20

Yeah I think I am just a little out of the loop, as I've been mostly using WSL + Windows Terminal for the last year or so. Looks like support for bracketed paste is pretty good across the board with other terminal emulators.

1

u/gmes78 Oct 15 '20

Reading about it more, the feature seems to be called "bracketed paste",

Yeah, I edited my comment to add that.

I've asked a few people this and not got an answer - which terminal emulator are you using in combination with zsh that you've observed this behaviour with?

I tested it now, it works on all the terminal emulators I have installed: Alacritty, Konsole and Terminator. It doesn't work on a tty (using gpm to paste).

2

u/liamnesss Oct 15 '20

I just booted into Ubuntu to test - seems to work with GNOME Terminal. I'm sure that didn't used to be the case! So looks like Windows Terminal is the odd one out - but at least they have the security popup in the meantime, and looks like there is a PR in the works to add proper bracketed paste support.

-3

u/[deleted] Oct 15 '20

... do you know any terminal emulator that doesn't implement that ? Because it is kinda irrelevant complaint

3

u/liamnesss Oct 15 '20

Sure - read my comments again

-9

u/[deleted] Oct 15 '20

So you're just pointlessly whining. Ok.