You are not logged in.
Sometimes I paste a line into a terminal that I want to edit before executing, but because of a newline at the end it gets executed right away. Is there a way to prevent this?
Offline
Try one of these in .xbindkeysrc
"xsel | tr -d '\n' | xsel -i; xdotool click --clearmodifiers 2"
Control + Insert
"xdotool type --clearmodifiers "$(xsel | tr -d '\n')""
Control + Insert
I do not recommend xdotool "key Shift+Insert" instead of "click 2", because the shift can be sticky which could mess up your entire system (I had to restart X, because it made every modifier sticky)
You can also bind to Shift + Insert. (EDIT: but note that you bound it to middle click, so e.g. in a GTK app it will paste in the wrong location)
The second one is non-destructive but won't work with unicode.
Last edited by Procyon (2010-04-18 10:50:33)
Offline
Or you can also, when you copy, be careful not to take the end character of the line.
ktr
Offline
Or if you type a # before pasting a single line then it will be taken as a comment if you accidentally paste the newline.
Offline
Try one of these in .xbindkeysrc
"xsel | tr -d '\n' | xsel -i; xdotool click --clearmodifiers 2" Control + Insert "xdotool type --clearmodifiers "$(xsel | tr -d '\n')"" Control + Insert
I do not recommend xdotool "key Shift+Insert" instead of "click 2", because the shift can be sticky which could mess up your entire system (I had to restart X, because it made every modifier sticky)
You can also bind to Shift + Insert. (EDIT: but note that you bound it to middle click, so e.g. in a GTK app it will paste in the wrong location)
The second one is non-destructive but won't work with unicode.
Thanks.. that looks like the best solution so far.
Offline
With you use urxvt you can edit the source code to remove pasted newlines
--- a/rxvt-unicode-9.07/src/screen.C 2009-12-29 02:16:18.000000000 -0200
+++ b/rxvt-unicode-9.07/src/screen.C 2010-04-18 09:13:11.853162361 -0300
@@ -2676,7 +2676,7 @@
/* convert normal newline chars into common keyboard Return key sequence */
for (unsigned int i = 0; i < len; i++)
if (data[i] == C0_LF)
- data[i] = C0_CR;
+ data[i] = ' ';
if (priv_modes & PrivMode_BracketPaste)
tt_printf ("\e[200~");
I think this can be done with the perl interface of urxvt, so you can have more power (yes, you can set urxvt to call perl commands on key-press) I'm working on this but I cannot found a clean way to get the content of primary clipboard buffer, (only from the internel urxvt buffer via $self->selection, I can cal xsel but this is ugly)
Offline