Mac OS X
macOS tips: Preview settings, hidden utilities and handy command-line tools for audio, video and downloads.
4 min read
Upgrade
#Install all updatessoftwareupdate -i -a#Install the specific updatesoftwareupdate -i NAME#List installerssoftwareupdate --list-full-installers#Download the specific installersoftwareupdate --fetch-full-installer --full-installer-version 14.7#Run the specific installersudo /Applications/Install\ macOS\ <version>.app/Contents/Resources/startosinstallPreferences
Preview for PDFs - Incorrect Pages are Bookmarked
Turn off logical page numbers by going to Preferences > PDF and then unticking the Viewing documents: Use logical page numbers box.
Hidden Utilities
afplay - Audio File Play
afplay [option…] audio_file
loop a file
while :; do afplay "file.mp3"; done;individually play all file in a directory
find . -name '*.mp3' -exec afplay '{}' \;transmission-cli: Download torrent and magnet links through the command line
Install transmission
brew install transmission-cli watchLaunch the daemon
transmission-daemonStart the download
transmission-remote -a "magnet:link"To have a visual update write: (add the -n flag to specify an interval, the standard is 2 seconds)
watch "transmission-remote -l"Stop the daemon
transmission-remote --exitor create a magnet.links file including magnet: link list of files you want to download, and then run below script to download all.
file="magnet.links"while IFS= read -r linedotransmission-remote -n 'transmission:transmission' -a $linedone <"$file"Some options:
To target to a directory
transmission-remote -a magnet:?xt=urn:btih:e249fe4dc957be4b4ce3ecaac280fdf1c71bc5bb&dn=ubuntu-mate-16.10-desktop-amd64.iso -w ~/DownloadsTo download torrent file
transmission-remote -a ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloadstransmission-remote -a http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/DownloadsTo enable a peer blocklist: Since transmission-cli works different than its GTK counterpart, it often doesn’t save settings. This means peer blocklists need to be specified each time before use. The -b switch enables a blocklist.
transmission-remote -a http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads -b http://john.bitsurge.net/public/biglist.p2p.gzTo download with encryption: It is possible to encrypt the traffic while downloading.
transmission-remote -a http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads -erTo remove a torrent with ID 3
transmission-remote -t 3 -rTo remove a torrent with ID 3 and 4
transmission-remote -t 3,4 -rTo remove all torrents
transmission-remote -t all -rConvert wav to mp3
ffmpeg -i input.wav -codec:a libmp3lame -qscale:a 2 output.mp3Free NTFS read and write on Mac
Edit fstab file
sudo nano /etc/fstabAdd below line where DRIVE_NAME is the name of the drive. The drive’s name should contain no spaces, as adding a space to the configuration file would tell your Mac to interpret whatever’s after that space as a separate command. If your DRIVE_NAME is made up of two words separated with a space, for example, “NO NAME”, you have to add a “\” before the space for the system to recognize the space. For example, “NO\ NAME”.
LABEL=DRIVE_NAME none ntfs rw,auto,nobrowseInstead of using above, we can use the following command line.
UUID=Universal Unique Identifier none ntfs rwOpen Disk Utility and check File System UUID by opening Volume Info. Go back to Disk Utility to Unmount then Mount the NTFS disk to see if it is able to read and write to NTFS Disk.
Download from youtube
Download all content as mp3 format
yt-dlp --extract-audio --audio-format mp3 'https://www.youtube.com/watch?v=J5oZ80Daduc'Download all content as mp4 format
yt-dlp -S res,ext:mp4:m4a --recode mp4 'https://www.youtube.com/watch?v=J5oZ80Daduc'Download any youtube video
yt-dlp --cookies-from-browser safari "<url>"yt-dlp -v -f mp4 --cookies-from-browser chrome "<url>"Download clip
yt-dlp --quiet --force-keyframes-at-cuts --no-warnings -x --audio-format wav -f bestaudio -o "{output_filename}" --download-sections "*{start_time}-{end_time}" "{url_base}{video_identifier}"Trim a video without downloading it entirely
yt-dlp 'https://www.youtube.com/watch?v=J5oZ80Daduc' --downloader ffmpeg --downloader-args "ffmpeg_i:-ss 1313 -to 1330"-ss HH:MM:SS: start time to take-to HH:MM:SS: end time-t HH:MM:SS: time length to take
Fastest: It will only download the section specified (to the nearest keyframe).
yt-dlp 'https://www.youtube.com/watch?v=J5oZ80Daduc' --download-sections "*6:02-6:22"Exact Key Frame: inf means to the end of the video.
yt-dlp 'https://www.youtube.com/watch?v=J5oZ80Daduc' --download-sections "*1:22:22-inf" --force-keyframes-at-cutsSections: Download a section titled “03. Symphony No. 6, Op. 68 (Pastoral): III. Allegro”:
yt-dlp 'URL' --download-sections "03.*"Multiple Sections: Download multiple sections:
yt-dlp 'URL' --download-sections "03.*" --download-sections "05.*" -o "%(title)s-%(section_title)s.%(ext)s"Verifying SHA256 checksum with shasum
A checksum is basically a string of letters and numbers that can be used to determine file integrity, like whether an error occurred during transmission, or whether a file was tampered with. For example, if the file checksum matches on your end with the checksum posted by where you received the file, you can be sure the file is identical.
shasum -a 256 /path/to/filePDF merge
qpdf --empty --pages part1.pdf part2.pdf part3.pdf -- merged.pdfIf you want to merge only certain pages from files, you can specify page ranges.
qpdf --empty --pages part1.pdf 1-3 part2.pdf 1 part3.pdf -- merged.pdfDisabling animations
-
Settings > Accessibility > Display and then toggling “Reduce transparency” on.
-
Settings > Accessibility > Motion and then toggling “Reduce Motion” on.
This replaces the sideways scrolling animation with a much quicker transition between two Spaces. It’s a lot cleaner and more responsive when swiping, as well as when Command+Tabbing between two apps.
- Speed Up the Dock Animations
This makes the Dock appear more quickly. The “0.2” in the command is how long the animation takes in seconds.
defaults write com.apple.dock autohide-time-modifier -float 0.2; killall Dock
To revert the change, paste this command into Terminal:
defaults delete com.apple.dock autohide-time-modifier; killall Dock
- Speed Up the Launchpad Animations
defaults write com.apple.dock springboard-show-duration -float 0.2; defaults write com.apple.dock springboard-hide-duration -float 0.2; killall Dock
To undo these changes, use this:
defaults delete com.apple.dock springboard-show-duration; defaults delete com.apple.dock springboard-hide-duration; killall Dock
- Speed up scrolling between pages in Launchpad
defaults write com.apple.dock springboard-page-duration -float 0.2; killall Dock
This is the command to undo that change:
defaults delete com.apple.dock springboard-page-duration; killall Dock