A method 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 “information or folders” and “Finder”
- “Shell” choose “/bin/bash” (which is historical system bash)
- “Move enter” choose “as arguments”
Script determines file sort by file extension, opens pdf information with Preview and csv information 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
carried out
I saved it as Good Open
Then in System Settings -> Keyboard Shortcuts -> Providers -> Information and Folders there ought to be seen “Good Open”. Assign keyboard shorcut to your liking. In Finder utilizing this keyboard shortcut will open pdf information with Preview and csv information with Excel and all others with system default.
Identified limitations: multi-part extensions should not acknowledged –
archive.tar.gz is handled as gz, not tar.gz; information beginning with . will fall to system default. Most definitely there are others limitations and gotchas as properly however my proof-of-concept utilization confirmed that it labored as anticipated.
