←back to thread

2039 points Gadiguibou | 1 comments | | HN request time: 0.231s | 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 #
pmarreck ◴[] No.36492028[source]
I have linux/macos-agnostic bash functions in my dotfiles that unify this to “clip” and “paste” (since “copy” is too close semantically to “cp”)
replies(2): >>36492092 #>>36493443 #
svieira ◴[] No.36493443[source]
And I have one that unifies _both_ to `clip` so you can put the same command in both sides of the pipe, e. g. to turn a line-delimited blob on your clipboard to a space-separated one:

    clip | tr '\n' ' ' | clip
https://github.com/svieira/dotfiles/blob/a3654d6a194e3689978...

    # Use clipboard in shell pipelines
    # clip | xargs echo           # uses pbpaste
    # ps -A | grep search | clip  # uses pbcopy
    clip() {
      [ -t 0 ] && pbpaste || pbcopy
    }
replies(2): >>36504955 #>>36506140 #
1. pmarreck ◴[] No.36504955[source]
Holy crap. Of course! You win! Amazing!

Simple is genius