1 回答
To add ~/bin to your path:
First, we make the folder (if it isn't already made).
mkdir ~/binCopy
batcharge.pyinto~/bin:cp batcharge.py ~/bin/batcharge.py(Obviously you'll want to do this from where-ever the
batcharge.pyscript is located).Check if
~/binis in your path:echo $PATH | grep ~/binThis 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:~/binThis will add
~/binto 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~/binat the end of the long-ish list of paths).
Now, we test: you should be able to type
which batcharge.pyand see thatzshknows where to find it. For example, typewhich batcharge.pyin terminal, and you should see something like:/Users/simont/bin/batcharge.pyNow we can type
batcharge.pyand see the script run :)