2020-06-03 23:10:31 -05:00
|
|
|
#!/bin/sh
|
2020-04-12 03:41:42 -05:00
|
|
|
|
|
|
|
# script to automate generation of executable shell scripts
|
|
|
|
|
2020-06-03 23:10:31 -05:00
|
|
|
FILE="$1"
|
|
|
|
SHELL="$2"
|
2020-04-12 03:41:42 -05:00
|
|
|
|
2020-06-03 23:10:31 -05:00
|
|
|
if [ -z "$FILE" ]
|
2020-04-12 03:41:42 -05:00
|
|
|
then
|
|
|
|
echo "No file name specified."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-06-03 23:10:31 -05:00
|
|
|
if [ -e "$FILE" ]
|
2020-04-12 03:41:42 -05:00
|
|
|
then
|
|
|
|
echo "File already exists."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-06-03 23:10:31 -05:00
|
|
|
printf "#!/bin/%s\n\n\n" "${SHELL:-sh}" > "$FILE"
|
2020-04-12 03:41:42 -05:00
|
|
|
|
2020-06-03 23:10:31 -05:00
|
|
|
touch "$FILE"
|
|
|
|
chmod +x "$FILE"
|
|
|
|
exec "${EDITOR:-nvim}" "$FILE" '+$'
|