Use keyboard shortcuts to assign tags to items in macOS Finder.
I have tried intermittently to enable this functionality since Mavericks, and was extremely happy to get this working last year. I post this on the off chance that anyone else has an irrational need to have "keystroke = tag" capability.
Portland's own James Berry made a very useful command line tool (tag) that can, among other things, add/remove tags to/from Finder items.
-
It can add tags:
tag -a YourTagHere
-
It can remove tags:
tag -r YourTagHere
More in the tag README.
The example Automator workflows I have included here are one way to trigger tag to act on the selected finder items via keyboard shortcut. (This functionality is probably available using LaunchBar, Alfred, Keyboard Maestro, etc., but I wanted to assign tags via keyboard w/o needing any other apps running.)
The tag command is used in a tiny Bash script. Note: The Automator action requires including the path to the command.
for f in "$@"
do
/usr/local/bin/tag -a YourTagHere "$f"
done
- The Bash script is contained in an Automator action in a workflow
- The workflow is saved as a macOS Service
- A keyboard shortcut is assigned to the Service
Note: Services can be assigned a keyboard shortcut in System Preferences -> Keyboard -> Shortcuts -> Services.
I currently toggle a "flag" tag in the most simple manner:
- "cmd-shift-L" ADDS the "flag" tag
- "cmd-opt-shift-L" REMOVES the "flag" tag.
Further ideas: It could be useful in some circumstances to:
- Read the state of the tag on the file
- Use a single key command to toggle that state.
Requirements (from the readme.md)
- 10.9 Mavericks and above
- You must have Xcode or the Command Line Tools installed to build/install.
Installation of tag
- Install Homebrew on your Mac.
- Install the tag package via the command line.
brew install tag