1

I would like to change the Terminal interrupt keyboard shortcut to ideally Command+Shift+C. Just this shortcut solely.

Is there a feasible way to do this?

1
  • I have used ^C for as long as I've use computers to preform a terminal interrupt, didn't know about ⌘. however, since they apparently do the same thing, I believe for this purpose my answer accomplishes the task. Sep 14, 2018 at 4:58

1 Answer 1

1

The following was created, tested and works for me in macOS High Sierra.


Create the Automator service...

In Automator:

  1. File > New, or press: ⌘N
  2. Select Service and click the Choose button.
  3. Configure the settings as shown in the first image below.
  4. Add a Run AppleScript action.
  5. Replace the default code with the example AppleScript code.
  6. Save as e.g.: My Terminal Interrupt

enter image description here


Example AppleScript code:

tell application "System Events" to keystroke "c" using control down

Assigning the keyboard shortcut...

In System Preferences...

  • System Preferences > Keyboard > Shortcuts > Services add ⇧⌘C (press Shift-Command-C) to the My Terminal Interrupt service, as shown in the image below.

    • Note: A word about the shortcut you assign... ⇧⌘C is offered as a suggestion however, you'll need to select one that doesn't conflict with Terminal (or any other app that has focus if setting the service to any application) when pressed. This may require a strange combination or a four character combo. ⇧⌘C worked fo me in Terminal after changing the default for the Show Colors command, shown further below.

enter image description here


Terminal already uses ⇧⌘C for the Edit menu > Show Colors command, so you'll need to change that to e.g. ^⇧⌘C (Control-Shift-Command-C).

Changing the default keyboard shortcut...

  • System Preferences > Keyboard > Shortcuts > App Shortcuts

    1. Click the [+] button
    2. Change Application: from All Applications to: Terminal
    3. For Menu Title: type: Show Colors
    4. For Keyboard Shortcut: type, e.g.: ^⇧⌘C
    5. Click the Add button.

enter image description here

enter image description here


Now when in Terminal and I need to interrupt a running command, I press ⇧⌘C instead of ^C
(or ⌘.) to stop the process.

6
  • Unfortunately in High Sierra there appears to be a a bug that prevents this keyboard shortcut from working consistently for some reason in Terminal(works 1 out of every 10 presses). I am going to do some more investigation but at this point this doesn't work. I have tried a range of shortcuts thinking maybe something else would work but unfortunately it hasn't.
    – William
    Sep 14, 2018 at 14:23
  • @William, Just curious, why not just use the builtin ^C manually (or ⌘. which actually sends a ^C)? Sep 14, 2018 at 15:02
  • @William, As I said, "The following was created, tested and works for me in macOS High Sierra.", and I just now tested it again over 20 times and it worked every time. There is a slight lag compared to pressing ^C manually (or ⌘. which sends a ^C). I will say though that in every OS I've ever used sometimes the interrupt is not immediately caught and I've had to press ^C again, so I can imagine that this workaround might be slower to act especially if whatever process is running is hogging CPU cycles to the point even pressing ^C manually might not act quickly. Sep 14, 2018 at 15:02
  • I type on Dvorak and can't feasible hit that shortcut with one hand.
    – William
    Sep 14, 2018 at 15:02
  • My High Sierra is not updated so it might be an older version of High Sierra.
    – William
    Sep 14, 2018 at 15:03

You must log in to answer this question.

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