From c7f20751fcfcc1ebf0634c15bdae5045c30d122a Mon Sep 17 00:00:00 2001 From: DogeyStamp Date: Fri, 1 Oct 2021 20:41:38 -0400 Subject: [PATCH] Add sedi script --- .local/bin/sedi | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 .local/bin/sedi diff --git a/.local/bin/sedi b/.local/bin/sedi new file mode 100755 index 0000000..de1e8c7 --- /dev/null +++ b/.local/bin/sedi @@ -0,0 +1,17 @@ +#!/bin/sh + +# Edit a file that requires superuser permissions without running the editor as root +# Substitute for sudo -e that uses doas instead. + +fname=$(mktemp) + +cat $1 > $fname +$EDITOR $fname + +if [ -n "$(diff $fname $1)" ] + then + diff $fname $1 + doas cp $fname $1 +fi + +rm $fname