How to avoid paste of multiline text on ubuntu command line?
up vote
3
down vote
favorite
This question may sound weird. But here is what happened and I'd like to find out the ways to avoid this happening again.
I accidentally pasted contents of a text file into SSH CLI on Ubuntu 16.04. The machine was used for my production setup. I actually copied contents of a log file and intended to paste it in a nano editor opened in some other SSH window, but mistakenly pasted it on command line interface. The shell attempted to process every line as a command and created some junk files in local directory.
This fortunately didn't cause much damage however I want to know is there any way to avoid the accidental paste on ubuntu command line? Or can I disable the command line for multiline inputs?
I use PAC ssh client to connect to my remote systems.
16.04 command-line
add a comment |
up vote
3
down vote
favorite
This question may sound weird. But here is what happened and I'd like to find out the ways to avoid this happening again.
I accidentally pasted contents of a text file into SSH CLI on Ubuntu 16.04. The machine was used for my production setup. I actually copied contents of a log file and intended to paste it in a nano editor opened in some other SSH window, but mistakenly pasted it on command line interface. The shell attempted to process every line as a command and created some junk files in local directory.
This fortunately didn't cause much damage however I want to know is there any way to avoid the accidental paste on ubuntu command line? Or can I disable the command line for multiline inputs?
I use PAC ssh client to connect to my remote systems.
16.04 command-line
2
I'm not familiar with PAC, however maybe you can implement something equivalent to this? Prevent accidental execution of commands in Linux if pasting text containing one or more return characters
– steeldriver
Jul 20 at 11:41
1
That's precisely what I am looking for. Will check if something like that possible for PAC or any other SSH clients on Ubuntu.
– Pawan
Jul 20 at 15:45
2
You might want to google "bracketed paste" as well - see for example prevent multi-line paste in bash
– steeldriver
Jul 20 at 15:49
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
This question may sound weird. But here is what happened and I'd like to find out the ways to avoid this happening again.
I accidentally pasted contents of a text file into SSH CLI on Ubuntu 16.04. The machine was used for my production setup. I actually copied contents of a log file and intended to paste it in a nano editor opened in some other SSH window, but mistakenly pasted it on command line interface. The shell attempted to process every line as a command and created some junk files in local directory.
This fortunately didn't cause much damage however I want to know is there any way to avoid the accidental paste on ubuntu command line? Or can I disable the command line for multiline inputs?
I use PAC ssh client to connect to my remote systems.
16.04 command-line
This question may sound weird. But here is what happened and I'd like to find out the ways to avoid this happening again.
I accidentally pasted contents of a text file into SSH CLI on Ubuntu 16.04. The machine was used for my production setup. I actually copied contents of a log file and intended to paste it in a nano editor opened in some other SSH window, but mistakenly pasted it on command line interface. The shell attempted to process every line as a command and created some junk files in local directory.
This fortunately didn't cause much damage however I want to know is there any way to avoid the accidental paste on ubuntu command line? Or can I disable the command line for multiline inputs?
I use PAC ssh client to connect to my remote systems.
16.04 command-line
16.04 command-line
asked Jul 20 at 11:13
Pawan
15116
15116
2
I'm not familiar with PAC, however maybe you can implement something equivalent to this? Prevent accidental execution of commands in Linux if pasting text containing one or more return characters
– steeldriver
Jul 20 at 11:41
1
That's precisely what I am looking for. Will check if something like that possible for PAC or any other SSH clients on Ubuntu.
– Pawan
Jul 20 at 15:45
2
You might want to google "bracketed paste" as well - see for example prevent multi-line paste in bash
– steeldriver
Jul 20 at 15:49
add a comment |
2
I'm not familiar with PAC, however maybe you can implement something equivalent to this? Prevent accidental execution of commands in Linux if pasting text containing one or more return characters
– steeldriver
Jul 20 at 11:41
1
That's precisely what I am looking for. Will check if something like that possible for PAC or any other SSH clients on Ubuntu.
– Pawan
Jul 20 at 15:45
2
You might want to google "bracketed paste" as well - see for example prevent multi-line paste in bash
– steeldriver
Jul 20 at 15:49
2
2
I'm not familiar with PAC, however maybe you can implement something equivalent to this? Prevent accidental execution of commands in Linux if pasting text containing one or more return characters
– steeldriver
Jul 20 at 11:41
I'm not familiar with PAC, however maybe you can implement something equivalent to this? Prevent accidental execution of commands in Linux if pasting text containing one or more return characters
– steeldriver
Jul 20 at 11:41
1
1
That's precisely what I am looking for. Will check if something like that possible for PAC or any other SSH clients on Ubuntu.
– Pawan
Jul 20 at 15:45
That's precisely what I am looking for. Will check if something like that possible for PAC or any other SSH clients on Ubuntu.
– Pawan
Jul 20 at 15:45
2
2
You might want to google "bracketed paste" as well - see for example prevent multi-line paste in bash
– steeldriver
Jul 20 at 15:49
You might want to google "bracketed paste" as well - see for example prevent multi-line paste in bash
– steeldriver
Jul 20 at 15:49
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Bracketed paste may be what you need. Assuming you are running a terminal that supports it (e.g., xterm, putty, gnome-terminal), and assuming you are running the bash shell, all you have to do is execute this command in each terminal:
set enable-bracketed-paste
You can even put this command at the end of your .bashrc. From that moment on, any stuff you paste into the shell will not be immediately executed, even if it contains newlines. However, if you paste one or more lines and then hit 'enter' manually, all of the lines will be executed - so if you pasted something by mistake and don't want it executed, you must hit 'Ctrl-C' instead of 'enter'.
Caveat 1: bracketed paste will also be enabled for any programs you run in the shell. Many programs don't understand it. So if you run cat
and then paste the word hello
, you will see ^[[200~hello^[[201~
instead. This may not be what you want.
Caveat 2: some programs, such as vi
or emacs -nw
, will disable bracketed paste after they finish running, even if it was turned on before they ran. You could work around this by enabling bracketed-paste with every prompt. One way to do this would be to redefine $PS1
to include the escape sequence $'e[?2004h'
. This may be a bit esoteric.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Bracketed paste may be what you need. Assuming you are running a terminal that supports it (e.g., xterm, putty, gnome-terminal), and assuming you are running the bash shell, all you have to do is execute this command in each terminal:
set enable-bracketed-paste
You can even put this command at the end of your .bashrc. From that moment on, any stuff you paste into the shell will not be immediately executed, even if it contains newlines. However, if you paste one or more lines and then hit 'enter' manually, all of the lines will be executed - so if you pasted something by mistake and don't want it executed, you must hit 'Ctrl-C' instead of 'enter'.
Caveat 1: bracketed paste will also be enabled for any programs you run in the shell. Many programs don't understand it. So if you run cat
and then paste the word hello
, you will see ^[[200~hello^[[201~
instead. This may not be what you want.
Caveat 2: some programs, such as vi
or emacs -nw
, will disable bracketed paste after they finish running, even if it was turned on before they ran. You could work around this by enabling bracketed-paste with every prompt. One way to do this would be to redefine $PS1
to include the escape sequence $'e[?2004h'
. This may be a bit esoteric.
add a comment |
up vote
1
down vote
Bracketed paste may be what you need. Assuming you are running a terminal that supports it (e.g., xterm, putty, gnome-terminal), and assuming you are running the bash shell, all you have to do is execute this command in each terminal:
set enable-bracketed-paste
You can even put this command at the end of your .bashrc. From that moment on, any stuff you paste into the shell will not be immediately executed, even if it contains newlines. However, if you paste one or more lines and then hit 'enter' manually, all of the lines will be executed - so if you pasted something by mistake and don't want it executed, you must hit 'Ctrl-C' instead of 'enter'.
Caveat 1: bracketed paste will also be enabled for any programs you run in the shell. Many programs don't understand it. So if you run cat
and then paste the word hello
, you will see ^[[200~hello^[[201~
instead. This may not be what you want.
Caveat 2: some programs, such as vi
or emacs -nw
, will disable bracketed paste after they finish running, even if it was turned on before they ran. You could work around this by enabling bracketed-paste with every prompt. One way to do this would be to redefine $PS1
to include the escape sequence $'e[?2004h'
. This may be a bit esoteric.
add a comment |
up vote
1
down vote
up vote
1
down vote
Bracketed paste may be what you need. Assuming you are running a terminal that supports it (e.g., xterm, putty, gnome-terminal), and assuming you are running the bash shell, all you have to do is execute this command in each terminal:
set enable-bracketed-paste
You can even put this command at the end of your .bashrc. From that moment on, any stuff you paste into the shell will not be immediately executed, even if it contains newlines. However, if you paste one or more lines and then hit 'enter' manually, all of the lines will be executed - so if you pasted something by mistake and don't want it executed, you must hit 'Ctrl-C' instead of 'enter'.
Caveat 1: bracketed paste will also be enabled for any programs you run in the shell. Many programs don't understand it. So if you run cat
and then paste the word hello
, you will see ^[[200~hello^[[201~
instead. This may not be what you want.
Caveat 2: some programs, such as vi
or emacs -nw
, will disable bracketed paste after they finish running, even if it was turned on before they ran. You could work around this by enabling bracketed-paste with every prompt. One way to do this would be to redefine $PS1
to include the escape sequence $'e[?2004h'
. This may be a bit esoteric.
Bracketed paste may be what you need. Assuming you are running a terminal that supports it (e.g., xterm, putty, gnome-terminal), and assuming you are running the bash shell, all you have to do is execute this command in each terminal:
set enable-bracketed-paste
You can even put this command at the end of your .bashrc. From that moment on, any stuff you paste into the shell will not be immediately executed, even if it contains newlines. However, if you paste one or more lines and then hit 'enter' manually, all of the lines will be executed - so if you pasted something by mistake and don't want it executed, you must hit 'Ctrl-C' instead of 'enter'.
Caveat 1: bracketed paste will also be enabled for any programs you run in the shell. Many programs don't understand it. So if you run cat
and then paste the word hello
, you will see ^[[200~hello^[[201~
instead. This may not be what you want.
Caveat 2: some programs, such as vi
or emacs -nw
, will disable bracketed paste after they finish running, even if it was turned on before they ran. You could work around this by enabling bracketed-paste with every prompt. One way to do this would be to redefine $PS1
to include the escape sequence $'e[?2004h'
. This may be a bit esoteric.
answered Nov 22 at 18:49
Peter Selinger
262
262
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1057855%2fhow-to-avoid-paste-of-multiline-text-on-ubuntu-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
I'm not familiar with PAC, however maybe you can implement something equivalent to this? Prevent accidental execution of commands in Linux if pasting text containing one or more return characters
– steeldriver
Jul 20 at 11:41
1
That's precisely what I am looking for. Will check if something like that possible for PAC or any other SSH clients on Ubuntu.
– Pawan
Jul 20 at 15:45
2
You might want to google "bracketed paste" as well - see for example prevent multi-line paste in bash
– steeldriver
Jul 20 at 15:49