diff --git a/lua/img-clip/clipboard.lua b/lua/img-clip/clipboard.lua index e11dbc4..112f4b9 100644 --- a/lua/img-clip/clipboard.lua +++ b/lua/img-clip/clipboard.lua @@ -137,16 +137,14 @@ M.get_content = function() return output:match("^[^\n]+") end - -- MacOS (pngpaste) - elseif cmd == "pngpaste" then - local output, exit_code = util.execute("pngpaste -") + -- MacOS + elseif cmd == "pngpaste" or cmd == "osascript" then + local output, exit_code = util.execute("pbpaste") if exit_code == 0 then return output:match("^[^\n]+") end - -- MacOS (osascript) - elseif cmd == "osascript" then - local output, exit_code = util.execute([[osascript -e 'get the clipboard as text']]) + output, exit_code = util.execute([[osascript -e 'get the clipboard as text']]) if exit_code == 0 then return output:match("^[^\n]+") end diff --git a/lua/img-clip/util.lua b/lua/img-clip/util.lua index a20dbd9..c9c5d40 100644 --- a/lua/img-clip/util.lua +++ b/lua/img-clip/util.lua @@ -4,10 +4,6 @@ local M = {} M.verbose = true -M.executable = function(command) - return vim.fn.executable(command) == 1 -end - ---@param input_cmd string ---@return string | nil output ---@return number exit_code @@ -50,6 +46,10 @@ M.execute = function(input_cmd) return output, exit_code end +M.executable = function(command) + return vim.fn.executable(command) == 1 +end + ---@param feature string M.has = function(feature) return vim.fn.has(feature) == 1