xonsh.completer

A (tab-)completer for xonsh.

class xonsh.completer.Completer[source]

This provides a list of optional completions for the xonsh shell.

complete(prefix, line, begidx, endidx, ctx=None, multiline_text=None, cursor_index=None, completion_context=None)[source]

Complete the string, given a possible execution context.

Parameters:
prefixstr

The string to match

linestr

The line that prefix appears on.

begidxint

The index in line that prefix starts on.

endidxint

The index in line that prefix ends on.

ctxdict, optional

Names in the current execution context.

multiline_textstr

The complete multiline text. Needed to get completion context.

cursor_indexint

The current cursor’s index in the multiline text. May be len(multiline_text) for cursor at the end. Needed to get completion context.

Returns:
rtnlist of str

Possible completions of prefix, sorted alphabetically.

lprefixint

Length of the prefix to be replaced in the completion.

complete_from_context(completion_context, old_completer_args=None)[source]
complete_line(text: str)[source]

Handy wrapper to build command-completion-context when cursor is at the end.

Notes

suffix is not supported; text after last space is parsed as prefix.

static generate_completions(completion_context, old_completer_args, trace: bool) Iterator[tuple[RichCompletion | str, int]][source]
parse(text: str, cursor_index: None | int = None, ctx=None) CompletionContext[source]

Parse the given text

Parameters:
text

multi-line text

cursor_index

position of the cursor. If not given, then it is considered to be at the end.

ctx

Execution context