Add colour to your Sage session
For those Sage users who often work with the command line interface to Sage, a default Sage command line session is something like the following:
The default settings give you little to no colour in order to distinguish between different input and output. On the sage-support mailing list, I’ve seen many people requesting colour support for a terminal session. So here are some tips on getting colour into your command line session.
Sage uses IPython in order to bring users the interactive features that they get via a command line session. The configuration file $HOME/.sage/ipython/ipythonrc can be customized to your heart’s content. In particular, after installing Sage your $HOME/.sage/ipython/ipythonrc file has the following snippet:
# LightBG is similar to Linux but swaps # dark/light colors to be more readable # in light background terminals. # keep uncommented only the one you want: #colors Linux #colors LightBG colors NoColor
Note the configuration option colors NoColor, which accounts for the often ugly look you get by default with a command line session (see Figure 1). You can uncomment the section that suits your colour preferences. I usually prefer a terminal session with dark background, so I use the configuration option colors Linux to get something like the following:
But if you’re curious about what the option colors LightBG does, then look no further than what’s shown in Figure 3. Some people like their terminal background to be light, so this figure should give you some indication of what it looks like within a command line Sage session.
The colour that you get also depends on how you set the colours for your particular terminal. Tweak the colour settings of your terminal and see what happens. Until next time, put some colour into your life 🙂