Configuration

Marcel is customized on startup by executing ~/.marcel.py. You don't need to create this file, it will be created for you the first time you run marcel. What ~/.marcel.py does is to initialize the marcel namespace -- it defines symbols that are available for use in marcel commands, or that customize marcel's behavior.

The default ~/.marcel.py begins with an import:

from marcel.builtin import *

This brings in a few functions and types that are important in marcel usage. For example, the symbol now is defined to be time.time(), allowing you to call now() to obtain seconds since the epoch:

The default ~/.marcel.py also provides a rudimentary definition of PROMPT, which controls the appearance of your shell prompt:

PROMPT = [lambda: PWD, ' $ ']

PWD is the environment variable identifying your current directory. lambda: PWD creates a function, returning the value of PWD each time a prompt is displayed. ' $ ' is a string printed following the value of PWD. This definition results in a prompt that looks like this:

A more sophisticated prompt can be created with other environment variables, and adding colors (described below). This prompt specification:

PROMPT = [
    Color(5, 0, 0, BOLD),
    'M-',
    MARCEL_VERSION,
    ' ',
    Color(2, 1, 0, BOLD),
    USER,
    '@',
    HOST,
    Color(5, 5, 5),
    ':',
    Color(3, 2, 0, BOLD),
    lambda: ('~' + PWD[len(HOME):]) if PWD.startswith(HOME) else PWD,
    '$ '
]

results in this prompt:

Another variable, PROMPT_CONTINUATION defines the prompt to be used for multi-line commands.

Marcel colorizes its prompt, and the output describing some objects, e.g. Files and Processes.  Marcel provides two types, Color and ColorScheme, so that you can customize colorization.

A Color is constructed by providing RGB (red/green/blue) values, in the range 0-5. So white would be Color(5, 5, 5), and pure red would be Color(5, 0, 0). Colors are applied to text, and you can include styling attributes BOLD, ITALIC or both (BOLD | ITALIC) as a last argument to Color, e.g. Color(5, 3, 0, BOLD).

A ColorScheme is a set of colors for specific purposes. The default configuration file, generated on startup, includes a commented-out ColorScheme definition. If you'd like, remove the # characters, and then see the effect using this color scheme, by running the ls or ps operator.  You can also add colors to the prompt, as shown above. In both cases, the changes to configuration will take effect as soon as the changes are saved.
 

  • github
  • Twitter
  • email