Skip to content

Expose clear_selection function #4600

@nickwynja

Description

@nickwynja

Is your feature request related to a problem? Please describe.

I have a script that takes the selection in kitty and sends it to a text file. I'd like to be able to clear the kitty text selection either from the script or from a combine action in kitty.conf.

This is what I currently have in kitty.conf:

# Don't use pass_selection_to_program since it won't call if selection is empty
# and I want to show an error message in this case to provide feedback
map cmd+shift+v launch --type background hl "@selection"

Describe the solution you'd like

I'd like the screen.clear_selection() function to be exposed so I can call it from map commands.

map cmd+shift+v combine : launch --type background hl "@selection" : clear_selection

Describe alternatives you've considered

I've tried other commands which might force the text selection to be cleared. Alternatively to calling it from the map combine, it would be nice to clear the text selection from the script so I can optionally clear or not clear based on the outcome of some logic.

Additional context

My hl script, for context:

#!/usr/bin/env bash

STDIN=$1

if [[ "$STDIN" == "" ]]; then
     ~/.dotfiles/kitty/alert.sh "Selection empty. Make sure you have the correct window selected."
    exit 1

else
    printf "\n\n" >> ~/Wiki/ReadingNotes.md
    echo "$STDIN" | xargs | fmt | sed 's/^/\> /'  >> ~/Wiki/ReadingNotes.md
fi

Thank you for this amazing software!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions