I always have the problem in my dock, where the download bar just stops and stays froze. I know you can do a killall -KILL Dock and it will fix the issue.

Is there a way to click a button or do a keyboard-shortcut that runs this Terminal command?

2 Answers 2


There are multiple ways to do this, here are 2.

First method: Create a quick script that runs after a double-click.

Create a text file, named myScript.command. The '.command' postfix will let Finder know to run it on opening.

Add the following as plain text:

killall -KILL Dock

Now the script exists but needs to be executable. To do this you need to do a chmod.

chmod 755 myScript.command 

Running myScript.command will open a Terminal window and run the command. The first line, hashbang, will let your computer know to use bash for the following script. You can set the preferences in Terminal.app to close the terminal window after a clean exit.

Second method: Create a 'Service' and bind a keystroke to that service.

Create and install the service:

  1. Open Automator
  2. New Document -> Service
  3. Add the 'Run Shell Script' module and insert your code killall -KILL Dock
  4. Set the 'Service receives no input', save and quit.
  5. Install your newly created service by opening it in Finder and choose 'Install'.

Attach a keystroke to this service:

  1. Open 'System preferences' -> 'Keyboard' -> 'Keyboard shortcuts' -> 'Services'
  2. Find the 'Kill Dock' service and attach a keystroke to it.

Automator - Run Shell Script

  • If I were to add another command to the myscript.command would I just write the other command on the bottom like if I want it to KILL finder and dock. May 7, 2015 at 14:39
  • Added the fix for your problem. May 7, 2015 at 19:14
  • @Ilya See Full privileges on .command file, but it says I don't have appropriate privileges, Gatekeeper isn't the problem here.
    – grg
    May 7, 2015 at 19:15
  • @grgarside, thnx. I updated the answer. So used to this that I forgot. May 7, 2015 at 19:19
  • So I used automator and did everything exactly but whenever I enable the service through Keyboard Commands it doesnt work but whenever I run it in Automator it works and restarts my dock. This it the command I set (⌃⌥⌘D). See it works fine in Automator > i.imgur.com/CEYnmqK.png May 7, 2015 at 23:29

If you want to use a shortcut to run an applescript which runs the terminal command. here is a question on superuser with the first answer explaining how to make a shortcut to an applescript.

How to Make a Shortcut to Applescript in Automator

Make a new service and add your applescript alt

alt Make a keyboard shortcut using system preferences

Keyboard shortcuts will work across applications.

Made by rahul_send89 from Super User

Then you can do this as the applescript to the Automator input (As shown on the screenshot):

do shell script "sudo killall -KILL Dock" with administrator privileges

I put it in sudo (admin) just in case it would require.

Or without admin:

do shell script "killall -KILL Dock" with user privileges
  • 3
    Please do not use links, if the link dies your answer will have no value. May 7, 2015 at 8:06
  • Ok, I will edit question to incl. the contents of the link, and add credit to the owner
    – John K
    May 7, 2015 at 8:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .