`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):
Dealing with some minified json, switching to iTerm, doing `pbpaste | json_pp | pbcopy` and having a clean output is _so_ nice.
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
}
`if read -r -t0; then` # returns true if there is data but times out instantly so it doesn't consume any
Is `[ -t 0 ]` more idiomatic? Apparently it fails on this case: function < file
`read -r -t0` is Bash-only though and not POSIX, but it will work regardless of what type of data is on stdin