yoshuawuyts / vmd

:pray: preview markdown files
MIT License
1.18k stars 111 forks source link

Preview from clipboard #120

Closed motine closed 6 years ago

motine commented 6 years ago

Great work guys! Just great. I love vmd.

Here is an idea: instead of opening a file, I would like to be able to paste from the clipboard. I often only need to print a part of a document. It is tedious to create a new file and then export this new file.

maxkueng commented 6 years ago

Hi! Glad you like vmd.

vmd supports reading from stdin. So instead specifying the path to a file you can make vmd read from stdin like this:
cat somefile.md | vmd or echo "**hello**" | vmd.

In the same way you can pipe the contents of your clipboard directly in to vmd:
xclip -o -selection clipboard | vmd

You may not want to type this all the time so you can define an alias in your bash config like this:
alias clipmd="xclip -o -selection c | vmd" and then just type clipmd to render the markdown that's in your clipboard.

This is how it works on Linux and if you don't have xclip installed it's available in every repository. apt install xclip or pacman -S xclip or how ever it work on your distro.

If you have a Mac it seems the command is called pbpaste: pbpaste | vmd (I don't have a Mac so I haven't tried this, I just googled it).
On Windows I have no idea but I'm sure there's a program or command to do this somehow.

If this works for you please close the issue. If not it'd be great if you could explain your use case a bit more in detail.

motine commented 6 years ago

Wow, thanks for the great answer. Funnily enough, I already do use pbpaste occasionally. I was hoping for a simple cmd-v action, but I understand if this is not desired. Please feel free to close the ticket as "wouldn't-fix". Thanks again!

maxkueng commented 6 years ago

Sure thing. If you ever feel like diving in to Electron and JavaScript you are welcome to implement the feature yourself and create a PR. I'd merge it. Your GitHub profile looks like you're more of a C++ and Python person. So if you wanted to give it a shot and needed assistance with it I'd be here to help.

motine commented 6 years ago

Yeah, my profile is misleading. I will put this feature on my projects-to-do list :)