MacOS – How to run a script from Alfred or Spotlight or any run dialog

command linemacosscriptspotlight

Coming from Linux I am really missing the good old gmrun — a run dialog
which recognizes your $PATH and allows you to execute any script in it
without needing to open up a terminal. It does the job and get out of the
way immediately.

I am wondering if I can make Alfred or spotlight do the same thing, or perhaps
find another tool?

Update 1

I have tried Dterm, but it keeps asking me for accessibility permissions, which I have already granted.

enter image description here

Update 2

  • I have solved the above problem by going to privacy settings and check DTerm manually there:

enter image description here

  • It's working right now, but not as smoothly as I would expect: the run dialog is still there after the command is issued, it would be much better if the window gets hidden.

enter image description here

Best Answer

Dterm

You might want to take a look at Dterm. This is a dialog under commandshiftreturn and does exactly what you are looking for and it does even more than that.

As it says on the site:

"DTerm provides a context-sensitive command line that makes it fast and easy to run commands on the files you're working with and then use the results of those commands."

ping test Dterm