Live data from Hacker News

Yank: Yank Terminal Output to Clipboard

github.com

21–30 of 57 posts

Re: Yank: Yank Terminal Output to Clipboard

#21

The final example `yank -- xsel -b` is probably the most directly useful for me, but it still doesn't solve the following problem which irritates me to all hell: $ git push fatal: The current branch new has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin new Is there any sane way to copy the perfectly formatted `git push -u` command shown above without…

You can also just do

  git push -u origin HEAD

Re: Yank: Yank Terminal Output to Clipboard

#24

The final example `yank -- xsel -b` is probably the most directly useful for me, but it still doesn't solve the following problem which irritates me to all hell: $ git push fatal: The current branch new has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin new Is there any sane way to copy the perfectly formatted `git push -u` command shown above without…

I have the following alias which simply parses the branch name and passes with carts

  alias gpsu='git rev-parse --abbrev-ref HEAD | xargs git push --set-upstream origin'

Re: Yank: Yank Terminal Output to Clipboard

#25
post #16

Earlier quoted context omitted.

“| clip.exe” should work

That works outside WSL2, not inside, right?

clip.exe works to and from WSL 2.

But if you run VcXsrv you can use the native Linux clipboard and have it shared between WSL 2 and Windows. This is what I do because then tools like Vim, the pass utility and other command line tools can write to and read from the native Linux clipboard and everything will work out of the box.

If you wanted to reproduce pbcopy / pbpaste in native Linux or WSL 2 you can set up aliases for:

    alias pbcopy="xclip -selection clipboard"
    alias pbpaste="xclip -o"
And in case you don't already have xclip installed in WSL 2, you can apt-get install xclip or use whatever package manager you have. I can't remember if xclip is installed by default in WSL 2 distros.

Re: Yank: Yank Terminal Output to Clipboard

#26
Useful tool indeed, thanks for sharing. I use clipper[1], which delivers a similar function through a different implementation. What I like about that one is that with right config you can also pipe output from remote servers back into your machine's clipboard, which is quite handy in so many situations.

[1] https://github.com/wincent/clipper

Re: Yank: Yank Terminal Output to Clipboard

#27
Similarly, if you're using tmux there is the very handy tmux-fingers[1] plugin that kind of works like the vim-shortcut browser addons but inside tmux.

You initialize the plugin and it shows you hints of what to copy, you press the wanted key and it copies the text next to the hint. Works with bunch of things (hashes, urls, numbers) and usually highlights what I want to copy, otherwise tmux with it's normal keyboard shortcuts work fine to manually select things.

- [1] https://github.com/Morantron/tmux-fingers

Re: Yank: Yank Terminal Output to Clipboard

#29
post #9
post #8

Very cool tool! Two immediate thoughts: one, the naming had me confused for a while. The only place I've seen the word "yank" in computing is in Emacs context, where it means "paste", not "copy"... Two, natural extension of this idea is "interactively select and transform data in the pipe". I think existing text editors would be natural fit for this, especially if configured with some conveniences (like field-based n…

> The only place I've seen the word "yank" in computing is in Emacs context, where it means "paste", not "copy"... This is a confusing difference between Emacs and Vim. Emacs uses it for pasting, Vim uses it for copying.

How did the Emacs developers ever thought "yank" would convey the meaning of "paste"?

(Legitimate question. I'm aware some UX faux-pas do happen, but I don't see how)

Re: Yank: Yank Terminal Output to Clipboard

#30
post #5

You can do this with tmux too. ~/.tmux.conf: # export to clipboard. bind-key > run-shell -b 'tmux save-buffer - | xclip' # paste from clipboard. bind-key (edit: my actual setup is slightly different. It interacts with a Windows clipboard via ssh where the terminal is running. cf. https://github.com/euske/pyrexecd/blob/master/tools/tmux.con... )

You could also use `xclip -selection clipboard` if you wanted it to end up in your clipboard (so you can use ctrl-v to paste) instead of in your primary selection (the one where highlighting text copies and middle click pastes).
Post reply on HN