0
4

1 回答 1

1

To add ~/bin to your path:

  1. First, we make the folder (if it isn't already made).

    mkdir ~/bin
    
  2. 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).

  3. 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:

    1. Open ~/.zshrc.

    2. At the end, add the line:

      export PATH=$PATH:~/bin
      

      This will add ~/bin to your $PATH.

    3. Close the terminal window, and re-open it. (Or open a new one).

    4. 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).

  4. Now, we test: you should be able to type which batcharge.py and see that zsh knows where to find it. For example, type which 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 :)

于 2012-05-24T18:17:30.490 回答