←back to thread

2039 points Gadiguibou | 1 comments | | HN request time: 0.396s | source
Show context
klausa ◴[] No.36491947[source]
`pbcopy` and `pbpaste` are one of my most-loved in the list.

Dealing with some minified json, switching to iTerm, doing `pbpaste | json_pp | pbcopy` and having a clean output is _so_ nice.

replies(28): >>36492008 #>>36492015 #>>36492028 #>>36492101 #>>36492108 #>>36492229 #>>36492265 #>>36492890 #>>36492953 #>>36493037 #>>36493127 #>>36493336 #>>36493457 #>>36493802 #>>36494023 #>>36494242 #>>36494325 #>>36495379 #>>36495894 #>>36496866 #>>36497033 #>>36497293 #>>36497589 #>>36497973 #>>36498181 #>>36498558 #>>36498586 #>>36535798 #
escot ◴[] No.36497589[source]
I use the following to edit contents of my clipboard:

    pbpaste | vipe | pbcopy

Where vipe is a util for inserting your editor (vim) in the middle of a pipe. From: https://joeyh.name/code/moreutils/
replies(1): >>36502278 #
rasen58 ◴[] No.36502278[source]
This is great utility I didn't know about! Thanks!

But do you know why it doesn't seem to work with the `pbfilter` function?

If I do directly `pbpaste | vipe | pbcopy`, then it opens vim and the clipboard text is pasted there. But if I run `pbfilter | vipe`, then vim opens with a blank buffer.

   function pbfilter() {
      if [ $# -gt 0 ]; then
          pbpaste | "$@" | pbcopy
      else
          pbpaste | pbcopy
      fi
   }      

It seems that the number of args is 0 for some reason
replies(1): >>36502450 #
1. nneonneo ◴[] No.36502450[source]
I think you have to use `pbfilter vipe`, as the argument to pbfilter is inserted into the middle of the pipe.