30 lines
583 B
Text
Executable file
30 lines
583 B
Text
Executable file
# !/bin/sh
|
|
# This utility pre-allocs a file and adds execution permissions. It also
|
|
# removes the resulting file if it is empty after the editor closes.
|
|
|
|
DAISY_INTERNAL=1
|
|
. $(dirname $(realpath $0))/daisy.source
|
|
|
|
if [[ -z $1 ]];
|
|
then
|
|
echo "No filename specified."
|
|
exit 2
|
|
fi
|
|
|
|
if [[ -z "${EDITOR}" ]];
|
|
then
|
|
ched "EDITOR env variable not set! You will have to set it yourself in the next screen."
|
|
fi
|
|
|
|
exists=$(file "$1" >/dev/null && echo $?)
|
|
|
|
touch "$1"
|
|
chmod +x "$1"
|
|
$EDITOR "$1"
|
|
wait $!
|
|
size=$(du "$1" | cut -f 1)
|
|
|
|
if [[ $size -eq 0 && $exists -ne 0 ]];
|
|
then
|
|
rm -rf "$1"
|
|
fi
|