Live data from Hacker News

macOS command-line tools you might not know about

saurabhs.org

291–300 of 454 posts

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

#292
post #139

Earlier quoted context omitted.

A tad outdated. At a glance I see it’s missing `networkQuality` (introduced in Monterey) and `realpath` (added in Ventura).

Agreed. Some of the flags are missing as well. Not sure it's updated often, but still not a bad starting point. If only Apple would publish something directly. They do a pretty good job with the Apple Platform Deployment guide ( https://support.apple.com/guide/deployment ). And the Security guide ( https://support.apple.com/guide/security ).

I maintain updated lists here:

https://manp.gs/mac/1/

https://manp.gs/mac/8/

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

#293

Earlier quoted context omitted.

That's a useless use of cat. You can use `jq . foo.json | pbcopy` or `jq < foo.json | pbcopy`.

Is there any shell that has cat as a built-in? Such a shell could remove some of the more common cases.

All of them do. Including bash. It’s just not the same syntax (ie ‘But I honestly think people who try to optimise away ‘cat’ are optimising the wrong thing. If one extra fork() is that detrimental then don’t use a shell scripting language.

For a lot of people, “useless” ‘cat’ enables them to write a pipeline in the order that their brain farts out the requirements for the pipeline. So they’ve optimised for human productivity. And given the human brain is slower than a few extra fork()s, I think optimising for one’s brain makes more sense here.

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

#295
post #3

Neat, I was not aware of `networkQuality`. A good replacement for opening up Speedtest or whatnot when you just want to figure out if the network is slow or something else is up.

I can't find any (official) documentation on how it measures the speed. Against which target?

Edit: Found https://www.macinstruct.com/tutorials/how-to-check-your-macs... which says:

"The networkquality tool uses Apple’s CDN (https://mensura.cdn-apple.com/api/v1/gm/config) as a target"

The contents of this file (for me):

  { "version": 1,
    "test_endpoint": "sesto4-edge-bx-021.aaplimg.com",
    "urls": {
        "small_https_download_url": "https://mensura.cdn-apple.com/api/v1/gm/small",
        "large_https_download_url": "https://mensura.cdn-apple.com/api/v1/gm/large",
        "https_upload_url": "https://mensura.cdn-apple.com/api/v1/gm/slurp",
        "small_download_url": "https://mensura.cdn-apple.com/api/v1/gm/small",
        "large_download_url": "https://mensura.cdn-apple.com/api/v1/gm/large",
        "upload_url": "https://mensura.cdn-apple.com/api/v1/gm/slurp"
     }
  }

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

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

So much of my Linux use is over ssh from a MacOS client that I've made a `pbcopy` executable that just pipes stdin over ssh to my MacBook to its pbcopy (with a dedicated ssh key that runs this as a forced command). Makes it super nice to be on an SSH session and `pbcopy` some content to my MacOS clipboard!

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

#297
post #281

Earlier quoted context omitted.

I love this flow! Such a powerful and clean way to solve text issues. # This will remove Windows double-spaced empty lines from your copy/paste buffer alias winlines="sed '/^$/{$!{N;s/\n//;};}'" # pbw = [P]aste [B]uffer to fix [W]indows line endings alias pbw="pbpaste | winlines | pbcopy" Also - if you want `pbpaste` and `pbcopy` on Linux... # imitate MacOS's paste buffer copy/paste: alias pbcopy='xsel --clipboard --…

There's `wl-copy` and `wl-paste` for Wayland users too, via https://github.com/bugaevc/wl-clipboard

And `cb` which works cross-platform, via https://github.com/Slackadays/clipboard

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

#298

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!

Fwiw, `clip` on Windows does the same as `pbcopy` (there's no analog to pbpaste built in though)

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

#300
The `security` tool is handy too. I like the ability to store passwords in the `login` Keychain and automate using them in the terminal using `security find-generic-password`.

    security find-generic-password -gw -l "${keychain_id}"
Super helpful for VPN automation scripts, easy logins to things like Vault, etc. The security tool has tons of other handy functions as well.
Post reply on HN