Giter Club home page Giter Club logo

xontrib-term-integrations's Introduction

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

xontrib-term-integrations's People

Contributors

eugenesvk avatar jnoortheen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

eugenesvk

xontrib-term-integrations's Issues

Bizzare crashes with `kitty`

See kovidgoyal/kitty#4582

Output that seems suspicious from kitty when running as a subprocess:

027 20:43:05.886534] [PARSE ERROR] Unknown OSC code: 1337
[027 20:43:05.886550] [PARSE ERROR] Unknown OSC code: 1337

Is OSC code: 1337 not a valid escape code for kitty?

Escape characters shown in prompt

Hi, excited to see this project and been looking forward to a working xonsh successfully integrated with iterm2 (MacOS).
I tried this and not certain if this is something I've missed or any other obvious settings at my end, but when having this loaded (with or without powerline2) it looks that there are some reoccurring escape-characters..

In such case I can supply anything that would help look into this or any advice what to try next..?

With xontrib-term-integration loaded
image

Without xontrib-term-integration loaded
image

Kind regards,
Daniel

Error trying to install source checkout with `pip install -e`

Obtaining file:///Users/techcable/git/xontrib-term-integrations
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
ERROR: Project file:///Users/techcable/git/xontrib-term-integrations has a 'pyproject.toml' and its build backend is missing the 'build_editable' hook. Since it does not have a 'setup.py' nor a 'setup.cfg', it cannot be installed in editable mode. Consider using a build backend that supports PEP 660.

Could you please add a setup.cfg or setup.py ❤️

iTerm now works from release

xonsh release 0.12.0 and higher now includes the PR mentioned in the README so you do not need to install from github.

The README should be altered to reflect that.

How would we combine iterm/kitty integration?

Hi! Came here from xonsh/xonsh#4623 :)

As far as I'm aware, kitty's requirements for escape sequences are a subset of iTerm2's. The only extra thing needed is $PS2.

The prompt marking sequences are the same except that kityt needs less (more dont do any harm) and it marks PS2 which iterm doesnt.

Given how much overlap there seems to be, I think it makes the most sense to combine the kitty/iterm integration wherever possible.

Does it make more sense to:

  1. Turn this into a common plugin that supports both (maybe called fancy-term or term-integration or something?)
  2. Have separate xontribs for both, but move common code into a library (this is probably better)

It seems you already have the bulk of the work done for iTerm2. That's amazing 😄

I'm not super familiar with how "xontrib libraries" would work. What are your thoughts on this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.