RASH configuration

class rash.config.Configuration

RASH configuration interface.

If you define an object named config in the configuration file, it is going to be loaded by RASH. config must be an instance of Configuration.

configuration file
In unix-like systems, it’s ~/.config/rash/config.py or different place if you set XDG_CONFIG_HOME. In Mac OS, it’s ~/Library/Application Support/RASH/config.py. Use rash locate config to locate the exact place.

Example:

>>> from rash.config import Configuration
>>> config = Configuration()
>>> config.isearch.query = '-u .'

Here is a list of configuration variables you can set:

Configuration variables  
config.record.environ Environment variables to record.
config.search.alias Search query alias.
config.search.kwds_adapter Transform keyword arguments.
config.isearch.query Default isearch query.
config.isearch.query_template Transform default query.
config.isearch.base_query Default isearch base query.
class rash.config.RecordConfig

Recording configuration.

environ = None

Environment variables to record.

Each key (str) represent record type (init/exit/command). Each value (list of str) is a list of environment variables to record.

Example usage:

>>> config = Configuration()
>>> config.record.environ['command'] += ['VIRTUAL_ENV', 'PYTHONPATH']
class rash.config.SearchConfig

Search configuration.

alias = None

Search query alias.

It must be a dict-like object that maps a str to a list of str when “expanding” search query.

Example:

>>> config = Configuration()
>>> config.search.alias['test'] = \
...     ["--exclude-pattern", "*rash *", "--include-pattern", "*test*"]

then,:

rash search test

is equivalent to:

rash search --exclude-pattern "*rash *" --include-pattern "*test*"
kwds_adapter = None

A function to transform keyword arguments.

This function takes a dictionary from command line argument parser and can modify the dictionary to do whatever you want to do with it. It is much more lower-level and powerful than alias. This function must return the modified, or possibly new dictionary.

Example definition that does the same effect as the example in alias:

>>> def adapter(kwds):
...     if 'test' in kwds.get('pattern', []):
...         kwds['pattern'] = [p for p in kwds['pattern']
...                            if p != 'test']
...         kwds['exclude_pattern'].append("*rash *")
...         kwds['include_pattern'].append("*test*")
...     return kwds
...
>>> config = Configuration()
>>> config.search.kwds_adapter = adapter
class rash.config.ISearchConfig

Configure how rash isearch is started.

See also SearchConfig. Once isearch UI is started, SearchConfig controls how search query is interpreted. For example, aliases defined in SearchConfig can be used in isearch.

query = None

Set default value (str) for --query option.

If you want to start isearch with the query -d . (only list the command executed at this directory), use the following configuration:

>>> config = Configuration()
>>> config.isearch.query = '-d . '

As rash-zle-isearch passes the current line content to --query which override this setting, you need to use query_template instead if you want to configure the default query.

query_template = None

Transform default query using Python string format.

The string format should have only one field {0}. The query given by -query or the one specified by query fills that filed. Default value is do-nothing template '{0}'.

>>> config = Configuration()
>>> config.isearch.query_template = '-d . {0}'
base_query = None

Set default value (list of str) for --base-query option.