Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit the command with prompt_toolkit instead of readline #4

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

jkseppan
Copy link
Contributor

The readline on some Python versions is based on libedit, which doesn't support either set_startup_hook or insert_text - it just sits there waiting for input. IPython uses prompt_toolkit for editing, which feels like a more modern solution. It can even highlight the shell command using Pygment's BashLexer.

Fixes #3

The readline on some Python versions is based on libedit, which
doesn't support either set_startup_hook or insert_text - it just
sits there waiting for input. IPython uses prompt_toolkit for
editing, which feels like a more modern solution. It can even
highlight the shell command using Pygment's BashLexer.
@simonw
Copy link
Owner

simonw commented Mar 26, 2024

I love the prompt toolkit fix!

I'm not sold on Pyments as a default - mainly because on my terminal it actually makes things harder to read (red on black):

CleanShot 2024-03-26 at 14 46 07@2x

So not sure it's worth the dependency weight.

Maybe there's a way to make it optional.

@simonw
Copy link
Owner

simonw commented Mar 26, 2024

https://pypi.org/project/prompt-toolkit/ looks like a clean new dependency - BSD licensed, widely used.

Actively maintained on https://github.com/prompt-toolkit/python-prompt-toolkit for 10+ years, and good documentation: https://python-prompt-toolkit.readthedocs.io/en/stable/

Plus it doesn't pull in many other dependencies - installing in a fresh environment only pulls it plus one other:

prompt-toolkit==3.0.43
wcwidth==0.2.13

@simonw
Copy link
Owner

simonw commented Mar 26, 2024

I'm going to land this as-is and then decide what to do with pygments.

@simonw simonw merged commit e471b28 into simonw:main Mar 26, 2024
5 checks passed
@jkseppan jkseppan deleted the prompt-toolkit branch March 27, 2024 04:21
@jkseppan
Copy link
Contributor Author

Suggestion for pygments handling in #7

simonw added a commit that referenced this pull request Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Seems to hang when readline is really libedit
2 participants