Search code examples
pythonmacosshellterminalmarkdown

Paste from system mac osx clipboard into terminal


I'm trying to use python-markdown to convert the system clipboard contents into HTML by running a shell script after pressing a hotkey and sending the processed markdown to pbcopy. The following is the shell script to make this happen.

#!/bin/sh
echo `pbpaste` | python -m markdown | pbcopy

The issue already known is that pbpaste will not contain the systems clipboard contents. Is there a similar utility to pbpaste that stores the clipboard contents?


Solution

  • pbpaste should work for this. You can even specify the general clipboard to ensure you're getting the main system clipboard.

    #!/bin/sh
    
    pbpaste -pboard general | python -m markdown | pbcopy