jupyter_console icon indicating copy to clipboard operation
jupyter_console copied to clipboard

Jupyter console configuration for colors

Open unode opened this issue 7 years ago • 9 comments

Ipython has c.InteractiveShell.colors and %colors.

With jupyter-console only %colors seems to be available. This option seems to have existed in jupyter console 4.0.1 but not on the latest.

Otherwise the only reference I've managed to find so far on google groups mentions its use but with a different goal: --simple-prompt.

With that said, is there any way to configure jupyter-console to always use a given colorscheme?

unode avatar Apr 16 '18 20:04 unode

Actually I correct my previous post. %colors (e.g %colors Linux) seems to have no effect in jupyter-console - 5.2.0, so there seems to be a problem here too.

unode avatar Apr 16 '18 21:04 unode

There are two sources of colours

  • Things like the prompts are controlled by the frontend. It looks like we have no config option to affect this at the moment.
  • Things like help? output are produced by the kernel, so %colors and IPython config should affect these.

takluyver avatar Apr 17 '18 08:04 takluyver

I was able to change the colors and font by launching the Developer Console and typing:

terminal.term.setOption('fontFamily', 'Fira Code');
terminal.term.setOption('theme', {
  foreground:    '#d4d4d4',
  background:    '#2d2d2d',
  black:         '#646464',
  brightBlack:   '#646464',
  red:           '#f58e8e',
  brightRed:     '#f58e8e',
  green:         '#a9d3ab',
  brightGreen:   '#a9d3ab',
  yellow:        '#fed37e',
  brightYellow:  '#fed37e',
  blue:          '#7aabd4',
  brightBlue:    '#7aabd4',
  magenta:       '#d6add5',
  brightMagenta: '#d6add5',
  cyan:          '#79d4d5',
  brightCyan:    '#79d4d5',
  white:         '#d4d4d4',
  brightWhite:   '#d4d4d4',
});

I was also able to hide the scrollbar by replacing the overflow-y: scroll with overflow-y: hidden style from .terminal .xterm CSS class. See the screenshot below:

screenshot from 2018-11-13 12-07-05

I'm willing to create a PR to enable these options in the Jupyter Console configuration, but I need some time understanding how to do this as I've never worked with Jupyter Extensions. If anyone can give me any hints, I'll be very happy :smile:

ianliu avatar Nov 13 '18 14:11 ianliu

I was able to change the colors and font by launching the Developer Console and typing:

terminal.term.setOption('fontFamily', 'Fira Code');
terminal.term.setOption('theme', {
  foreground:    '#d4d4d4',
  background:    '#2d2d2d',
  black:         '#646464',
  brightBlack:   '#646464',
  red:           '#f58e8e',
  brightRed:     '#f58e8e',
  green:         '#a9d3ab',
  brightGreen:   '#a9d3ab',
  yellow:        '#fed37e',
  brightYellow:  '#fed37e',
  blue:          '#7aabd4',
  brightBlue:    '#7aabd4',
  magenta:       '#d6add5',
  brightMagenta: '#d6add5',
  cyan:          '#79d4d5',
  brightCyan:    '#79d4d5',
  white:         '#d4d4d4',
  brightWhite:   '#d4d4d4',
});

I was also able to hide the scrollbar by replacing the overflow-y: scroll with overflow-y: hidden style from .terminal .xterm CSS class. See the screenshot below:

screenshot from 2018-11-13 12-07-05

I'm willing to create a PR to enable these options in the Jupyter Console configuration, but I need some time understanding how to do this as I've never worked with Jupyter Extensions. If anyone can give me any hints, I'll be very happy 😄

Hi, I want to change the color of jupyter terminal page , and your picture shows

terminal.term.setOption('fontFamily', 'Fira Code');

Hi, I'm looking for a way to change the jupyter terminal page's color and font, luckily, I found this issue and your picture's url seems to be jupyter terminal page, I tried your code in jupyter console and terminal , both failed, could you please tell me how to do that please? Thanks

alayamanas avatar Jun 06 '19 06:06 alayamanas

Just for reference, this jupyter_console repository is for a Jupyter frontend that runs in a terminal. It's nothing to do with the HTML terminal you can get as part of the Jupyter Notebook interface. That is implemented by xtermjs, and integrated into Jupyter in the jupyter/notebook repo.

takluyver avatar Jun 06 '19 15:06 takluyver

Just for reference, this jupyter_console repository is for a Jupyter frontend that runs in a terminal. It's nothing to do with the HTML terminal you can get as part of the Jupyter Notebook interface. That is implemented by xtermjs, and integrated into Jupyter in the jupyter/notebook repo.

Thank you for the infomation, I have already done.

alayamanas avatar Jun 10 '19 23:06 alayamanas

The only config I found for the prompt colors is ZMQTerminalInteractiveShell.true_color, but there’s none to set it to 8 colors. The green it uses clashes with my terminal background, prompts are near invisible.

flying-sheep avatar Jul 17 '19 10:07 flying-sheep

Ah, so I need to override this:

# ~/.ipython/profile_default/ipython_config.py
from pygments.token import Token

c = get_config()

c.TerminalInteractiveShell.highlighting_style_overrides = {
    Token.Prompt: '#ansigreen',
    Token.PromptNum: '#ansidarkgreen bold',
    Token.OutPrompt: '#ansired',
    Token.OutPromptNum: '#ansidarkred bold',
}

Why is this not the default?

References:

  • https://github.com/jupyter/jupyter_console/blob/5755ec42a95b70492813be4a6bb8342015126062/jupyter_console/ptshell.py#L413-L438
  • https://github.com/prompt-toolkit/python-prompt-toolkit/blob/d3ad16dd7baf50267b7c6ee8b56d6f49008075f6/prompt_toolkit/styles/base.py#L51-L61

flying-sheep avatar Oct 02 '19 10:10 flying-sheep

I'm finding that in Jupyter Console 6.1.0 (IPython 7.12.0, Python 3.7.6), c.TerminalInteractiveShell.highlighting_style_overrides (as suggested by the auto-generated ipython_config.py) is not being picked up by ZMQTerminalInteractiveShell. Using c.ZMQTerminalInteractiveShell doesn't work either. It seems like the entire configurability of ZMQTerminalInteractiveShell is broken.

mjkramer avatar Feb 14 '20 06:02 mjkramer