2014-05-21 21:17:45 +00:00
|
|
|
# Sebastian Raschka 05/21/2014
|
|
|
|
# Shell script that prepends a Python shebang
|
2014-05-21 21:50:18 +00:00
|
|
|
# e.g., `!#/usr/bin/python` to all
|
2014-05-21 21:17:45 +00: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 21:52:09 +00:00
|
|
|
# prepends e.g., !#/usr/bin/python to all .py files
|
2014-05-21 21:44:05 +00:00
|
|
|
|
2014-05-21 21:17:45 +00:00
|
|
|
find ./ -maxdepth 1 -name "*.py" -exec sed -i.bak '1i\
|
2014-05-21 21:49:47 +00:00
|
|
|
#!'"$(which python)"'
|
2014-05-21 21:17:45 +00:00
|
|
|
' {} \;
|
|
|
|
|
2014-05-21 21:26:28 +00:00
|
|
|
# removes temporary files
|
|
|
|
find . -name "*.bak" -exec rm -rf {} \;
|
|
|
|
|
|
|
|
# makes Python scripts executable
|
|
|
|
chmod ug+x *.py
|