I’m using the default Terminal in macOS Sequoia on an Intel Mac.
Back in the 4DOS days I really liked its filename auto-completion, and I’d like to recreate something similar in Keyboard Maestro.
Here’s what I’d like to achieve:
When I’m in Terminal and type python3 (with a space),
pressing F4 should insert the newest Python file (.py) from my Desktop.
Pressing F4 again should insert the second-newest file, and so on.
Only the file name should be inserted — not the full path.
I’ve started working on a macro for this, but I’m stuck here:
Can I suggest you do include the path, if only to prevent accidents if you run this macro when your current working directory isn't your Desktop? Or is there a reason not to include it?
The macOS/KM way to do this would be to throw a list you can choose from in the normal way:
(Note that we're doing "list most recent first" by using the -t flag in the ls command, so we turn off the "Prompt with List" action's "Sort Entries" option.)
(Also note: I misread and have included "python3 " in the text that's entered -- sorry!)
If you really want to do it the way you've explained you'll need to find a way for F4 to be both trigger and list iterator, plus a way to replace the previously-typed file name in Terminal each time you hit F4-the-iterator. And a way to signal to the macro that the last F4 was the final F4 and the macro can finish. That's all probably doable -- but it's a lot more work!