Skip to content

Mac OS X

macOS tips: Preview settings, hidden utilities and handy command-line tools for audio, video and downloads.

4 min read

Upgrade

Terminal window
#Install all updates
softwareupdate -i -a
#Install the specific update
softwareupdate -i NAME
#List installers
softwareupdate --list-full-installers
#Download the specific installer
softwareupdate --fetch-full-installer --full-installer-version 14.7
#Run the specific installer
sudo /Applications/Install\ macOS\ <version>.app/Contents/Resources/startosinstall

Preferences

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

Terminal window
while :; do afplay "file.mp3"; done;

individually play all file in a directory

Terminal window
find . -name '*.mp3' -exec afplay '{}' \;

Install transmission

Terminal window
brew install transmission-cli watch

Launch the daemon

Terminal window
transmission-daemon

Start the download

Terminal window
transmission-remote -a "magnet:link"

To have a visual update write: (add the -n flag to specify an interval, the standard is 2 seconds)

Terminal window
watch "transmission-remote -l"

Stop the daemon

Terminal window
transmission-remote --exit

or create a magnet.links file including magnet: link list of files you want to download, and then run below script to download all.

Terminal window
file="magnet.links"
while IFS= read -r line
do
transmission-remote -n 'transmission:transmission' -a $line
done <"$file"

Some options:

To target to a directory

Terminal window
transmission-remote -a magnet:?xt=urn:btih:e249fe4dc957be4b4ce3ecaac280fdf1c71bc5bb&dn=ubuntu-mate-16.10-desktop-amd64.iso -w ~/Downloads

To download torrent file

Terminal window
transmission-remote -a ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads
Terminal window
transmission-remote -a http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads

To 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.

Terminal window
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.gz

To download with encryption: It is possible to encrypt the traffic while downloading.

Terminal window
transmission-remote -a http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads -er

To remove a torrent with ID 3

Terminal window
transmission-remote -t 3 -r

To remove a torrent with ID 3 and 4

Terminal window
transmission-remote -t 3,4 -r

To remove all torrents

Terminal window
transmission-remote -t all -r

Convert wav to mp3

Terminal window
ffmpeg -i input.wav -codec:a libmp3lame -qscale:a 2 output.mp3

Free NTFS read and write on Mac

Edit fstab file

Terminal window
sudo nano /etc/fstab

Add 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”.

Terminal window
LABEL=DRIVE_NAME none ntfs rw,auto,nobrowse

Instead of using above, we can use the following command line.

Terminal window
UUID=Universal Unique Identifier none ntfs rw

Open 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

Terminal window
yt-dlp --extract-audio --audio-format mp3 'https://www.youtube.com/watch?v=J5oZ80Daduc'

Download all content as mp4 format

Terminal window
yt-dlp -S res,ext:mp4:m4a --recode mp4 'https://www.youtube.com/watch?v=J5oZ80Daduc'

Download any youtube video

Terminal window
yt-dlp --cookies-from-browser safari "<url>"
yt-dlp -v -f mp4 --cookies-from-browser chrome "<url>"

Download clip

Terminal window
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

Terminal window
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).

Terminal window
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.

Terminal window
yt-dlp 'https://www.youtube.com/watch?v=J5oZ80Daduc' --download-sections "*1:22:22-inf" --force-keyframes-at-cuts

Sections: Download a section titled “03. Symphony No. 6, Op. 68 (Pastoral): III. Allegro”:

Terminal window
yt-dlp 'URL' --download-sections "03.*"

Multiple Sections: Download multiple sections:

Terminal window
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.

Terminal window
shasum -a 256 /path/to/file

PDF merge

Terminal window
qpdf --empty --pages part1.pdf part2.pdf part3.pdf -- merged.pdf

If you want to merge only certain pages from files, you can specify page ranges.

Terminal window
qpdf --empty --pages part1.pdf 1-3 part2.pdf 1 part3.pdf -- merged.pdf

Disabling animations

  1. Settings > Accessibility > Display and then toggling “Reduce transparency” on.

  2. 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.

  1. 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

  1. 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

  1. 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

Related articles

3 min read

Swift - Core Location

Background location tracking in SwiftUI with Core Location and storing points with Core Data.

  • Apple & Mobile
11 min read

Swift

Swift language notes: collection types, conditions and loops, functions and closures.

  • Apple & Mobile

Type to search the whole site.