mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
suedit plugin (#359)
This commit is contained in:
parent
ab0fe6c408
commit
49bee69490
|
@ -38,6 +38,7 @@ The currently available plugins are listed below.
|
||||||
| readit | sh | pdftotext, mpv,<br>pico2wave | Read a PDF or text file aloud |
|
| readit | sh | pdftotext, mpv,<br>pico2wave | Read a PDF or text file aloud |
|
||||||
| ringtone | sh | date, ffmpeg | Create a variable bitrate mp3 ringtone from file |
|
| ringtone | sh | date, ffmpeg | Create a variable bitrate mp3 ringtone from file |
|
||||||
| splitjoin | sh | split, cat | Split file or join selection |
|
| splitjoin | sh | split, cat | Split file or join selection |
|
||||||
|
| suedit | sh | sudoedit/sudo/doas | Edit file using superuser permissions |
|
||||||
| sxiv | sh | sxiv | View images in dir, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts))|
|
| sxiv | sh | sxiv | View images in dir, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts))|
|
||||||
| thumb | sh | [lsix](https://github.com/hackerb9/lsix) | View thumbnail of an image or dir of images |
|
| thumb | sh | [lsix](https://github.com/hackerb9/lsix) | View thumbnail of an image or dir of images |
|
||||||
| transfer | sh | curl | Upload file to transfer.sh |
|
| transfer | sh | curl | Upload file to transfer.sh |
|
||||||
|
|
21
plugins/suedit
Executable file
21
plugins/suedit
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
# Description: Edit file as superuser
|
||||||
|
#
|
||||||
|
# Shell: POSIX compliant
|
||||||
|
# Author: Anna Arad
|
||||||
|
|
||||||
|
EDITOR="${EDITOR:-vim}"
|
||||||
|
|
||||||
|
is_cmd_exists () {
|
||||||
|
which "$1" > /dev/null 2>&1
|
||||||
|
echo $?
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$(is_cmd_exists sudoedit)" -eq "0" ]; then
|
||||||
|
sudoedit "$1"
|
||||||
|
elif [ "$(is_cmd_exists sudo)" -eq "0" ]; then
|
||||||
|
sudo "$EDITOR" "$1"
|
||||||
|
elif [ "$(is_cmd_exists doas)" -eq "0" ]; then
|
||||||
|
doas "$EDITOR" "$1"
|
||||||
|
fi
|
Loading…
Reference in a new issue