Skip to content

Instantly share code, notes, and snippets.

@ole
Last active May 4, 2024 02:10
Show Gist options
  • Save ole/2ddddd45098c1acf0cdc969714ae7156 to your computer and use it in GitHub Desktop.
Save ole/2ddddd45098c1acf0cdc969714ae7156 to your computer and use it in GitHub Desktop.
Assign a keyboard shortcut to the Export Unmodified Originals menu command in Photos.app on macOS
#!/bin/bash
# Assigns a keyboard shortcut to the Export Unmodified Originals
# menu command in Photos.app on macOS.
# @ = Command
# ^ = Control
# ~ = Option
# $ = Shift
shortcut='@~^e'
# Set shortcut for 1 selected item
echo "Setting shortcut for 1 item"
defaults write com.apple.Photos NSUserKeyEquivalents -dict-add "Export Unmodified Original For 1 Photo" "$shortcut"
defaults write com.apple.Photos NSUserKeyEquivalents -dict-add "Export Unmodified Original For 1 Video" "$shortcut"
# Set shortcut for 2-20 selected items
objects=(Photos Videos Items)
for i in {2..20}
do
echo "Setting shortcut for $i items"
for object in "${objects[@]}"
do
defaults write com.apple.Photos NSUserKeyEquivalents -dict-add "Export Unmodified Originals For $i $object" "$shortcut"
done
done
# Use this command to verify the result:
# defaults read com.apple.Photos NSUserKeyEquivalents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment