`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.
git diff | pbcopy
pbpaste | git apply121–130 of 454 posts
`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.
git diff | pbcopy
pbpaste | git applyEarlier quoted context omitted.
That's a useless use of cat. You can use `jq . foo.json | pbcopy` or `jq < foo.json | pbcopy`.
Speaking for myself, the first form is more natural- even if it’s a useless cat, because I’m always cat-ing files to see their structure. Then progressively tacking on different transforms. And then finally putting it in whatever I want as output. It’s so ingrained, I’m more likely than not to just write it out that way even when I know exactly what I’m doing from the onset.
e.g.
I need to grab some info from textfile.txt to use as arguments to a function.
cat textfile.txt
looks like its comma delimited.
cat textfile.txt | cut -d, -f 2-5
ah, its the third and fourth column i need
cat textfile.txt | cut -d, -f 3-4 | grep '123456'
perfect
cat textfile.txt | cut -d, -f 3-4 | grep 123456 | tr , ' '
myfunc $(cat textfile.txt | cut -d, -f 3-4 | grep 123456 | tr , ' ')
Earlier quoted context omitted.
In what way do you see those alternatives as superior?
They avoid an unnecessary invocation of the cat executable. Instead, they open a file descriptor and pass that. Tiny difference but there you go.
Here are my favorites: alias sleepoff="sudo pmset -a disablesleep 1" alias sleepon="sudo pmset -a disablesleep 0" This fully disables sleep, period. Just make sure you don't leave it unplugged too long, but on Apple Silicon it lasts for quite a long time.
`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.
Another frequent use I have, applying random diffs with git: git diff | pbcopy pbpaste | git apply
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
While you're at it, `brew install coreutils`. The coreutils that ship with macOS lack a lot of features available on Linux. If you use bash, I recommend upgrading it, too, since Apple ships a 16 year old build (iirc due to legal issues associated with GPLv3) `brew install bash`
They're shipping zsh now.
Nice list. Also, hidutil ( https://developer.apple.com/library/archive/technotes/tn2450... ). Example: hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000049,"HIDKeyboardModifierMappingDst":0x700000065}]}' For my PC keyboard, remaps "Ins" (normally useless under macOS) to something ("PC Execute") I can trap and remap with Keyboard Maestro.