I have an iTerm setup where I often have vim running in one split pane, and guard running in a different split pane.

So the keyboard focus stays almost exclusively in the pane running vim.

Once in a while, I would like to have guard run all tasks, which is accomplished by a single enter key press in the guard split pane. But I have to first switch input focus to the different pane, press enter, and switch focus back. So I end up with this keyboard sequence: +] (mapped to switch panes), Enter, +[

It does work, but it's a lot of key presses.

Can I create a setup, so e.g +R could trigger en Enter keypress in the 'other' pane?

1 Answer 1


Ever worked with Automator or Applescripts?

You can create a new services with automator executing an Applescript which then "presses" the keys. To that service you can then add a shortcut (⌘+R) under "System Preferences" > "Keyboard" > "Shortcuts" > "Services".

In your case the Applescript would be

tell application "System Events" to keystroke "]" using command down
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "[" using command down

If you got any questions you can ask :D

  • After a bit of struggling, I got it to work. There is a slight problem. As I created a keyboard shortcut using the 'command' button, when the script presses 'return' I am still holding down the 'command' key. Adding a 'delay 0.2' seems to remedy this (it took me a while to figure out the reason why the application switched to/from full screen when I was using the keyboard shortcut, but was working correctly when I executed the service from the services menu.
    – Pete
    Mar 22, 2014 at 12:15
  • Ok, I'm glad you got it to work :D
    – YourMJK
    Mar 22, 2014 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.