Created
March 31, 2023 14:54
-
-
Save ab/8088d6e893b1e0bafe7a8c0dd342951e to your computer and use it in GitHub Desktop.
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/bash | |
if [ $# -eq 0 ]; then | |
cat >&2 <<EOM | |
usage: poetry-shebang FILE | |
Install this script somewhere on your \$PATH -- such as /usr/local/bin/ -- to | |
be able to seamlessly run Python scripts under \`poetry run\` without having to | |
type that out. | |
Add this shebang to your script, and make it executable: | |
#!/usr/bin/env poetry-shebang | |
EOM | |
exit 1 | |
fi | |
script="$1" | |
shift | |
script_folder="$(dirname "$script")" | |
script_file="$(basename "$script")" | |
cd "$script_folder" && exec poetry run python "$script_file" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment