prevent multi-line paste in bash
This answer is not the most-specific for the user's question Please see my 2nd answer. I am leaving this here because it addresses the more general issue.
Per the comments to your original post, you need (1) a terminal emulator which supports bracketed paste and (2) corresponding support for whatever is running in the terminal, ie, vim
, bash
, zsh
. Terminal emulators supporting bracketed paste (list to be updated based on comments to this post):
xterm
- since ??gnome-terminal
- since ??putty
- since 0.63 (2013-08-06 release date)
Applications supporting bracketed mode:
vim
zsh
For bash
, StéphaneChazelas has put together a shell script to facilitate the detection of that mode and take appropriate action.
A more specific answer -- preventing lines from getting chopped off -- is unanswerable without knowing about the unix program that is running when you hit paste.
A clipboard manager maybe what you need.
Bash now offers the enable-bracketed-paste
option:
enable-bracketed-paste
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. The default is ‘off’.
So add this to ~/.inputrc
:
set enable-bracketed-paste on