Live data from Hacker News

Yank: Yank Terminal Output to Clipboard

github.com

11–20 of 57 posts

Re: Yank: Yank Terminal Output to Clipboard

#11

On Mac OS, a much less powerful but built in tool is `pbcopy`.

Was going to say this myself. I find myself using it (and it’s counterpart, `pbpaste`) surprisingly frequently.

This tool looks great for more involved use cases though I think for most scenarios I’d use it for, using the mouse with iTerm2 with “copy on highlight” might be quicker - can be nice to avoid the mouse though!

Re: Yank: Yank Terminal Output to Clipboard

#13
This is actually a solution to a problem I've been looking at recently. My current experimental answer is using the terminal within Neovim, which is kind of a superset of this in some ways.

I'm wondering if there's a standard way to invoke vim and just get a selection. Might make a good analog for vim users who don't want to commit to using its terminal.

Re: Yank: Yank Terminal Output to Clipboard

#14
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.

also VIM. It is probably that. I guess he could have call it Put. But yank sounds cooler.

Re: Yank: Yank Terminal Output to Clipboard

#17
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 resorting to the following eval, which doesn't alias nicely?

  $(git push 2>&1 | grep git)

Re: Yank: Yank Terminal Output to Clipboard

#18

This is actually a solution to a problem I've been looking at recently. My current experimental answer is using the terminal within Neovim, which is kind of a superset of this in some ways. I'm wondering if there's a standard way to invoke vim and just get a selection. Might make a good analog for vim users who don't want to commit to using its terminal.

With kitty you can map keyboard shortcuts to open the scrollback buffer in an editor. It's super neat and it has pretty much completely replaced using the neovim terminal for me. Below are my mappings for opening the scrollback in the current tab or a new one. What makes the former even better is that after closing it you are back in your regular terminal view.

[0] https://sw.kovidgoyal.net/kitty/launch.html

[1]

  #: You can pipe the contents of the current screen + history buffer as
  #: STDIN to an arbitrary program using the ``pipe`` function. For
  #: example, the following opens the scrollback buffer in less in an
  #: overlay window::
  # map f1 pipe @ansi overlay less +G -R
  map f1 pipe @text tab /usr/local/bin/nvim '+ normal GA' -
  map f2 pipe @text overlay /usr/local/bin/nvim '+ normal GA' -

Re: Yank: Yank Terminal Output to Clipboard

#19

This is actually a solution to a problem I've been looking at recently. My current experimental answer is using the terminal within Neovim, which is kind of a superset of this in some ways. I'm wondering if there's a standard way to invoke vim and just get a selection. Might make a good analog for vim users who don't want to commit to using its terminal.

I'm not quite sure whether I understand what you're trying to say, but this should be close (put into vimrc):

    " bind leader-y and leader-p to clipboard copy/paste
    noremap y "+y
    noremap p "+p
(\y or ,y is easier to use than "+y which is the default binding)

`ps ux | vim -`, go into visual mode and select the stuff you want, then ,y to copy it to the clipboard.

If you don't use a clipboard manager then of course it will be destroyed once you :q out of vim. You could probably add the :q! to the binding to make it automatically exit vim once you 'confirm' (copy) the selection.

Re: Yank: Yank Terminal Output to Clipboard

#20

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 think “thefuck” handles this case really well: https://github.com/nvbn/thefuck
Post reply on HN