Skip to content

Commit

Permalink
fix: adjust powershell commands
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonHarnes authored Mar 1, 2024
1 parent 45a99b9 commit ddddd2d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lua/img-clip/clipboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ M.get_content = function()

-- Windows
elseif cmd == "powershell.exe" then
local output, exit_code = util.execute([[powershell -command "Get-Clipboard -Text"]])
local output, exit_code = util.execute([[powershell -command "Get-Clipboard"]])
if exit_code == 0 then
return output:match("^[^\n]+")
end
Expand Down
2 changes: 1 addition & 1 deletion lua/img-clip/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ M.get_base64_encoded_image = function(file_path)
local cmd = clipoard.get_clip_cmd()

-- Windows
if cmd == "powershell" then
if cmd == "powershell.exe" then
local command = string.format([[[System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes('%s'))]], file_path)
local output, exit_code = util.execute(command)
if exit_code == 0 then
Expand Down
7 changes: 5 additions & 2 deletions lua/img-clip/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ M.execute = function(input_cmd)
-- WSL requires the command to have the format:
-- powershell.exe -Command 'command "path/to/file"'
elseif M.has("wsl") then
cmd = "powershell.exe -NoProfile -Command '" .. input_cmd:gsub("'", '"') .. "'"

if input_cmd:match("curl") then
cmd = input_cmd
else
cmd = "powershell.exe -NoProfile -Command '" .. input_cmd:gsub("'", '"') .. "'"
end
-- cmd.exe requires the command to have the format:
-- powershell.exe -Command "command 'path/to/file'"
elseif M.has("win32") then
Expand Down

0 comments on commit ddddd2d

Please sign in to comment.