You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
422 B
Bash

#!/usr/bin/env bash
test ! -n "${SCRIPTS}" && echo "SCRIPTS not set" && exit 1;
test ! -n "${1}" && echo "usage: newscript <name>" && exit 1;
path="${SCRIPTS}/${1}"
if test -e "${path}"; then
read -p "${1} already exists. Edit? " yes
case "${yes}" in
y|yes|yep|yeppers|yeah|ok|okay) exec vim "${path}"
esac
exit 0
fi
printf "#!/usr/bin/env bash\n\n" > "${path}"
chmod +x "${path}"
exec vim +2 "${path}"