Skip to content

jnoortheen/xontrib-term-integrations

Repository files navigation

Terminal Emulators integration

Shell integration for Xonsh.

The following terminal emulators are supported

  • iTerm2
  • kitty
  • WezTerm with CWD; Input, Output, and Prompt zones; and User Vars for tracking additional shell state

Note: If identifying current terminal fails, iTerm2 hooks are loaded.

PRs welcome on improving the support to more terminal programs :)

Installation

To install use pip:

xpip install xontrib-term-integrations
# or: xpip install -U git+https://github.com/jnoortheen/xontrib-term-integrations

Usage

# this modifies the $PROMPT function. So load it after setting $PROMPT if you have a custom value
xontrib load term_integration

(WezTerm) Set user vars1 via the helper set_user_var function:

# via a xonsh alias
set_wezterm_user_var 'my_term_user_var' 'value_of_my_term_user_var'

# or an explicit Python import
from xontrib_term_integrations.utils import set_user_var
set_user_var('my_term_user_var','value_of_my_term_user_var')

You can disable registering the alias with a $XONTRIB_TERM_INTEGRATIONS_SKIP_ALIAS = True

Contributing

Please make sure that you

  • Document the purpose of functions and classes.
  • When adding a new feature, please mention it in the README.md. Use screenshots when applicable.
  • Conventional Commit style should be used for commit messages as it is used to generate changelog.
  • Please use pre-commit to run qa checks. Configure it with
pre-commit install-hooks

Known issues

  • (WezTerm) Multiline prompt is partially supported:
    • every continuation line is semantically marked by default:
      if True:
      #↓ continuation prompt
      .....     echo 1
      #     ↑ input
      so you can select echo 1 as a SemanticZone with a mouse multiclick, but you can't select both lines as one zone (and would need to map some combo of commands to hack around it)
    • if you set $MULTILINE_PROMPT_PRE='', $MULTILINE_PROMPT_POS='', then continuation lines won't be marked, you'd be able to select all the lines as one SemanticZone (unles the right prompt interferes), but that will also include .. continuation markers (so you'd either need to disable them in Xonsh or add some extra WezTerm lua parsing hack to trim them)
      (follow this WezTerm discussion for updates)
  • (WezTerm) Semantic right prompt not separated from the next-line left prompt (issue)
  • WezTerm is not recognized in root shells due to this issue

Footnotes

  1. Variables associated with a given pane rather than a process. WezTerm, iTerm2