A Permanent Window Where I Click Lines and Their Values Are Copied to the Clipboard

I have a list of linux commands that I have to type frequently. They're in a text file. I like the functionality of the Prompt With List a lot, but I would prefer if the window remained opened after a selection is made, that way I dont' have to keep triggering the macro every time I need to input a command.

Is it possible? If not, is there any other action that I could use? Thank yoiu.

It is possible to keep a list prompt open indefinitely, but I wouldn't recommend it, since the prompt prevents you from interacting with your system until it's dismissed. Still, if you really want to try, here's a way to go about it:

Example - Keep Prompt With List Open.kmmacros (3.5 KB)

To make use of this method, you'd just have to add a line to your text file used in the prompt exclusively for the purpose of changing the variable that the While loop checks to see if it should keep re-opening the prompt or not.

Again, however, I wouldn't recommend this method. Instead, I would suggest making a macro group that is only active and shows a palette while in the app(s) where you use these commands, and fill it with macros that each paste a different command from the file. That way you could click on the appropriate command from the palette while in the app, and it wouldn't interfere with anything else you might want to do. If you have a lot of commands in this file, and the prospect of making a new macro for each one individually seems daunting, you could very likely even automate this process with the For Each action and AppleScripting the KM editor. If this sounds like something you'd like to do but you're not sure how to go about doing so, and you don't mind sharing the text file in question, feel free to post it here, along with the name of the app(s) you use these commands in, as I'm sure one of us can help you with that too.

Hey Leonardo,

What app are you doing this in? Terminal?


Thank you for the reply

Yes, I mostly copy and paste commands in Terminal. Ideally I want to click a line and have it pasted (no need to select, no need to copy, and no need to focus on Terminal before pasting).

As you predicted, the window remains focused at all times and this kind of defeats the purpose. I learned a lot by reading your code though, thank you for sharing!

1 Like

Do you know how you get a little menu when you assign the same shortcut to more than one macro? That is exactly what I am looking for in terms of functionality because it does not disappear when it loses focus. If only there was a way to keep that menu opened after an option is clicked, that would be so useful!

Yes, this is exactly what I was talking about here:

Here's an example of how this can work. First, make a macro group that is only available in the application(s) where you use these commands (I'm assuming this is Terminal here, but you can change this or add more):


Then you populate this macro group with simple macros consisting of a single "Insert text by pasting" actions:

Once done, a palette showing every macro in the group will appear automatically when using the apps specified in the macro group:

You can then click on the macros listed in the palette to execute them (i.e. paste the commands they contain), and the palette will remain open until you close it. (Please note that once closed, it won't appear automatically again until you explicitly show it, which is why I've enabled the hotkey and status menu entry options in the macro group).

Now, to quote my earlier post again:

Hey Leonardo,

I generally use aliases in the shell for this sort of thing.

For instance:

psu  ==  sudo port -v selfupdate
po   ==  port echo outdated
cua  == curl -L --user-agent 'Opera/9.70 (Linux ppc64 ; U; en) Presto/2.2.1'


OMG, that works 100% exactly how I wanted it to work! Thank you so much!!

1 Like

That is a great idea too, although I will probably forget the alias. I will try both, thank you very much for your suggestion

Hey Leonardo,

I have an alias for that.  :sunglasses:

alias sal="alias | egrep -i "


sal <pattern>  # Complex patterns should be single-quoted.

sal for search aliases.

I also have an alias to quickly open my shell customization file (~/.profile) in BBEdit:

alias ep='bbedit ~/.profile'

ep for edit profile.


Haha I'm sure you do! Thank you very much, I'll try these tonight and see how it goes!

Check out Clipboard.js - https://clipboardjs.com/

I set up a personal page that contains all the Shell commands that I need, and use clipboard.js to simply click and the content gets pasted into the clipboard.

1 Like

Wow this is so useful and it will work in all my computers! Thank you very much for sharing Christopher!

1 Like