この文書の現在のバージョンと選択したバージョンの差分を表示します。
— |
unix:bash:tips [2020/11/11 09:32] (現在) matoken 作成 |
||
---|---|---|---|
ライン 1: | ライン 1: | ||
+ | |||
+ | ## Bracketed pasteの有効化,無効化 | ||
+ | |||
+ | 最近のDebian sidのbashでテキスト貼付けすると反転で貼り付けられて即時反映されないようになった | ||
+ | 改行込みのテキストで想定外のコマンド実行が抑制されたり確認してから実行できる(実行したつもりでぼーっと待つことも) | ||
+ | |||
+ | /usr/share/doc/bash/CHANGES.gz 見ると Bracketed paste という機能でBash 5.1あたりから規定値で有効になるぽい | ||
+ | |||
+ | ``` | ||
+ | $ zgrep -i 'bracketed paste' -n /usr/share/doc/bash/CHANGES.gz | ||
+ | 14:a. Terminals that are named "dumb" or unknown do not enable bracketed paste | ||
+ | 17:b. Ensure that disabling bracketed paste turns off highlighting the incremental | ||
+ | 588:b. Bracketed paste mode works in more places: incremental search strings, vi | ||
+ | 601: inserted by a bracketed paste (the `active region') and the text found by | ||
+ | 606:h. Bracketed paste mode is enabled by default. | ||
+ | 863:d. If using bracketed paste mode, output a newline after the \r that is the | ||
+ | 1316:v. Fixed a problem with exiting bracketed paste mode on terminals that assume | ||
+ | 1317: the bracketed paste mode character sequence contains visible characters. | ||
+ | 2437: support for a terminal's bracketed paste mode. | ||
+ | ``` | ||
+ | |||
+ | infoを見ると `enable-bracketed-paste` で設定できるよう | ||
+ | |||
+ | ``` | ||
+ | $ info bash 2>/dev/null | grep enable-bracketed-paste -A 2 | ||
+ | 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. | ||
+ | |||
+ | ``` | ||
+ | |||
+ | 以下のようにしてアドホックに設定できた | ||
+ | |||
+ | ``` | ||
+ | $ bind 'set enable-bracketed-paste on' | ||
+ | $ bind 'set enable-bracketed-paste off' | ||
+ | ``` | ||
+ | |||
+ | `~/.bashrc` に書いておく | ||
+ | |||