macOS Terminal – Run Console Commands in Menu Bar

command linemacosmenu barterminal

I have a couple of console commands that I a) want to run and stop at demand (optionally automated) and b) without opening terminal window and/or leaving it open, ideally from menu bar. Some of them require root.

(One example of such command is proximac — it forces certain apps to use proxy, useful when they don’t respect system proxy settings. I want to run it when I connect to SOCKS proxy at work, and stop when I leave)

What’s the best way or app to launch command line tools from the menu bar?

Best Answer

You can enable the Script menu from the built-in Script Editor.app: Preferences → General → Show Script menu in menu bar.

Then you can place any AppleScript in this menu by putting the script in your Scripts folder.

To add user-level scripts to the script menu, save them into the ~/Library/Scripts/ folder of your user directory. For quick access to this folder, select Open Scripts Folder > Open User Scripts Folder from the script menu. When you do this, the folder is automatically created if it doesn’t already exist.

https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/UsetheSystem-WideScriptMenu.html