Configuration¶
Dish is very easy to configure. To set a configuration value, you simply just do
this, where dish
is a Dish object:
dish.config['NAME'] = 'value'
Registering Extensions¶
Extensions can do many things in Dish, such as adding new XML tags that can be used in PS1. This is how you register an extension:
import my_extension
dish.register_extension(my_extension)
Some extensions have additional parameters you can pass to the
register_exetnsion
method.
Configuring the Prompt String¶
The PS1
string is configured like this:
dish.config['PS1'] = '$ '
Special styles and values are inserted using XML tags. Dish comes with a built-in
extension called ansicolor
, which allows you to use ANSI colors in your
prompt by using CSS color names. Here is an example:
from dish.ext import ansicolor
dish.register_extension(ansicolor)
dish.config['PS1'] = '<color fg="green">$</color> '
Note
Due to a bug in prompt_toolkit, some
color names do not work and will cause a ValueError
.
There is also a feature called prompt predicates. This allows you to only display
part of a prompt if a certain condition is met. For example, the
prompt_goodies
extension has one called “git” that returns true if you are
currently in a Git repository. Here is an example of how to use it:
dish.config['PS1'] = '<if_git>We\'re in a Git repository </if_git> $ '