Running a script - Clipboard as Input

I am trying to make this work. Unfortunately, I know very little about how scripting works. Can't get this pasted script to work.

Please help.

Markdown to Mind Map Macro (v9.0.3)

Markdown to Mind Map.kmmacros (7.3 KB)

Hi @slyfox, we're pretty good around here, but we haven't quite mastered the art of reading minds. :wink:

For us to help you, we need a lot of detail about exactly what does not work, and how you want it to work.

Please read:
Tip: How Do I Get The Best Answer in the Shortest Time?

The input looks something like this:

## Titles

- text

### Subtitle

- text

#### Some headings

- more text

Error message:

02%20AM

Original script - https://github.com/ttscoff/popclipextensions/blob/master/Markdown2Mindmap.popclipext/md2mm.rb

You are using a very complicated scripting system that is written in ruby. You did not provide what your expected output should look like, nor what your objective is.

I'd suggest you post your request/issue on the GitHub issue where you got this script from.

The Execute Shell Script does not have the #! line to inform the shell what language/tool you want to run the script with.

Add something like:

#!env ruby

or

#!/usr/bin/ruby

Or whatever.

I suppose what you meant is the the Execute Shell Script that @slyfox is using does NOT have the required shebang to specify the language of that specific Action.

The first 4 lines of the original script for PopClip app are:

#!/usr/bin/ruby
require 'shellwords'

input = ENV['POPCLIP_TEXT']

Maybe if I change the "input" it can work?

Yes, the original #!/usr/bin/ruby tells the shell to execute the script with ruby.

If you want to read the system clipboard from ruby, you'd have to use the appropriate command to read the output of pbpaste, or as you have done, you can feed the clipboard in as stdin to the script, then you would have to use the appropriate ruby command to read the stdin.

Alternatively, you could put the system clipboard in a Keyboard Maestro variable, eg:

image

And then you could use input = ENV['KMVAR_Clip'] since Keyboard Maestro populates the environment with Keyboard Maestro variables in that form (KMVAR_Variable_Name).

1 Like

@peternlewis

Thank you! It works now.

1 Like