astrand / xclip

Command line interface to the X11 clipboard
GNU General Public License v2.0
1.04k stars 75 forks source link

Use MIME type by default (e.g., -t image/jpeg) particularly for CLIPBOARD #103

Open hackerb9 opened 3 years ago

hackerb9 commented 3 years ago

It would be beneficial to users if xclip was smart enough to call file (if available) on documents being read and set the target appropriately.

type=$(file --brief --mime-type foo.pnm)
xclip -c -t $type foo.pnm

could more easily be typed as

xclip -c foo.pnm

For example, xclip could look for input coming from a file when -t is not specified, and then set the target appropriately based on file --mime-type --brief FILENAME. This effect could be limited to only the CLIPBOARD selection, since PRIMARY and SECONDARY do often contain just text. (That's my preference). Or, it could be triggered by a special option, such as -t auto.