Created
November 21, 2016 07:02
-
-
Save naoya/01be08d7117f300bde6e1c44752cffc6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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