nnn/plugins/suedit

17 lines
312 B
Plaintext
Raw Normal View History

2019-10-14 01:06:11 +00:00
#!/usr/bin/env sh
# Description: Edit file as superuser
#
# Shell: POSIX compliant
# Author: Anna Arad
EDITOR="${EDITOR:-vim}"
2019-10-14 01:06:11 +00:00
if type sudo >/dev/null 2>&1; then
2019-10-14 01:06:11 +00:00
sudo "$EDITOR" "$1"
elif type sudoedit >/dev/null 2>&1; then
2020-01-15 11:48:10 +00:00
sudoedit "$1"
elif type doas >/dev/null 2>&1; then
2019-10-14 01:06:11 +00:00
doas "$EDITOR" "$1"
fi