3 ms·
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]).
by moonboots 14y ago
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/ 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
- jfr 14y agoCtrl-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.
- moonboots 14y agoThanks, edited my post
- cmsj 14y agoOut 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?
- moonboots 14y agoI 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.
- petepete 14y agoYou might find urxvt-perls useful, amongst the useful things it offers is clipboard interaction. https://github.com/muennich/urxvt-perls https://github.com/muennich/urxvt-perls
- moonboots 14y agoThanks 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.
- jmesserly 14y agoI 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.
- perlgeek 14y agoFirefox 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.
- cmsj 14y agoJust one more reason to abandon the extraordinary towering failure that is Firefox ;)
- philh 14y ago> 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.
- huhtenberg 14y agoCtrl-X + E doesn't appear to be doing anything in bash.
- lelf 14y agoIt's Ctrl-X-E (both with Ctrl)
- moonboots 14y agoThanks, forgot about bash behavior. On Zsh the 'e' doesn't need to be pressed with control.
- huhtenberg 14y agoWoah :)
- cdjk 14y agoEvery 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.
- cschramm 14y agoYeah, 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.
- rgrau 14y agoBeing 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 http://i.imgur.com/AiTFm2R.png Userscript itself in: https://github.com/kidd/org-protocol-github-lines/blob/clone-repo/browser/org-protocol-github-repo.user.js https://github.com/kidd/org-protocol-github-lines/blob/clone...