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

# xonsh.completers.emoji

Completer for unicode symbols and emoji.

Trigger prefixes are configurable via environment variables:

- `$XONSH_COMPLETER_EMOJI_PREFIX` (default `"::"`) — colorful emoji (faces, animals, objects).

- `$XONSH_COMPLETER_SYMBOLS_PREFIX` (default `":::"`) — simple unicode symbols (arrows, math, dingbats).

Set to empty string to disable.

xonsh.completers.emoji.complete_emoji(ctx: CommandContext)

  Complete emoji and unicode symbols using configurable trigger prefixes.

xonsh.completers.emoji.get_emoji_cache()

  Return the cached list of `(char, unicode-name)` pairs for colorful emoji.

  The cache covers Unicode ranges for emoticons, misc pictographs, transport, supplemental and extended-A symbols, filtered to double-width characters (`wcwidth == 2`). It is built lazily on first call and reused thereafter; callers can use it directly — e.g. to wire a random-emoji prompt field.

  Returns:
    list of tuple of (str, str)

      Pairs `(emoji_character, lowercased_unicode_name)`.

  Examples

      >>> import random
      >>> from xonsh.completers.emoji import get_emoji_cache
      >>> random.choice(get_emoji_cache())[0]
      '🥗'

xonsh.completers.emoji.get_symbol_cache()

  Return the cached list of `(char, unicode-name)` pairs for simple symbols.

  The cache covers Unicode ranges for arrows, mathematical operators, misc technical symbols, geometric shapes, dingbats, and misc symbols+arrows, filtered to single-width characters (`wcwidth == 1`). It is built lazily on first call and reused thereafter.

  Returns:
    list of tuple of (str, str)

      Pairs `(symbol_character, lowercased_unicode_name)`.

  Examples

      >>> from xonsh.completers.emoji import get_symbol_cache
      >>> any(name == 'rightwards arrow' for _, name in get_symbol_cache())
      True