From bc5b3cb42ba01d73f811cc32ed5320d1f6ed7b10 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Fri, 17 Apr 2026 10:53:21 +0100 Subject: fix: use doas instead of sudo in DoasWrite command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit System uses doas for privilege escalation. Renamed SudoWrite → DoasWrite and switched from sudo -p '' -S to doas -S with newline-terminated password input. --- home/.config/nvim/lua/config/keymaps.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'home/.config/nvim') diff --git a/home/.config/nvim/lua/config/keymaps.lua b/home/.config/nvim/lua/config/keymaps.lua index f198a95..c9ca371 100644 --- a/home/.config/nvim/lua/config/keymaps.lua +++ b/home/.config/nvim/lua/config/keymaps.lua @@ -101,15 +101,15 @@ nmap("yp", function() vim.fn.setreg("+", vim.fn.expand("%")) end, "[Y]ank [P]ath") -local sudo_exec = function(_cmd) +local doas_exec = function(_cmd) vim.fn.inputsave() local password = vim.fn.inputsecret("Password: ") vim.fn.inputrestore() if not password or #password == 0 then - vim.notify("Invalid password, sudo aborted", vim.log.levels.WARN) + vim.notify("Invalid password, doas aborted", vim.log.levels.WARN) return false end - local out = vim.fn.system(string.format("sudo -p '' -S %s", _cmd), password) + local out = vim.fn.system(string.format("doas -S %s", _cmd), password .. "\n") if vim.v.shell_error ~= 0 then print("\r\n") vim.notify(out, vim.log.levels.ERROR) @@ -118,7 +118,7 @@ local sudo_exec = function(_cmd) return true end -vim.api.nvim_create_user_command("SudoWrite", function(opts) +vim.api.nvim_create_user_command("DoasWrite", function(opts) local tmpfile = vim.fn.tempname() local filepath if #opts.fargs == 1 then @@ -139,7 +139,7 @@ vim.api.nvim_create_user_command("SudoWrite", function(opts) ) -- no need to check error as this fails the entire function vim.api.nvim_exec2(string.format("write! %s", tmpfile), { output = true }) - if sudo_exec(_cmd) then + if doas_exec(_cmd) then -- refreshes the buffer and prints the "written" message vim.cmd.checktime() -- exit command mode @@ -152,5 +152,5 @@ vim.api.nvim_create_user_command("SudoWrite", function(opts) vim.fn.delete(tmpfile) end, { nargs = "?", - desc = "Write using sudo permissions", + desc = "Write using doas permissions", }) -- cgit v1.2.3-70-g09d2