Live data from Hacker News

macOS command-line tools you might not know about

saurabhs.org

301–310 of 454 posts

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

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

alias pbg='pbpaste | fgrep --color -i "`pbpaste -pboard find`"' select all in a terminal window with pages of log data and cmd-c copy; find the one phrase you want to find in that data and cmd-e to put it in the find pasteboard; cmd-n new window, type pbg to isolate the log lines.

TIL about named pasteboards https://developer.apple.com/documentation/appkit/nspasteboar...

I recognize that your pbg alias works for pretty much any text you could copy, but I wanted to mention, in case you're looking at log files with plain old less, there's the & limiter, which limits the current view to only lines matching a regular expression (or, if you type ^R during a & prompt, for a text match).

If you type ^N or ! during a & prompt it will limit the view to those lines that do not match the expression.

These view limits stack, so you can "&WARN" to see all lines that have WARN in them, and then maybe you want to see just a certain PID so "&12345" and you'll only see lines with both WARN and 12345, but then that one module is printing out a bunch of messages you think are safe to ignore so you do "&!modulename" and it filters out log lines that match modulename. Very handy and less is everywhere.

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

#303
post #90

Surprised pngpaste isn't mentioned (in the article nor the comments). If you take a screen shot (command + shift + 4) or partial screen shot (command + shift + control + 4) you can save it directly to an image file with: pngpaste filename.png

I configured the screenshot to file to automatically save them to ~/Desktop/screenshots instead of ~/Desktop using the Screenshot app to avoid cluttering the desktop. See https://www.hellotech.com/guide/for/how-to-change-where-scre...

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

#305

`caffeinate` is a game changer. Now I can keep my Slack status green without sitting in an empty zoom room. #WFHLife ;)

I use `caffeinate -dsim` permanently. In short I ask the computer to avoid any kind of sleep.

  -d Create an assertion to prevent the display from sleeping.
  -i Create an assertion to prevent the system from idle sleeping.
  -m Create an assertion to prevent the disk from idle sleeping.
  -s Create an assertion to prevent the system from sleeping. This
     assertion is valid only when system is running on AC power.

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

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

Use the Apple shortcuts app and you can just copy some text and hit a keyboard shortcut. The Shortcuts app lets you run arbitrary shell command.

This is interesting, thank you. I've been automating various things with Hammerspoon but (I think) it's limited to what you can reach with either a11y or osascript / the NS dictionary for the app you want to manipulate, but Shortcuts seems to have some actions that aren't in the NS dictionary.

For instance, in Shortcuts, I see that there's a "Pin Notes" action for Notes.app, but I don't see anything for pinning notes when I open Notes.app with "File -> Open Dictionary..." in Script Editor.

(In this case it's likely that Notes.app has the a11y bits necessary to run that action from Hammerspoon, but it would probably be easier to go through Shortcuts.)

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

#308
post #146

You can use `say` to recreate your own Serial Experiments Lain intros. say -v Whisper "Weird: Layer zero one"

You may have to install extra voices somehow, looking at the manpage for say, it seems like 'say -v ?' would list the voices installed, but I don't seem to have any (like Whisper), though plain old 'say "hello world"' does do a robotic voice which must be the default.

You can install additional voices in System Settings → Accessibility → Spoken Content → System voice → Manage voices (in Ventura).

"Whisper" is listed under "English (US) - Novelty".

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

#309
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 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/

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

#310
post #146

You can use `say` to recreate your own Serial Experiments Lain intros. say -v Whisper "Weird: Layer zero one"

You may have to install extra voices somehow, looking at the manpage for say, it seems like 'say -v ?' would list the voices installed, but I don't seem to have any (like Whisper), though plain old 'say "hello world"' does do a robotic voice which must be the default.

Not sure if you can install additional voices using the command line, but the way you do it in the UI is Preferences -> Accessibility -> Spoken Content, then select customize in the voice selector and finally select the voice you want to add.
Post reply on HN