5

I am mostly an Ubuntu user. I like that it is very easy to create one-click launchers for apps by (in Gnome, at least) right-clicking on the panel and choosing add-to-panel->custom-app. I use this A LOT. For custom one-liners and custom shell script utilities that I use day to day for work (I am a LAMP stack sysadmin)

Mac OS <= 9 used to have these "droplet" things which were similar.

I may be forced to use my Mac for a while, and I'd like to know of an easy way to create a one-click "app" launcher that launches, for example, a custom shell script, or a custom shell one liner, or even a normal app but with different CLI flags.

What is the "Mac Way(TM)" of doing something like that? I'd like to be able to add the .desktop-ish files to the Mac app bar at the bottom, or, failing that, make them clickable icons on my desktop. Is that even possible?

studiohack
  • 13,477
JDS
  • 482
  • 1
  • 7
  • 15

3 Answers3

3

You can use AppleScript Editor to create AppleScript script files or applications that do the following:

a) Launch an application

tell application "TextEdit" to activate

b) Run a shell command without opening Terminal

run shell script "/usr/local/bin/growlnotify 'Hello World'"

Applications can be dragged to the left side of the Dock. To execute normal scripts, enable AppleScript menu (which will be located in the menubar notification area) in AppleScript Editor's preferences. This menu is fed by using scripts in ~/Library/Scripts, it displays those e.g. in ~/Library/Scripts/Applications/TextEdit only when TextEdit in frontmost.

You can also use Automator to do this (e.g. Run Shell Script and Launch Application actions), but in my experience, it's a lot slower than running the AppleScripts themselves.


To make an executable shell script that's open the Terminal, simply chmod +x it and save with the extension .tool or .command. Optionally drag to the right side of the Dock.


To launch arbitrary shell scripts from the GUI without a Terminal, simply save them as files, and create the following application (once):

Open Automator, select Application, double-click the Run Shell Script item in the library, select to receive input as arguments and enter the following:

for f in "$@"
do
    source "$f"
done

(or something similar)

Now you just need to associate these shell scripts with this application (I called mine Shell Script Runner), and you can drag them to the Dock's file area.


To execute a Mac application (e.g. Firefox) with different arguments, use the following in shell:

open -a Firefox --args ProfileManager

Anything you can drag to the Dock, you can place on the desktop:

  • Create an alias for Applications
  • Create an alias for regular files, or just drag the files to the desktop.
Daniel Beck
  • 111,893
0

You can use Automator to create a small application that simply runs a shell script. Open Automator, find the Run Shell Script action, paste in your code, save as an Application, then drag the application to your Dock.

0

You did not say what osx version you are using, so...

Look for AppleScript Utility.app it has the option to put a script item in the menu bar.

I have shell scripts and applescripts in that script menu, works great.

-Bill

broomdodger
  • 3,200