@@ -118,9 +118,26 @@ open_dir.linux = [[busctl --user call org.freedesktop.FileManager1 /org/freedesk
118118
119119local open_files = {}
120120open_files .windows = " explorer.exe /select, %s"
121- open_files .macos = " open -Rn %s "
121+ open_files .macos = " osascript -e 'tell application \" Finder \" to (reveal {%s}) activate' "
122122open_files .linux = [[ busctl --user call org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1 ShowItems ass %d %s ""]]
123123
124+ reveal_file_osx_cmd = " \" %s\" as POSIX file"
125+
126+ -- Call the osx Finder with each selected image selected.
127+ -- For images in multiple folders, Finder will open a separate window for each
128+ local function call_list_of_files_osx (selected_images )
129+ local cmds = {}
130+ for _ , image in pairs (selected_images ) do
131+ current_image = image .path .. PS .. image .filename
132+ -- AppleScript needs double quoted strings, and the whole command is wrapped in single quotes.
133+ table.insert (cmds , string.format (reveal_file_osx_cmd , string.gsub (string.gsub (current_image , " \" " , " \\\" " ), " '" , " '\" '\" '" )))
134+ end
135+ reveal_cmd = table.concat (cmds , " ," )
136+ run_cmd = string.format (open_files .macos , reveal_cmd )
137+ dt .print_log (" OSX run_cmd = " .. run_cmd )
138+ dsys .external_command (run_cmd )
139+ end
140+
124141-- Call the file mangager for each selected image on Linux.
125142-- There is one call to busctl containing a list of all the image file names.
126143local function call_list_of_files (selected_images )
@@ -188,6 +205,8 @@ local function open_in_fmanager()
188205 else
189206 if act_os == " linux" then
190207 call_list_of_files (images )
208+ elseif act_os == " macos" then
209+ call_list_of_files_osx (images )
191210 else
192211 call_file_by_file (images )
193212 end
0 commit comments