1 回答
To add ~/bin
to your path:
First, we make the folder (if it isn't already made).
mkdir ~/bin
Copy
batcharge.py
into~/bin
:cp batcharge.py ~/bin/batcharge.py
(Obviously you'll want to do this from where-ever the
batcharge.py
script is located).Check if
~/bin
is in your path:echo $PATH | grep ~/bin
This should come back with a line. If it does not, we shall add it:
Open
~/.zshrc
.At the end, add the line:
export PATH=$PATH:~/bin
This will add
~/bin
to your$PATH
.Close the terminal window, and re-open it. (Or open a new one).
Type
echo $PATH | grep ~/bin
. This should now show a line (and you should see~/bin
at the end of the long-ish list of paths).
Now, we test: you should be able to type
which batcharge.py
and see thatzsh
knows where to find it. For example, typewhich batcharge.py
in terminal, and you should see something like:/Users/simont/bin/batcharge.py
Now we can type
batcharge.py
and see the script run :)