Home > documentation, open source software, Sage > Add colour to your Sage session

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 🙂

Advertisements
  1. Robert Samal
    26 May 2009 at 12:10 am

    Nice — only when I try it, “something breaks”: when I pres tab to complete
    a command, the terminal forgets about the position of cursor, and then I will write several times over one place. (I hope you undestand what I mean …)

  2. 31 May 2009 at 11:17 pm

    Hi Robert. I don’t really understand what you mean. Can you explain to me what went wrong, and give as precise information as possible about the Sage version you used, your operating systems, etc.

  3. Micah
    23 July 2009 at 1:51 am

    For what it’s worth, I had to also change the ipy_user_conf.py to get the colors to work correctly at the beginning of each session. In particular, I had to uncomment the line

    o.autoexec.append(‘%colors Linux’)

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: