prompt-toolkit / prompt-toolkit/python-prompt-toolkit
open hyperlinks, local files in external app on keypress event
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
Some terminals (such as iterm2) include support OSC 8 clickable hyperlinks, that integrate with the OS to open a URL or local file with a mouse click:
- https://github.com/mintty/mintty/wiki/CtrlSeqs#hyperlinks
- https://www.iterm2.com/documentation-escape-codes.html
Is it possible to simulate a mouse click with a key press to trigger this behavior? For example, the idea would be to highlight/select a menu item, press return, and trigger the OSC 8 event.
Currently I emulate similar behavior using something like:
@self.kb.add("enter")
def _(event):
"""Open url"""
subprocess.run("<open url command>", shell=True)
but it's much slower/more error prone than the OSC 8 behavior in iterm2.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing prompt-toolkit's keyboard event handling around the Enter binding shown in the issue, then read the linked OSC 8 terminal documentation. Determine whether keypress activation is supported by the library's existing abstractions and define what behavior would count as complete; the issue does not name implementation files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100