From b644a42a48951c50339d92d07beb3ccba5e81506 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 3 Dec 2022 14:06:16 +0530 Subject: [PATCH] Allow using wildcard mime types when copying from clipboard --- kittens/clipboard/main.py | 4 +++- tools/cmd/clipboard/read.go | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/kittens/clipboard/main.py b/kittens/clipboard/main.py index a12db0a2a..d0106c5cf 100644 --- a/kittens/clipboard/main.py +++ b/kittens/clipboard/main.py @@ -22,7 +22,9 @@ type=list The mimetype of the specified file. Useful when the auto-detected mimetype is likely to be incorrect or the filename has no extension and therefore no mimetype can be detected. If more than one file is specified, this option should be specified multiple -times, once for each specified file. +times, once for each specified file. When copying data from the clipboard, you can use wildcards +to match MIME types. For example: :code:`--mime 'text/*'` will match any textual MIME type +available on the clipboard, usually the first matching MIME type is copied. --alias -a diff --git a/tools/cmd/clipboard/read.go b/tools/cmd/clipboard/read.go index 5efb8e01e..bb9a5d590 100644 --- a/tools/cmd/clipboard/read.go +++ b/tools/cmd/clipboard/read.go @@ -156,6 +156,12 @@ func (self *Output) assign_mime_type(available_mimes []string, aliases map[strin } } } + for _, mt := range available_mimes { + if matched, _ := filepath.Match(self.mime_type, mt); matched { + self.remote_mime_type = mt + return + } + } if images.EncodableImageTypes[self.mime_type] { for _, mt := range available_mimes { if images.DecodableImageTypes[mt] {