Reputation: 4037
I have just written a python script to do some batch file operations. I was wondering how i could keep it in some common path like rest of the command line utilities like cd, ls, grep etc.
What i expect is something like this to be done from any directory -
$ script.py arg1 arg2
Upvotes: 0
Views: 248
Reputation: 1779
An alternative approach is to create a python package with entry points and install the program, rather than changing $PATH
(using setuptools
in setup.py
). This has some advantages:
See Explain Python entry points? and python: simple example for a python egg with a one-file source file? for details.
This has the advantage of keeping all your settings in one place.
You can use the --develop
option so that you can still edit your code in place and the --user
option to avoid messing python for other users.
Upvotes: 0
Reputation: 34657
Add the directory it is stored in to your PATH variable? From your prompt, I'm guessing you're using an sh-like shell and from your tags, I'm further assuming OS X. Go into your .bashrc and make the necessary changes.
Upvotes: 0
Reputation: 387557
Just put the script directory into the PATH environment variable, or alternatively put the script in a location that is already in the PATH. On Unix systems, you usually use /home/<nick>/bin
for your own scripts and add that to the PATH.
Upvotes: 1