News for hackers. Stuff that matters.
Re:Don't Copy-Paste from Website to Terminal by moonboots on Sunday April 07, 2013 @03:32PM (#5508341)
Bash and Zsh provide shortcuts to open a text editor where commands can be pasted and edited before running (Ctrl-x Ctrl-e in bash, need to enable in zsh [2]). I've been using this on Linux not for security but because I'm still confused by X11's primary and clipboard selections [1]. It seems like every time I try to paste a github repo link, I get the last chunk of code I copied and vice versa.

[1] http://www.nongnu.org/autocutsel/

[2] Sample .zshrc to map edit-command-line to Ctrl-x e:

  autoload edit-command-line
  zle -N edit-command-line
  bindkey '^Xe' edit-command-line
edit: fixed shortcut for bash

edit: forgot about my .zshrc

Re:Don't Copy-Paste from Website to Terminal by cmsj on Sunday April 07, 2013 @03:34PM (#5508350)
Out of interest, what is confusing? If you select text it always goes into the selection buffer. If you also press the clipboard copy shortcut (so, Ctrl-C most of the time, sometimes Ctrl-Shift-C in a terminal) the selection is copied into the clipboard buffer.

Ctrl-V (or, again, sometimes Ctrl-Shift-V in a terminal) pastes the clipboard buffer. Middle mouse button (or shift-Insert) pastes the selection buffer.

Is there still room for confusion?

Re:Don't Copy-Paste from Website to Terminal by perlgeek on Sunday April 07, 2013 @04:21PM (#5508576)
Firefox causes additional confusion by rebinding Ctrl+Insert to what Ctrl+v usually does (copying the clipboard buffer, not the selection buffer).

Also there are some cases where javascript which selects text for you causes very unintuitive behavior wrt selection buffer.

Re:Don't Copy-Paste from Website to Terminal by cmsj on Monday April 08, 2013 @04:27AM (#5510557)
Just one more reason to abandon the extraordinary towering failure that is Firefox ;)
Re:Don't Copy-Paste from Website to Terminal by jmesserly on Sunday April 07, 2013 @03:55PM (#5508465)
I think "confusing" in this context doesn't mean that the concepts are hard to enumerate or understand, it means they're hard to apply with low error rate in a practical setting.

I don't have a problem with X selection+paste if I'm just using Linux. But using it when connected to a remote machine via various remoting technologies (NX, Chrome Remote Desktop), and then mix in that the host machine is a Mac with its terrible command/control split, and the result is pretty confusing.

Re:Don't Copy-Paste from Website to Terminal by moonboots on Sunday April 07, 2013 @03:45PM (#5508417)
I use rxvt and never figured out how to paste the clipboard buffer, so I use shift-insert to paste the primary buffer. Unfortunately, the primary buffer can be overwritten without my consent, e.g. an autofocused web input field.

Vim and emacs also have their own shortcuts for accessing the clipboard buffer.

Re:Don't Copy-Paste from Website to Terminal by petepete on Sunday April 07, 2013 @03:50PM (#5508445)
You might find urxvt-perls useful, amongst the useful things it offers is clipboard interaction.

https://github.com/muennich/urxvt-perls

Re:Don't Copy-Paste from Website to Terminal by moonboots on Sunday April 07, 2013 @03:59PM (#5508487)
Thanks for the link. I'll find a place for uxvrt-perls in my hacky copy-paste workflow. I'm currently using tmux paste buffers and shell functions around xclip to move around text.
Re:Don't Copy-Paste from Website to Terminal by philh on Sunday April 07, 2013 @08:37PM (#5509389)
> If you select text it always goes into the selection buffer.

But as far as I can tell, if text is selected for you that's not always true. I sometimes have difficulty with text boxes which insist on self-selecting as soon as I click them, and which I just can't seem to pull into the selection buffer.

Github doesn't seem to have this issue, but I had recently when trying to get a google maps permalink, for example.

Re:Don't Copy-Paste from Website to Terminal by cschramm on Monday April 08, 2013 @02:40AM (#5510287)
Yeah, copying GitHub URLs sucks. You cannot actually select it with your mouse, since some creepy JavaScript interferes and selects it for you. the result is that it's selected, but not copied to PRIMARY, as you'd expect. I fall into this trap every single time.
Re:Don't Copy-Paste from Website to Terminal by rgrau on Monday April 08, 2013 @06:09AM (#5510857)
Being pissed off as I always fall into the trap, last week I wrote a userscript that adds a 'clone' button to gh webs.

Combined with xdg-open, I clone the repos locally just clicking the 'Clone' link.

http://i.imgur.com/AiTFm2R.png

Userscript itself in: https://github.com/kidd/org-protocol-github-lines/blob/clone...

Re:Don't Copy-Paste from Website to Terminal by jfr on Sunday April 07, 2013 @04:59PM (#5508736)
Ctrl-x e in zsh is '_expand_word'. The function you are talking about is 'edit-command-line', which is not loaded or bound to any key by default in zsh. You have to load it manually.
Re:Don't Copy-Paste from Website to Terminal by moonboots on Sunday April 07, 2013 @05:07PM (#5508768)
Thanks, edited my post
Re:Don't Copy-Paste from Website to Terminal by cdjk on Sunday April 07, 2013 @08:28PM (#5509371)
Every once in a while I think I have my shell environment set up exactly the way I want it. Then I find out about something like this - thanks for the tip.
Re:Don't Copy-Paste from Website to Terminal by huhtenberg on Sunday April 07, 2013 @03:35PM (#5508357)
Ctrl-X + E doesn't appear to be doing anything in bash.
Re:Don't Copy-Paste from Website to Terminal by lelf on Sunday April 07, 2013 @03:40PM (#5508386)
It's Ctrl-X-E (both with Ctrl)
Re:Don't Copy-Paste from Website to Terminal by moonboots on Sunday April 07, 2013 @03:46PM (#5508427)
Thanks, forgot about bash behavior. On Zsh the 'e' doesn't need to be pressed with control.
Re:Don't Copy-Paste from Website to Terminal by huhtenberg on Sunday April 07, 2013 @03:50PM (#5508443)
Woah :)