diff options
| author | 2026-04-17 10:53:21 +0100 | |
|---|---|---|
| committer | 2026-04-17 10:53:21 +0100 | |
| commit | bc5b3cb42ba01d73f811cc32ed5320d1f6ed7b10 (patch) | |
| tree | d5848f19330e207161a581115dfca29caeb8f9e1 | |
| parent | b9ba7e545f28d40ea8c81575d09751eccd7ced87 (diff) | |
| download | dotfiles-bc5b3cb42ba01d73f811cc32ed5320d1f6ed7b10.tar.gz dotfiles-bc5b3cb42ba01d73f811cc32ed5320d1f6ed7b10.tar.bz2 dotfiles-bc5b3cb42ba01d73f811cc32ed5320d1f6ed7b10.zip | |
fix: use doas instead of sudo in DoasWrite command
System uses doas for privilege escalation. Renamed SudoWrite → DoasWrite
and switched from sudo -p '' -S to doas -S with newline-terminated
password input.
| -rw-r--r-- | home/.config/nvim/lua/config/keymaps.lua | 12 |
1 files changed, 6 insertions, 6 deletions
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", }) |
