Skip to content

Instantly share code, notes, and snippets.

@dimagimburg
Created May 1, 2017 10:04
Show Gist options
  • Save dimagimburg/e9f32a88b4ab0330d97e41743f3ce276 to your computer and use it in GitHub Desktop.
Save dimagimburg/e9f32a88b4ab0330d97e41743f3ce276 to your computer and use it in GitHub Desktop.
A bash script that helps me automate creating executable bash shell scripts
#!/usr/bin/env bash
FILENAME=$1
if [ $# -ne 1 ]
then
echo "Usage: vibash FILENAME"
exit
fi
if [ "${FILENAME##*.}" != "sh" ]
then
FILENAME="${FILENAME}.sh"
fi
cat <<END > $FILENAME
#!/usr/bin/env bash
#
# File path: `pwd`/$FILENAME
# Created at: `date +%Y-%m-%d:%H:%M:%S`
# By: `whoami`
#
END
chmod +x $FILENAME
vi "+normal G$" +startinsert $FILENAME # moves cursor to the end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment