28

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.

Jacob
  • 1,135
  • 5
  • 14
  • 29
  • 1
    What actually happens when you issue that command? The reason I ask is that when you open/launch a plain executable (as opposed to a bundled application), that typically opens a new Terminal window or tab and just issues the file path as a command. That is, I would expect that `open /usr/local/bin/jmeter` would be just the same as opening a new Terminal window or tab issuing the command `/usr/local/bin/jmeter` (without `open`). Anyway, if you navigate to `/usr/local/bin` in the Finder (using Go > Go to Folder) and drag the jmeter executable to the Dock, that ought to do what you want. – Ken Thomases Sep 25 '17 at 04:37
  • Yes, you are right. Thank you! – Jacob Sep 25 '17 at 05:07
  • Unfortunately, what Ken suggests above no longer works on macOS Monterey. – Esteban Dec 21 '22 at 13:28

4 Answers4

34

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.

zimeg
  • 458
  • 3
  • 7
  • 2
    You can open Finder, rename to .app , copy to Applications folder and then drag the file to DOCK. – Edimar Martins Sep 20 '22 at 13:58
  • I wanted to have an icon on my command and for it to display in my dock. I was able to copy the icon from a misbehaving app, but then OSX wouldn't let me put the `fileName.command` in the dock. I followed @EdimarMartins suggestion and renamed it `fileName.app`, but then the icon I had added disappeared, and I couldn't re-add it. In the end, I moved `fileName.app` to the dock, _then_ renamed it to `fileName.command` at which point it shows up in the dock, with the desired icon, and works as expected. – MetaSean Sep 24 '22 at 01:12
13

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.

A. Marchand
  • 189
  • 2
  • 4
5

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

BISI
  • 159
  • 2
  • 6
0

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.