18

Despite some effort, I have been unable to get the "bracketed paste" feature of Bash working.

My terminal is xterm, which supports it. My version of bash is 4.3.33(1)-release, which I think supports it, based on the date of this thread.

I have tried enabling it in a session with:

bind 'set enable-bracketed-paste on'

but that didn't seem to work.

I tried adding to my .inputrc:

set enable-bracketed-paste on

but also no luck.

This very nice feature seems to be very poorly documented, so I have had trouble finding information...

This good overview page says "...if anyone knows a better fix for bash users than 'switch to zsh', I'd like to include it here." But that page is dated before the change was made in Bash (see the thread mentioned above).

Has anyone had luck with Bash, here? What magic am I missing?

EDIT:

I see at this link that bracketed paste might not be available until readline 7.0. I currently have 6.3. Maybe that explains it? I'm not sure how that squares with the original Bash thread, which had a patch to readline...

jwd
  • 10,837
  • 3
  • 43
  • 67

1 Answers1

18

Welp, it works now (:

Bash 4.4, with readline 7.0, supports bracketed paste.

Enable in your session:

$ bind 'set enable-bracketed-paste on'

Or permanently in your .inputrc:

set enable-bracketed-paste on
jwd
  • 10,837
  • 3
  • 43
  • 67
  • Is this backward compatible, or is there a way to make it so? – Tom Hale Jul 08 '19 at 05:29
  • @TomHale: I'm not sure what you're asking, exactly. Do you mean make this feature available in pre-4.4 versions of Bash? In that case, not easily (that would be back*porting*). The reason it's a new version is because it has new code to support this. If you really mean backward *compatible*; what is the incompatibility with the current behavior? – jwd Jul 10 '19 at 20:54
  • If readline prior to v7.0 reads the .inputrc directive, does it error, warn or ignore? I'm thinking about backward compatible dotfiles. – Tom Hale Jul 11 '19 at 02:43
  • 1
    Ah, understood. It gives a warning, from what I see. You can test this yourself by running `bind 'set foobar on'` at the commandline or adding the line `set foobar on` to your .inputrc. In both cases, a warning is printed, but it otherwise succeeds. If you don't like the warning, you could do it in your `.bashrc` rather than `.inputrc`, and make it conditional upon something like `bind -v | grep enable-bracketed-paste`. – jwd Jul 11 '19 at 19:26