1 | initial version |
My init.sage
is as follows. It is run at the start of each Sage REPL session.
### Set colors depending on terminal background color
# Set color -- valid schemes: 'NoColor', 'Linux', 'LightBG', Neutral', ''
%colors Linux
### Custom banner, displays even when starting Sage in quiet mode with `sage -q`
print("\n# SageMath {}, released {}, based on Python {}.{}.{}."
.format(sage.version.version, sage.version.date, *sys.version_info[:3]))
print("""
sage: %colors Linux
""")
It includes two commands that print things out, and that works fine.
Beware that print
is a function in Python 3, while it was a statement in Python 2.
So make sure you use print(...)
rather than print ...
.
2 | No.2 Revision |
My init.sage
is as follows. It is run at the start of each Sage REPL session.
### Set colors depending on terminal background color
# Set color -- valid schemes: 'NoColor', 'Linux', 'LightBG', Neutral', ''
%colors Linux
### Custom banner, displays even when starting Sage in quiet mode with `sage -q`
print("\n# SageMath {}, released {}, based on Python {}.{}.{}."
.format(sage.version.version, sage.version.date, *sys.version_info[:3]))
### Set colors depending on terminal background color
# Set color -- valid schemes: 'NoColor', 'Linux', 'LightBG', Neutral', ''
print("""
sage: # To set the color scheme, use one of the following,
# where 'LightBG' is well suited for light background,
# while 'Linux' is well suited for dark background:
%colors LightBG
%colors Linux
%colors Neutral
%colors NoColor
# This can also be changed in the IPython configuration file,
# see answer by Sébastien to Ask Sage question
""")
It includes two commands that print things out, and that works fine.
Beware that print
is a function in Python 3, while it was a statement in Python 2.
So make sure you use print(...)
rather than print ...
.
I'm not sure whether init.sage
is executed when starting a Jupyter worksheet
with the SageMath kernel; and if it is, I'm not sure where things are printed to;
any print statements might be lost.
As a workaround, you could execute the following in the first cell of your Jupyter sheets:
load(sage.env.SAGE_STARTUP_FILE)