Skip to content
Back to top
View this page
Edit this page

# xonsh.completer

A (tab-)completer for xonsh.

class xonsh.completer.Completer

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

  static generate_completions(completion_context, old_completer_args, trace: bool) → Iterator[tuple[RichCompletion | str, int]]
  complete(prefix, line, begidx, endidx, ctx=None, multiline_text=None, cursor_index=None, completion_context=None)

    Complete the string, given a possible execution context.

    Parameters:
      prefix str

        The string to match

      line str

        The line that prefix appears on.

      begidx int

        The index in line that prefix starts on.

      endidx int

        The index in line that prefix ends on.

      ctx dict, optional

        Names in the current execution context.

      multiline_text str

        The complete multiline text. Needed to get completion context.

      cursor_index int

        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:
      rtn list of str

        Possible completions of prefix, sorted alphabetically.

      lprefix int

        Length of the prefix to be replaced in the completion.

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

    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.

  parse(text: str, cursor_index: None | int = None, ctx=None) → CompletionContext

    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