hello
February 2, 2021, 6:53pm
1
I'd love if it where easier to pass something to terminal, example:
Pass selected file(s) in Finder to Terminal shell as a variable in script
could be much simpler for ocasional uses, and have documentation.
a "batteries included" action , so to say.
my 2c.
ccstone
February 20, 2021, 9:41pm
2
Hey @hello ,
Do you mean the Terminal.app?
Or do you mean the Keyboard Maestro Execute a Shell Script action?
Personally I'd like for @peternlewis add a text token for the %FinderSelection%
.
This would simplify or solve a number of things.
In the meantime you'll have to live with something like this:
Return Finder Selection as POSIX Path List v1.00.kmmacros (7.2 KB)
To use this you can do something like:
Process Finder Selection with Execute Shell Script Action v1.01.kmmacros (8.3 KB)
Now then – that's NOT how I do this task in my own work.
If I'm working in an Execute a Shell Script action I'd rather keep all of my work consolidated if possible, so I'll do something like this:
Process Finder Selection with Execute Shell Script Action v2.01.kmmacros (7.8 KB)
-Chris
ccstone
February 20, 2021, 10:45pm
3
Thanks to @JMichaelTX for picking up on a couple of issues with my macros.
Fixed.
-Chris
hello
February 21, 2021, 1:03am
4
Thanks! great stuff as usual cc
yes, great way to put it, a token would be very useful indeed!
1 Like
Actually KM has already highly automated much of what you are asking for.
For example:
For Each action using a Finders Selection collection .
In the Execute a Shell Script action there is an option to pass the script, as stdin, the data in a KM Variable, Clipboard, even text:
In the Execute Shell Script , directly reference KM Variables:
Even if @peternlewis provided us with a text token for the %FinderSelection%
, it would not work inside of the shell script, since AFAIK shell scripts do NOT support any tokens.
I just wanted to make sure you, and others, are aware of the current support KM provides for shell scripts.
1 Like
Assuming you have a single thing selected in the Finder, then:
sets the variable FinderSelection to it.
ccstone
February 22, 2021, 2:33am
7
I think so; it'd save people a good deal of work.
Here's a canonical Keyboard Maestro macro to work with the Finder selection.
I've added a counter and a line-count filter to demonstrate both in action.
-Chris
Save Path(s) of Selected Item(s) in the Finder to a Variable v1.00.kmmacros (13 KB)
2 Likes