Search code examples
zsh

Source doesn't work in zsh (os x 10.12)


In bashrc case, I could be just input the source line like this,

source /my/path/etc

As far as i know, zshrc also can input that line. but there was happen error.

ERROR: geant4.sh could NOT self-locate GEANT4 installation

This is most likely because you are using ksh, zsh or similar

To fix this issue, cd to the directory containing this script

and source it in that directory

And I can't understand last sentence starting for "To fix this issue", If you have any idea, please tell me.


Solution

  • You can use pushd and popd to temporarily change directories within your .zshrc file (that's a rough explanation, see this post).

    To automatically source geant4.sh with zsh, add this line to your .zshrc file:

    pushd /path/to/script >/dev/null; . /path/to/script/geant4.sh; popd >/dev/null
    

    The >/dev/null is just directing the output to null so the sourcing doesn't cause anything to appear on your terminal when you open it.