2018-03-16 12:02:58 +01:00
|
|
|
nano () {
|
|
|
|
if [ -f "$1" ]; then
|
|
|
|
if [ -w "$1" ]; then
|
|
|
|
command nano $*
|
|
|
|
else
|
|
|
|
echo "Unwritable file, openning through sudoedit"
|
2018-07-03 09:18:13 +02:00
|
|
|
VISUAL=nano command sudoedit $(realpath $*)
|
2018-03-16 12:02:58 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -d "`dirname \"$1\"`" ]; then
|
|
|
|
if [ -w "`dirname \"$1\"`" ]; then
|
|
|
|
command nano $*
|
|
|
|
else
|
|
|
|
echo "Unwritable file, openning through sudoedit"
|
|
|
|
VISUAL=nano command sudoedit $*
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Unexpected result..."
|
|
|
|
read
|
|
|
|
command nano $*
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
vim () {
|
|
|
|
if [ -f "$1" ]; then
|
|
|
|
if [ -w "$1" ]; then
|
|
|
|
command vim $*
|
|
|
|
else
|
|
|
|
echo "Unwritable file, openning through sudoedit"
|
2018-07-03 09:18:13 +02:00
|
|
|
VISUAL=vim command sudoedit $(realpath $*)
|
2018-03-16 12:02:58 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -d "`dirname \"$1\"`" ]; then
|
|
|
|
if [ -w "`dirname \"$1\"`" ]; then
|
|
|
|
command vim $*
|
|
|
|
else
|
|
|
|
echo "Unwritable file, openning through sudoedit"
|
|
|
|
VISUAL=vim command sudoedit $*
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Unexpected result..."
|
|
|
|
read
|
|
|
|
command vim $*
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|