fix: made chmodx escape safe + used vim API
parent
902335bf12
commit
721d77b549
|
|
@ -114,11 +114,23 @@ function M.copyFilename() copyOp("filename") end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
---Run `chmod +x` on the current file. Requires `chmod`.
|
---Makes current file executable
|
||||||
function M.chmodx()
|
function M.chmodx()
|
||||||
local currentFile = expand("%:p")
|
local filename = vim.fn.expand('%')
|
||||||
os.execute("chmod +x '" .. currentFile .. "'")
|
local perm = vim.fn.getfperm(filename)
|
||||||
vim.notify(" Execution permission granted. ")
|
local res = ''
|
||||||
|
local r
|
||||||
|
for j = 1, perm:len() do
|
||||||
|
local char = perm:sub(j, j)
|
||||||
|
if j % 3 == 1 then
|
||||||
|
r = char == 'r'
|
||||||
|
end
|
||||||
|
if j % 3 == 0 and r then
|
||||||
|
char = 'x'
|
||||||
|
end
|
||||||
|
res = res .. char
|
||||||
|
end
|
||||||
|
vim.fn.setfperm(filename, res)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Trash the Current File. Requires `mv`.
|
---Trash the Current File. Requires `mv`.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue