Created
August 5, 2013 19:57
-
-
Save nagataka/6159029 to your computer and use it in GitHub Desktop.
This is a script to automate writing shebang at the top of the file.
You can add any extension to 'case' statement.
This file contains 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
#!/bin/sh | |
#set this script as alias of editor like | |
#alias vim='/path/shebang.sh' | |
if [ "${1}" = "" ]; then | |
vim | |
fi | |
filename=${1} | |
if [ -e $filename ]; then | |
vim $filename | |
else | |
case $filename in | |
*\.rb) touch $filename | |
echo '#!'`which ruby` > $filename | |
vim $filename;; | |
*\.py) touch $filename | |
echo '#!'`which python` > $filename | |
vim $filename;; | |
*\.sh) touch $filename | |
echo '#!'`which sh` > $filename | |
vim $filename;; | |
*) vim $filename;; | |
esac | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment