GNU Bashのbracketed pasteの設定

Debian sid amd64環境で最近Bashにテキストを貼り付けると貼り付けた文字列が反転して即時反映されないようになっていました.


/usr/share/doc/bash/changelog.Debian.gz は殆どUpstreamへの追従.
/usr/share/doc/bash/changelog.gz を見るとそれらしいものが載っていました.

bash-4.4-alpha, bash-4.3-release.から Bracketed paste mode が入ったようです.
そしてbash-5.1-alpha, bash-5.0-releaseから既定値になたようです.(そして気づいた)

bash-4.4-alpha, bash-4.3-release.

b. There is a new bindable variable, `enable-bracketed-paste’, which enables
support for a terminal’s bracketed paste mode.

bash-5.1-alpha, bash-5.0-release.

h. Bracketed paste mode is enabled by default.

infoを見ると enable-bracketed-paste という項目で設定できるようです.

info bash
enable-bracketed-paste (On)
       When set to On, readline will configure the terminal in a way that will enable it to insert each paste into the editing buffer as a single string of characters, instead of treating
       each character as if it had been read from the keyboard.  This can prevent pasted characters from being interpreted as editing commands.
info bash
Readline Variables
    Readline has variables that can be used to further customize its behavior.  A variable may be set in the inputrc file with a statement of the form
       set variable-name value
or using the bind builtin command (see SHELL BUILTIN COMMANDS below).


$ bind 'set enable-bracketed-paste off'
$ bind 'set enable-bracketed-paste on'

~/.bashrc 辺りに書いておくと次回のbash起動時に反映されます.

  • byobu-screenでは enable-bracketed-paste on しても利用できない?
  • tmuxでのCtrl+b Ctrl + ] での貼付け時には無視される?
  • Ubuntu 20.10 amd64の5.0-6ubuntu2では既定値で無効になっているけど enable-bracketed-paste on で有効に出来る
$ dpkg-query -W bash
bash    5.1~rc2-1
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m