MacOS – How to focus on MacVim in terminal using keyboard shortcut

keyboardmacos

I have three Applications open, one window for each:

Google chrome

MacVim in server mode

iTerm2

How I can set up some keyboard shortcuts to focus this apps ?

One Idea is do it via Alfred 2 Powerpack, after double click ctrl, run the iTerm2 command, this will start the iTerm2 app when not running, or focus it when it is already open.

Same for Google Chrome with different shortcut.

But I have no idea how to focus MacVim, because the app alone will run always a new window (no –remote option) when run like the both above.

Is there a method to focus to an existing already open application ?

Best Answer

See this question for different ways to assign shortcuts to opening applications.

When I tried using Alfred to assign a keyboard shortcut for MacVim, pressing the shortcut did not always open a new window. You could try using a script like this though:

tell application "MacVim"
    reopen -- open a new default window if there are no open windows
    activate -- make frontmost
end tell

Or try just using activate app "MacVim" or adding different arguments to open -a MacVim.