(most recent on top)

  1. Run shortcut Get URL of Note

  2. Enter node Note and check the LNEntity Supported Type to get the UUID, e.g.:

    <LNEntity: 0x123456789, identifier: NoteEntity/applenotes:note/12345678-abcd-bcde-cdef-123456789012, ...


  3. Convert the UUID to ALL CAPS (for example, using Convert Case or the Pages app):


  4. Append it to the url sheme to open Notes:


Note: Sometimes you might get the following error:

An error occurred while running Get URL of Note
Couldn’t communicate with a helper application.

I haven’t found any way around it other than trying again some other time 🤷‍♂️ — restarts haven’t helped at all.

Enable Touch ID for sudo

cd /etc/pam.d/ && sudo chmod a+w sudo && vi sudo && sudo chmod a-w sudo && cd -
# sudo: auth account password session
auth       sufficient     pam_tid.so        # <= add this line here
auth       sufficient     pam_smartcard.so
auth       required       pam_opendirectory.so
account    required       pam_permit.so
password   required       pam_deny.so
session    required       pam_permit.so

Remove quarantine

… “‘command’ cannot be opened because the developer cannot be verified.”

xattr -d com.apple.quarantine /usr/local/bin/cmd

File extended attributes

… list attributes

ls -l -@ file
xattr file

… show values

xattr -l file
xattr -p attribute file

Add to sudoers without needing a restart

su - admin

… add

sudo dseditgroup -o edit -a hugo -t user admin
sudo dseditgroup -o edit -a hugo -t user wheel

… delete

sudo dseditgroup -o edit -d hugo -t user admin
sudo dseditgroup -o edit -d hugo -t user wheel

Create encrypted zip file

… install

brew install p7zip

… create

7za a -tzip -mem=AES256 -p secrets-encrypted.zip secrets/
7za x secrets-encrypted.zip

View and change file flags

… invisible = hidden; visible = nohidden

$ touch seeme hideme

$ chflags hidden hideme
$ chflags nohidden seeme

$ ls -lO *me  # -O is an “oh” not a “zero”
-rw-r--r--  1 hugo  staff  hidden 0 Mar 12 11:28 hideme
-rw-r--r--  1 hugo  staff  -      0 Mar 12 11:28 seeme

Reset unlocking MacBook by Apple Watch

  • In Messages
    • Preferences ➤ Accounts
    • Sign Out
    • Sign In
  • In System Preferences
    • Security & Privacy
    • Check “Allow your Apple Watch to unlock you Mac”

Why does it keep waking from sleep?

… definition of log terms

  • OHC (Open Host Controller) is usually USB or Firewire. OHC1 or OHC2 is almost certainly an external USB keyboard or mouse
  • EHC (Enhanced Host Controller) is another USB interface, but can also be wireless devices and bluetooth
  • USB when a USB device woke the machine up
  • LID0 when you open the lid the machine wakes up from sleep
  • PWRB (Power Button) which is the physical power button on your Mac
  • RTC (Real Time Clock Alarm) is generally from wake-on-demand services
    • Schedule sleep and wake via the Energy Saver control panel
    • launchd setting
    • User applications
    • Backups
    • Other scheduled events
log show --last 1d --predicate 'eventMessage contains "Wake reason"'
log show --last 1d | grep -C15 -i "wake reason"

Delete old Time Machine backups

tmutil listbackups
sudo tmutil delete /Volumes/[Disk]/Backups.backupdb/[Name]/2000-00-00-000000
sudo tmutil delete /Volumes/[Disk]/Backups.backupdb/[Name]/2000-*

Use Keychain for unlocking SSH private key

Host *
   AddKeysToAgent yes
   UseKeychain yes
   IdentityFile ~/.ssh/id_rsa

Spoof MAC address

openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'  # make
sudo ifconfig en0 ether xx:xx:xx:xx:xx:xx  # set
ifconfig en0 |grep ether  # check

Consult timestamps on Safari history

$ sqlite3 ~/Library/Safari/History.db
sqlite> .headers on
select datetime(v.visit_time + 978307200, 'unixepoch', 'localtime') as date, v.visit_time + 978307200 as epoch, v.visit_time, i.domain_expansion, i.url
from history_items i left join history_visits v on i.id = v.history_item
order by i.id desc
limit 100;

Homebrew: Remove formula and its dependencies, if not in use

… installing command

brew tap beeftornado/rmtree && brew install brew-rmtree

… removing a formula

brew rmtree --dry-run formula

Homebrew: Show installed formulae and dependencies

… top-level only

brew leaves

… all dependencies

brew deps --installed [--tree]

… what uses a dependency

brew uses --installed --recursive formula

Homebrew quick guide

… installed things

brew list

… bumping version

brew update                       # Homebrew itself
brew outdated                     # Formulas
brew upgrade [$FORMULA]           # Formulas

… clearing things

brew list --versions --multiple
brew cleanup -n                   # dry run
brew cleanup [$FORMULA]

Homebrew: Using Caskroom sources

brew tap caskroom/cask
brew cask info Caskroom/cask/rowanj-gitx

Test and debug LaunchAgents and LaunchDaemons

sudo launchctl log level debug
tail -f /var/log/system.log
sudo launchctl log level error
launchctl list [cc.ferreira.backlog.daily]
launchctl start cc.ferreira.backlog.daily
launchctl unload -w ~/Library/LaunchAgents/cc.ferreira.backlog.daily.plist 
launchctl load -w ~/Library/LaunchAgents/cc.ferreira.backlog.daily.plist 

Resolve host from IP

  • with zeroconf / Multicast DNS / mDNS
dig +short -x -p 5353 @

Disable/revoke disk decryption from a user

$ sudo su - testing  
$ passwd 
Changing password for charlie.
Old Password:                     # [enter old password here]
New Password:                     # [press enter]
Retype New Password:              # [press enter]
  • System Preferences ➤ Security & Privacy ➤ FileVault
    • Enable Users …
    • Set Password …

Create user manually without disk encryption rights

  • for FileVault 2
sudo dscl /Local/Default -create /Users/testing
sudo dscl /Local/Default -create /Users/testing UserShell /bin/bash
sudo dscl /Local/Default -create /Users/testing RealName "Testing"
sudo dscl /Local/Default -create /Users/testing UniqueID 503
sudo dscl /Local/Default -create /Users/testing PrimaryGroupID 1000
sudo dscl /Local/Default -create /Users/testing NFSHomeDirectory /Users/testing
sudo passwd testing

Check user definitions

sudo dscl /Local/Default -read /Users/testing

Where the modem passwords are stored

cat /Library/Preferences/SystemConfiguration/preferences.plist

Where the dhcp leases are stored

cat /var/db/dhcpd_leases

Flush DNS cache

sudo dscacheutil -flushcache

Force Spotlight to re-index

sudo mdutil -E /

Remove duplicates in the “Open With” menu

cd /System/Library/Frameworks/ApplicationServices.framework/\Frameworks/LaunchServices.framework/Support/
lsregister -kill -r -domain local -domain system -domain user

View resource forks

# DEPRECATED: ls -l path/to/file/rsrc

MySQL server

… MacPorts

su - admin -c "sudo mysql.server start | stop | …"

… Homebrew

su - admin; mysql.server start | stop |

iPhoto speedup

cd Pictures/iPhoto\ Library/
for db in *.db; do
    sqlite3 $db "vacuum;"

Stop nmbd

sudo launchctl unload /System/Library/LaunchDaemons/nmbd.plist

Quit application

osascript -e 'tell app "iCal" to quit'

“Old” style sleep mode

pmset -g | grep hibernatemode
sudo pmset -a hibernatemode 0

Eject cd

drutil tray eject

Text styles and substitutions

open ~/Library/Preferences/.GlobalPreferences.plist
# See `NSFavoriteStyles`
# See `NSUserReplacementItems`

Open man pages in PDF

man -t opensnoop | open -f -a /Applications/Preview.app

Start/Stop local FTP Server

sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist
sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist