Ask Your Question

Revision history [back]

If you are adding this directory to your path so that you can load files from it, you can use the environment variable LOAD_ATTACH_PATH. It is described in the section about the preparser in the reference manual.

If you want to modify the path for some other reason, or execute other shell commands on startup, maybe looking closely at the sage startup script will help: $SAGE_ROOT/sage is a bash script which, after doing some other things, calls $SAGE_ROOT/local/bin/sage-sage. Many things happen there, but in particular you will see a function sage_setup, which prints the startup banner and then does some other stuff which I don't understand. If you add something like

export PATH=$PATH:/my/new/directory

just after this block

# Display the startup banner
if [ "$SAGE_BANNER" != "no" ]; then
    cat "$SAGE_LOCAL/bin/sage-banner"
fi

then when you start sage and type sage: os.environ.get('PATH'), you will see that your new directory is now included! Of course this is a terrible way to accomplish this, since upgrading sage will overwrite this file and your changes will be lost, but maybe you can think of some ways to modify it into a workable solution, or maybe poking around in the sage startup files will help you find a better solution.

click to hide/show revision 2
deleted terrible idea, replacing it with reference to good idea

If you are adding this directory to your path so that you can load files from it, you can use the environment variable LOAD_ATTACH_PATH. It is described in the section about the preparser in the reference manual.

If you want to modify the path for some other reason, or execute other shell commands on startup, maybe looking closely at you could use the sage startup script will help: $SAGE_ROOT/sage is a bash script which, after doing some other things, calls $SAGE_ROOT/local/bin/sage-sage. Many things happen there, but in particular you will see a function sage_setup, which prints the startup banner and then does some other stuff which I don't understand. If you add something likeanswer posted to this question:

export PATH=$PATH:/my/new/directory

just after this blockhttp://ask.sagemath.org/question/1072/preload-defined-functions-for-later-use

# Display the startup banner
if [ "$SAGE_BANNER" != "no" ]; then
    cat "$SAGE_LOCAL/bin/sage-banner"
fi

then when you start sage and type sage: os.environ.get('PATH'), you will see that your new directory is now included! Of course this is a terrible way to accomplish this, since upgrading sage will overwrite this file and your changes will be lost, but maybe you can think of some ways to modify it into a workable solution, or maybe poking around in the sage startup files will help you find a better solution.