Skip to content

Instantly share code, notes, and snippets.

@naoya
Created November 21, 2016 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naoya/01be08d7117f300bde6e1c44752cffc6 to your computer and use it in GitHub Desktop.
Save naoya/01be08d7117f300bde6e1c44752cffc6 to your computer and use it in GitHub Desktop.
import sys
import os
from keyhac import *
import ckit
def configure(keymap):
not_emacs_target = [
"com.googlecode.iterm2",
"com.apple.Terminal",
]
class Fakeymacs:
pass
fakeymacs = Fakeymacs()
fakeymacs.last_window = None
def is_emacs_target(window):
if window != fakeymacs.last_window:
fakeymacs.last_window = window
# print(ckit.getApplicationNameByPid(window.pid))
if ckit.getApplicationNameByPid(window.pid) in not_emacs_target:
fakeymacs.keybind = "not_emacs"
return False
fakeymacs.keybind = "emacs"
return True
keymap_emacs = keymap.defineWindowKeymap(check_func=is_emacs_target)
keymap_emacs[ "Ctrl-V" ] = "PageDown" # Page down
keymap_emacs[ "Alt-V" ] = "PageUp" # page up
keymap_emacs[ "Ctrl-S" ] = "Cmd-F" # Search
keymap_emacs[ "Ctrl-W" ] = "Cmd-X" # Cut
keymap_emacs[ "Alt-W" ] = "Cmd-C" # Copy
keymap_emacs[ "Ctrl-Y" ] = "Cmd-V" # Paste
keymap_emacs[ "Ctrl-Slash" ] = "Cmd-Z" # Undo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment