Skip to content

Commit

Permalink
refactor: simplify windows powershell command
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonHarnes committed Dec 9, 2023
1 parent 947325c commit b7b4f17
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lua/img-clip/clipboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,7 @@ M.save_clipboard_image = function(cmd, file_path)

-- Windows
elseif cmd == "powershell.exe" then
local command

if util.has("win32") then
command = string.format([[powershell.exe -c (Get-Clipboard -Format Image).save(\"%s\")]], file_path)
else -- wsl uses bash and doesn't handle \" well
command = string.format([[powershell.exe -c '(Get-Clipboard -Format Image).save("%s")']], file_path)
end

local command = string.format([[powershell.exe "(Get-Clipboard -Format Image).save('%s')"]], file_path)
local _, exit_code = util.execute(command)
return exit_code == 0
end
Expand Down

0 comments on commit b7b4f17

Please sign in to comment.