aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/zsh
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-06-15 00:55:44 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-06-15 00:55:44 +0100
commit066df8cc91966a0fbe5b2a32c45ad984fd9ae468 (patch)
tree97bdba4d5294f305791f48afabd8386c3f97091f /dot_config/zsh
parentbb607b3cdb027a2d02cf2111b8ee12dab172efad (diff)
downloaddotfiles-066df8cc91966a0fbe5b2a32c45ad984fd9ae468.tar.gz
dotfiles-066df8cc91966a0fbe5b2a32c45ad984fd9ae468.tar.bz2
dotfiles-066df8cc91966a0fbe5b2a32c45ad984fd9ae468.zip
Use absolute editor commands under sudo
Resolve nvim before exporting editor and pager variables so sudo-rs env_keep does not depend on root's secure_path. Update the Waybar pacdiff action to pass an absolute DIFFPROG through sudo.
Diffstat (limited to 'dot_config/zsh')
-rw-r--r--dot_config/zsh/dot_zprofile23
1 files changed, 19 insertions, 4 deletions
diff --git a/dot_config/zsh/dot_zprofile b/dot_config/zsh/dot_zprofile
index 7b79af0..b95079b 100644
--- a/dot_config/zsh/dot_zprofile
+++ b/dot_config/zsh/dot_zprofile
@@ -42,10 +42,25 @@ export BROWSER='linkhandler'
export OPENER='xdg-open'
# ── Editors ───────────────────────────────────────────────────────────────────
-export EDITOR='nvim'
-export VISUAL='nvim'
-export DIFFPROG='nvim -d'
-export MANPAGER='nvim +Man!'
+# Keep editor-style variables absolute. sudo-rs preserves them for interactive
+# tools, but root's secure_path intentionally does not include the user's nix
+# profile, so bare `nvim` would fail under sudo.
+if _nvim="$(whence -p nvim 2>/dev/null)"; then
+ export EDITOR="$_nvim"
+ export VISUAL="$_nvim"
+ export SUDO_EDITOR="$_nvim"
+ export GIT_EDITOR="$_nvim"
+ export DIFFPROG="$_nvim -d"
+ export MANPAGER="$_nvim +Man!"
+else
+ export EDITOR='vi'
+ export VISUAL='vi'
+ export SUDO_EDITOR='vi'
+ export GIT_EDITOR='vi'
+ export DIFFPROG='diff -u'
+ export MANPAGER='less'
+fi
+unset _nvim
export MANWIDTH=999
# ── less ──────────────────────────────────────────────────────────────────────