`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 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 --…
macOS command-line tools you might not know about
281–290 of 454 posts
Re: macOS command-line tools you might not know about
#282Re: macOS command-line tools you might not know about
#283 # hide desktop icons and folders
defaults write com.apple.finder CreateDesktop 0
killall Finder # restarting Finder is required
# unhide desktop icons and folders
defaults write com.apple.finder CreateDesktop 1
killall Finder # restarting Finder is required
I made myself a convenient bash alias for this which lets me simply toggle the desktop on and off
Here is a gist: https://gist.github.com/berndverst/6f58c0d6aedddb6c06c23e57d... toggledesktop () {
if [[ $(defaults read com.apple.finder CreateDesktop) -eq "0" ]]
then
export SHOWDESKTOP=1;
echo "Unhiding Desktop icons"
else
export SHOWDESKTOP=0;
echo "Hiding Desktop icons"
fi
defaults write com.apple.finder CreateDesktop $SHOWDESKTOP
killall Finder
}Re: macOS command-line tools you might not know about
#284Years ago, I wrote a script to find something in a big blob of data and to alert me when it was done, I added a “say ” type phrase upon completion. I forgot about it and went to bed and was jolted awake hours later by what was clearly an “intruder” speaking to his accomplice, in my home office. Quite the relief when I realized what happened.
Re: macOS command-line tools you might not know about
#285`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.
Re: macOS command-line tools you might not know about
#286Re: macOS command-line tools you might not know about
#287For example, turn off autohiding of the Dock from commandline:
defaults write com.apple.dock "autohide" -bool "false" && killall Dock
Include the date in screenshots you take: defaults write com.apple.screencapture "include-date" -bool "true"
Here is handy website which documents many of the defaults and their purpose:
https://macos-defaults.com/#%F0%9F%99%8B-what-s-a-defaults-c...Re: macOS command-line tools you might not know about
#288Earlier quoted context omitted.
Another frequent use I have, applying random diffs with git: git diff | pbcopy pbpaste | git apply
You can also use `git format-patch` and `git am` if you want to apply the same commit to multiple repos, a use-case I sometimes I have.
Re: macOS command-line tools you might not know about
#289afconvert(1) lets you convert between various audio formats - most noteworthy is that it gives you access to Core Audio's superior AAC encoder without having to use iTunes/Music: afconvert music.wav -o music_160kbps_aac.m4a -b 160000 -q 127 -s 2 -f m4af -d 'aac ' lipo(1) lets you operate (replace/extract/thin/etc) on executables and libraries to tailor their supported architectures: lipo -thin arm64e -output
# 500 megabytes disk image
mb=$((500*2048))
diskutil eraseVolume ExFAT my_ramdisk `hdiutil attach -nomount ram://$mb`Re: macOS command-line tools you might not know about
#290`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.
then just highlight any youtube link and COPY
later when I have time, I can use quicklook to browse directory of youtube videos.