2014-05-21 17:17:45 -04:00
|
|
|
# Sebastian Raschka 05/21/2014
|
|
|
|
# Shell script that prepends a Python shebang
|
2014-05-21 17:50:18 -04:00
|
|
|
# e.g., `!#/usr/bin/python` to all
|
2014-05-21 17:17:45 -04:00
|
|
|
# Python script files in the current directory
|
|
|
|
# so that script files can be executed via
|
|
|
|
# >> myscript.py
|
|
|
|
# instead of
|
|
|
|
# >> python myscript.py
|
|
|
|
|
2014-05-21 17:26:28 -04:00
|
|
|
# prepends !#/usr/bin/python to all .py files
|
2014-05-21 17:44:05 -04:00
|
|
|
|
2014-05-21 17:17:45 -04:00
|
|
|
find ./ -maxdepth 1 -name "*.py" -exec sed -i.bak '1i\
|
2014-05-21 17:49:47 -04:00
|
|
|
#!'"$(which python)"'
|
2014-05-21 17:17:45 -04:00
|
|
|
' {} \;
|
|
|
|
|
2014-05-21 17:26:28 -04:00
|
|
|
# removes temporary files
|
|
|
|
find . -name "*.bak" -exec rm -rf {} \;
|
|
|
|
|
|
|
|
# makes Python scripts executable
|
|
|
|
chmod ug+x *.py
|