sonnerberg / add_python_shebang

Add python shebang to python files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add shebang to python files

GitHub repo size GitHub contributors GitHub stars GitHub forks

Add shebang to python files is a utility that allows python developers to add a shebang to their Python files.

This script can be used to add a shebang to a python file, and also a Module Docstring and if __name__ == '__main__' to empty Python files. Personally I use it in vscode with Run on Save.

Installing add shebang to python files

To install add shebang to python files, follow these steps:

Linux and macOS:

  • Clone this repo
  • Copy add_shebang_cli.py to your PATH
  • Make add_shebang_cli.py executable with chmod +x add_shebang_cli.py

Using add shebang to python files

To use add shebang to python files, follow these steps:

  • Add the following lines in settings.json in vscode:
    "runOnSave.commands": [
        {
            "match": ".*\\.py$",
            "command": "add_shebang_cli.py ${file}",
            "runIn": "backend"
        }
    ]

Your python files will now be checked for shebang and if it's not present it will be added.

asciicast

Add run commands and examples you think users will find useful. Provide an options reference for bonus points!

Contributing to add shebang to python files

To contribute to add shebang to python files, follow these steps:

  1. Fork this repository.
  2. Create a branch: git checkout -b <branch_name>.
  3. Make your changes and commit them: git commit -m '<commit_message>'
  4. Push to the original branch: git push origin <project_name>/<location>
  5. Create the pull request.

Alternatively see the GitHub documentation on creating a pull request.

License

This project uses the following license: MIT License.

About

Add python shebang to python files.


Languages

Language:Python 100.0%