dotfiles/.local/bin/scripts/edit
2021-01-23 19:55:22 +01:00

8 lines
215 B
Bash
Executable file

#!/bin/sh
test ! -f "$1" && ( mkdir -p $(dirname "$1") || sudo mkdir -p $(dirname "$1") )
echo "Editing $1..."
if test -w "$1" || (test ! -f "$1" && test -w $(dirname "$1"))
then $EDITOR "$1"
else sudoedit "$1"
fi