Created
May 1, 2017 10:04
-
-
Save dimagimburg/e9f32a88b4ab0330d97e41743f3ce276 to your computer and use it in GitHub Desktop.
A bash script that helps me automate creating executable bash shell scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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