We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track

I create a fair few scripts in my
~/bin/
directory to automate tasks. Since discoveringuv
and inline script metadata, I’ve started using Python far more for these.As ~/bin is on my path, I want to run the script by calling it directly on the command line. To do this, I use this shebang:
#!/usr/bin/env -S uv run --script
The command line will now run
uv run --script
and pass the file as the argument.uv
ignores the shebang and then runs the rest of the file as a normal Python file.Once I’ve ensured that that script has executable permissions via
chmod a+x {filname}
, I’m now good to go with simple command line scripts written in Python that automatically handle their dependencies!
continue reading on akrabat.com
⚠️ This post links to an external website. ⚠️
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.