Live data from Hacker News

macOS command-line tools you might not know about

saurabhs.org

21–30 of 454 posts

Re: macOS command-line tools you might not know about

#21
post #8

`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.

I find it so annoying that these only work with plain text and RTF. On X11 there is `xclip`[0] and on Wayland there is `wl-clipboard`[1] both of which support binary file formats either through parsing the header or explicitly setting the MIME type.

This means you can do things like copy an image from the terminal and paste it into a graphical program like a browser or chat client and vice-versa. Also can be very useful in shell scripts for desktop automation.

The workaround on MacOS is to use AppleScript via `osascript` to `set the clipboard to...`.

  [0] https://github.com/astrand/xclip
  [1] https://github.com/bugaevc/wl-clipboard

Re: macOS command-line tools you might not know about

#23

pbcopy/pbpaste are a lifesaver when doing stuff on the command line that has a lot of output and piping is not something you can do. networkQuality is something I really wish I knew about sooner.

Also for things like sharing public ssh keys. Instead of "can you send me your public key" and getting something with random line breaks depending on the users text editor I just have to ask them to "cat ~/.ssh/id_rsa.pub | pbcopy".

I also alias pbcopy / pbpaste on Linux too, so useful!

Re: macOS command-line tools you might not know about

#24

I just freaked out my cat using `say`. I'm going to enjoy this too much.

I used to work at a 24 hr end user tech support call center. They didn’t use Macs, but we had a machine for the techs to use to understand what the customer is looking at. I wrote a script to sleep until late at night then start saying weird/creepy stuff to mess with the overnight crew.

Re: macOS command-line tools you might not know about

#28
post #8

`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.

Since you mention both pbcopy and iTerm - I love https://github.com/skaji/remote-pbcopy-iterm2. I do most of the work on a remove Linux server, treating my MacBook as mostly a dumb terminal, and being able to transparently copy from the remove to my local clipboard is so nice.

Re: macOS command-line tools you might not know about

#30
post #8

`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.

If I had a nickel for each `cat foo.json | jq | pbcopy`, I'd be a rich man :)
Post reply on HN