How to create dock icon for running terminal command in Mac OS

Viewed 23043

Now I open jmeter using terminal using command: open /usr/local/bin/jmeter

I need it frequently, so I want to create dock icon to run this command.

How can I do it?

I tried to make a right click and choose 'keep in dock' option. However, it disappears when I close the application.

4 Answers

The closest I could get was creating a desktop icon through the following method:

  1. Create a plain text document in TextEdit
  2. Paste the following code in the document

    #!/bin/bash open /usr/local/bin/jmeter

  3. Save the file as fileName.command

  4. Open Terminal and navigate to the directory which you saved the file

  5. Type in chmod +x fileName.command and hit enter

You should now have a shortcut to execute this command! I know this isn't the exact solution you were looking for, but I hope this still solves your problem.

Following E. Zimbelman's answer, you create a .command executable file and then

  • you can add an icon (drag and drop an icon file on the icon of the properties window of the file (Cmd+I))
  • change the .command extension to .app
  • so you can add it the the dock (drag and drop), it's ok if the icon has changed temporarily
  • and then you change it back to .command

With this you can have any script you like in the .command file and have it on mac's dock.

I suggest you have a look at the answer to this question in the apple stackexchange. It pretty much does exactly what you want (although I have no idea what jmeter does).

The answer is, essentially, use automator to run your script, save the automator job as an app (not a workflow), and drag the resulting object to the dock, once you have it working the way you want.

https://apple.stackexchange.com/questions/73897/how-can-i-launch-a-virtualbox-vm-from-the-dock

or the wayback machine copy: https://web.archive.org/web/20160921184459/https://apple.stackexchange.com/questions/73897/how-can-i-launch-a-virtualbox-vm-from-the-dock

I needed a simple terminal command to unmount an internal disk which keeps spinning up whilst appearing in Finder to be unmounted. I am running the Mac from an external SSD.

All that was required was to open Script Editor and enter the text: do shell script "diskutil eject /dev/nameofthedisk"

and then save that as an Application. Drag that to the dock and now I have one click unmounting of the disk when it spins up.

Related