A technique is to make use of Automator Fast Motion (assign keyboard shortcut to it) and bash script (I do not use zhs).
In Automator:
- choose “Fast Motion”
- choose “Run Shell Script”
- for “Workflow receives present” choose “recordsdata or folders” and “Finder”
- “Shell” choose “/bin/bash” (which is historical system bash)
- “Go enter” choose “as arguments”
Script determines file kind by file extension, opens pdf recordsdata with Preview and csv recordsdata with Excel (I’ve system defaults to different functions for these file extensions so I used these to check if script works) and if nothing specified falls again to system default
for f in "$@"; do
[[ -e "$f" ]] || proceed
filename=${f##*/}
ext=""
if [[ "$filename" == *.* && "$filename" != .* ]]; then
ext=${filename##*.}
ext=$(printf '%s' "$ext" | tr '[:upper:]' '[:lower:]')
fi
case "$ext" in
pdf)
open -a "Preview" "$f"
;;
csv)
open -a "Microsoft Excel" "$f"
;;
*)
open "$f"
;;
esac
accomplished
I saved it as Good Open
Then in System Settings -> Keyboard Shortcuts -> Providers -> Recordsdata and Folders there must be seen “Good Open”. Assign keyboard shorcut to your liking. In Finder utilizing this keyboard shortcut will open pdf recordsdata with Preview and csv recordsdata with Excel and all others with system default.
Recognized limitations: multi-part extensions aren’t acknowledged –
archive.tar.gz is handled as gz, not tar.gz; recordsdata beginning with . will fall to system default. Most actually there are others limitations and gotchas as effectively however my proof-of-concept utilization confirmed that it labored as anticipated.
