2

How can I switch among application windows using Cmd/Opt + 1/2/3... etc, like on Unity or KDE?

Why? This is especially handy if you often switch among the same few apps, e.g. a browser, a file manager and an IDE, but also have other apps open, so Alt+Tabbing to the desired window would take more time.

That keyboard shortcut saves me probably 5 seconds per minute on the average, so ~40 minutes a day, and it's supported by Windows as well.

I tried using the native Automator and Keyboard shortcuts in System settings, but the shortcut is only picked up in some applications (e.g. Automator, Webstorm), but most applications seem to consume it before it reaches the system.

To create the shortcut with Automator:

  1. ⌘+Space and launch Automator
  2. Choose "Quick action"
  3. Set the "Workflow receives current" to no "input"
  4. In the panel on the left, filter for the Run Shell Script Action and double click it
  5. In the Run shell script text area, replace cat with the command to run your application, e.g. open -a "Google Chrome".
  6. File -> Save and name your shortcut, e.g. Chrome launch/switch to

Assign the keyboard shortcut

  1. ⌘+Space and type keyboard shortcuts to access it in System Settings
  2. Click Services -> General and you'll see your newly created shortcut
  3. Double click none and press your hotkey combo, e.g. ⌘+1
  4. Click Done

I'm looking for a more reliable solution than the system's Keyboard shortcuts.

7
  • 2
    You can switch Spaces with Ctrl/Number. If you put one app on each Space, you've got it. [Doesn't work for fullscreened apps].
    – Tetsujin
    Commented Apr 6, 2023 at 8:02
  • @Tetsujin: I don't want the whole animation of switching spaces. I want to quickly switch for example between my IDE and the browser when I look up some reference information. Commented Apr 13, 2023 at 17:05
  • 1
    There's no native way to do what you want.
    – Tetsujin
    Commented Apr 13, 2023 at 17:45
  • In contrast with the open-source Linux world, it feels frustrating and powerless to be unable to provide feedback to Apple about this. Commented Apr 21, 2023 at 13:20
  • @DanDascalescu The type of feedback you can give via the links at the bottom of apple.com/contact ?
    – nohillside
    Commented Jul 3, 2023 at 19:31

1 Answer 1

3

Karabiner-Elements can be used to run an open shell command. It'll open it if the application is closed, and focus if it's already open. If you create cmd-numbers.json in ~/.config/karabiner/assets/complex_modifications/, you'll see new rules in Karabiner under Complex modifications | Add rule:

{
  "title": "Launch apps with Cmd+<number>",
  "rules": [
    {
      "description": "Finder",
      "manipulators": [
        {
          "from": {
            "key_code": "1",
            "modifiers": {
              "mandatory": "command"
            }
          },
          "to": {
            "repeat": false,
            "shell_command": "open -b com.apple.finder"
          },
          "type": "basic"
        }
      ]
    },
    {
      "description": "Firefox",
      "manipulators": [
        {
          "from": {
            "key_code": "2",
            "modifiers": {
              "mandatory": "command"
            }
          },
          "to": {
            "repeat": false,
            "shell_command": "open -a Firefox"
          },
          "type": "basic"
        }
      ]
    }
  ]
}

The -b flag means bundle ID. You can also use open -a Finder.app.

You must log in to answer this question.

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