File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ #
3+ # Switch default image handler between Preview and GIMP
4+ # Usage: image-app [gimp|preview]
5+ # No args or "preview" -> Preview (default)
6+ # "gimp" -> GIMP
7+
8+ set -e
9+
10+ preview=" com.apple.Preview"
11+ gimp=" org.gimp.gimp-2.10"
12+
13+ # Common image UTIs
14+ image_utis=(
15+ public.png
16+ public.jpeg
17+ public.tiff
18+ public.heic
19+ public.heif
20+ com.compuserve.gif
21+ org.webmproject.webp
22+ com.microsoft.bmp
23+ com.adobe.raw-image
24+ public.camera-raw-image
25+ )
26+
27+ case " ${1:- preview} " in
28+ gimp|g)
29+ app=$gimp
30+ app_name=" GIMP"
31+ ;;
32+ preview|p|" " )
33+ app=$preview
34+ app_name=" Preview"
35+ ;;
36+ * )
37+ echo " Usage: image-app [gimp|preview]"
38+ echo " gimp, g - Set GIMP as default image viewer"
39+ echo " preview, p - Set Preview as default (this is the default)"
40+ exit 1
41+ ;;
42+ esac
43+
44+ echo " Setting default image handler to $app_name "
45+ echo " -------------------------------------------"
46+
47+ for uti in " ${image_utis[@]} " ; do
48+ echo " $uti "
49+ duti -s " $app " " $uti " all 2> /dev/null || true
50+ done
51+
52+ echo " "
53+ echo " Done! $app_name is now the default for images."
You can’t perform that action at this time.
0 commit comments