48 lines
1.0 KiB
Plaintext
48 lines
1.0 KiB
Plaintext
nano () {
|
|
if [ -f "$1" ]; then
|
|
if [ -w "$1" ]; then
|
|
command nano $*
|
|
else
|
|
echo "Unwritable file, openning through sudoedit"
|
|
VISUAL=nano command sudoedit $(realpath $*)
|
|
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"
|
|
VISUAL=vim command sudoedit $(realpath $*)
|
|
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
|
|
}
|