I made a fancy-pants Ipython command prompt for BMM.  It shows the mode of the photon delivery system, the crystal set in use, the state of the front-end and photon shutters, and the ring current in a very compact form.  This page documents how I did this.

This works much less well in bsui as of January 2019. Most of the tokens below show up as normal
Prompt.png
white text.  OutPromptNum and Tilde have been replaced by Prompt and OutPrompt (green and red).

Here is a snippet from one of BMM's startup files that shows how the prompt is customized. (And here is the documentation.)

from IPython.terminal.prompts import Prompts, Token
class MyPrompt(Prompts):
    def in_prompt_tokens(self, cli=None):
        if idps.state.value == 0:
            shatoken = (Token.OutPromptNum, ' A')
        else:
            shatoken = (Token.Tilde, ' A')

        if shb.state.value == 1:
            shbtoken = (Token.OutPromptNum, 'B')
        else:
            shbtoken = (Token.Tilde, 'B')

        return [(Token.CursorLine, 'BMM '),
                (Token.CursorLine, '%s.%s' % (BMM_config._mode, dcm._crystal)),
                shatoken,
                (Token.Prompt, u'\u2022'),
                shbtoken,
                (Token.Comment, ' %.1f ' % ring.current.value),
                (Token.Prompt, '['),
                (Token.PromptNum, str(self.shell.execution_count)),
                (Token.Prompt, '] ' + u"\u25B6"+' ')]

ip = get_ipython()
ip.prompts = MyPrompt(ip)

The function in_prompt_tokens() is used to define the normal command line. The other prompts are set by customizing continuation_prompt_tokens(), rewrite_prompt_tokens(), and out_prompt_tokens(). The return value is a list of tuples. Each tuple contains the token and the string to be decorated with that token. BMM_config._mode, dcm._crystal, and ring.current.value are scalars defined elsewhere in BMM's startup. The unicode numbers make the circle and right-pointing triangle. str(self.shell.execution_count) makes the bright green number that indicates the number of commands entered in the Ipython session. The point of all this is to show that the prompt can have truly anything in it.


I had trouble finding documentation for the definitions of the tokens, so I wrote a little tool for exploring their values.  Here is the code:

def explore_tokens(i):
    tokens = ('Aborted', 'AutoSuggestion', 'ColorColumn', 'Comment',
              'CursorColumn', 'CursorLine', 'Digraph', 'Error',
              'Escape', 'Generic', 'Keyword', 'LeadingWhiteSpace',
              'LineNumber', 'Literal', 'MatchingBracket', 'Menu',
              'MultipleCursors', 'Name', 'Number', 'Operator',
              'Other', 'OutPrompt', 'OutPromptNum', 'Prompt',
              'PromptNum', 'Punctuation', 'Scrollbar', 'SearchMatch',
              'SelectedText', 'SetCursorPosition', 'String', 'Tab',
              'Text', 'Tilde', 'Token', 'Toolbar',
              'TrailingWhiteSpace', 'Transparent', 'WindowTooSmall',
              'ZeroWidthEscape')
    class MyPrompt(Prompts):
        def in_prompt_tokens(self, cli=None):
            return [(getattr(Token, tokens[i]), 'BMM >'),]
    ip = get_ipython()
    ip.prompts = MyPrompt(ip)
    return 'Token.%s' % tokens[i]

And here are screenshots of the colors and decorations generated by each token.  As you can see, the color palette is somewhat limited and many of the tokens simply return normal, white text.




RTENOTITLE
RTENOTITLE
RTENOTITLE