You can't paste enter into a Linux terminal


I love my Linux laptop. But, once in a while, it forgets it has a keyboard. I wake it from a little nap and it's all like "no, sir! no keyboards here! just use a mouse please!"

Logging in is pretty simple. Pop_OS has an on-screen keyboard which lets me hunt-n-peck P4ssW0rd123! into the box.

Screenshot of an on screen keyboard at a login prompt. But then I'm stuck. I can launch apps - but I can't type into them.

The on-screen keyboard only seems to work on certain OS elements. It didn't pop up for the Terminal app.

I could have plugged in a USB keyboard. Or even a Yubikey. But where's the fun in that? Similarly, I could have rebooted and manually changed Bash's behaviour. Or done some weird config which turns a middle click into an enter. Or SSH'd in from another machine. But I like a challenge!

So I opened up my browser, clicked to a news story, and then laboriously copied and pasted the letters l s u s b into the terminal. That would show me if my keyboard was stolen by goblins.

But how to run the command? I found a newline on the web page and c&p'd that.

Screenshot of a terminal. The command is pasted in, but there is a newline symbol inserted rather than the output of pressing enter.

Nothing.

And that's how I learned that most modern terminals don't let you paste in an enter. It becomes a newline to stop you automatically running code you shouldn't. This is the default behaviour on Bash since 5.1.

Anyway, there's a long running bug about this intermittently glitchy keyboard behaviour. In future, I'll just reboot.


Share this post on…

  • Mastodon
  • Facebook
  • LinkedIn
  • BlueSky
  • Threads
  • Reddit
  • HackerNews
  • Lobsters
  • WhatsApp
  • Telegram

6 thoughts on “You can't paste enter into a Linux terminal”

  1. Ivan says:

    If the keyboard works in the browser, does it also work if you somehow launch Jupyter and start a browser terminal from there? I think it should either live in the start menu or be launchable from start menu → run command.

    Reply
  2. says:

    URXVT started prompting you when you paste something with control characters a few months (?) back:

    Pasting 1 control characters, continue? (y/p/n)

    "y" strips the control characters but "p" works as you actually want.

    Reply
  3. says:

    This seems to be a terminal emulator specific issue. GNOME Terminal doesn't seem to allow this, but Tilix has an option to enable and disable this.

    As a work around it will only strip newlines if they are leading or trailing characters, so if you copy the last letter of your command, a newline, and a subsequent letter it will execute. You may want a text editor handy to compose this sequence.

    Reply
  4. says:

    Oh and whilst I'm here: Ctrl+J is equivalent to LF. Sadly I don't know how you enter that with a broken OSK 😐

    Reply

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">