mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-23 02:35:38 +01:00
feat(systemd): preserve editor env for sudo commands
When running `systemctl` commands that require sudo, the users' configured editor environment variables were not preserved. This resulted in systemctl opening a default editor. By instructing sudo to preserve the common environment variables for configuring an editor, systemctl can see these variables and open the users' preferred editor. This is mostly relevant for the `sc-edit` alias.
This commit is contained in:
parent
680298e920
commit
c4d215e1dc
1 changed files with 3 additions and 1 deletions
|
|
@ -67,13 +67,15 @@ power_commands=(
|
||||||
suspend
|
suspend
|
||||||
)
|
)
|
||||||
|
|
||||||
|
readonly SUDO_PRESERVE_ENV="SYSTEMD_EDITOR,SUDO_EDITOR,VISUAL,EDITOR"
|
||||||
|
|
||||||
for c in $user_commands; do
|
for c in $user_commands; do
|
||||||
alias "sc-$c"="systemctl $c"
|
alias "sc-$c"="systemctl $c"
|
||||||
alias "scu-$c"="systemctl --user $c"
|
alias "scu-$c"="systemctl --user $c"
|
||||||
done
|
done
|
||||||
|
|
||||||
for c in $sudo_commands; do
|
for c in $sudo_commands; do
|
||||||
alias "sc-$c"="sudo systemctl $c"
|
alias "sc-$c"="sudo --preserve-env=$SUDO_PRESERVE_ENV systemctl $c"
|
||||||
alias "scu-$c"="systemctl --user $c"
|
alias "scu-$c"="systemctl --user $c"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue