Skip to content

How to process text before copying using mouse click? #7699

Closed Answered by siddhpant
siddhpant asked this question in Q&A
Discussion options

You must be logged in to vote

I achieved this with the following kitten:

from kitty.boss import Boss
from kitty.clipboard import set_clipboard_string
from kittens.tui.handler import result_handler


def main(args: list[str]) -> None:
    """
    See "Using kittens to script kitty, without any terminal UI" section of
    https://sw.kovidgoyal.net/kitty/kittens/custom
    """
    pass
# End of main().


@result_handler(no_ui=True)
def handle_result(
    args: list[str],
    _,
    target_window_id: int,
    boss: Boss
) -> None:
    """
    Custom kitten to copy first 12 chars of the selection.
    To be used for copying git hashes in short form quickly.
    """
    window = boss.window_id_map.get(target_window_id)
    …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by siddhpant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants