Base prompt formatter (xonsh.prompt.base
)¶
Base prompt, provides PROMPT_FIELDS and prompt related functions
-
class
xonsh.prompt.base.
ParsedTokens
(tokens, template)[source]¶ Create new instance of ParsedTokens(tokens, template)
-
count
(value, /)¶ Return number of occurrences of value.
-
index
(value, start=0, stop=sys.maxsize, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
process
() → str[source]¶ Wrapper that gets formatter-function from environment and returns final prompt.
-
update
(idx: int, val: Optional[str], spec: Optional[str], conv: Optional[str]) → None[source]¶ Update tokens list in-place
-
template
: Union[str, Callable]¶ Alias for field number 1
-
tokens
: List[xonsh.prompt.base._ParsedToken]¶ Alias for field number 0
-
-
class
xonsh.prompt.base.
PromptFormatter
[source]¶ Class that holds all the related prompt formatting methods, uses the
PROMPT_FIELDS
envvar (no color formatting).
-
xonsh.prompt.base.
is_template_string
(template, PROMPT_FIELDS=None)[source]¶ Returns whether or not the string is a valid template.
-
xonsh.prompt.base.
multiline_prompt
(curr='')[source]¶ Returns the filler text for the prompt in multiline scenarios.
-
xonsh.prompt.base.
prompt_tokens_formatter_default
(container: xonsh.prompt.base.ParsedTokens) → str[source]¶ Join the tokens
- Parameters
- container: ParsedTokens
parsed tokens holder
- Returns
- str
process the tokens and finally return the prompt string