Skip to content

Instantly share code, notes, and snippets.

@ore-public
Created September 13, 2018 00:23
Show Gist options
  • Save ore-public/739560dad394ef5f3668aa20444afe73 to your computer and use it in GitHub Desktop.
Save ore-public/739560dad394ef5f3668aa20444afe73 to your computer and use it in GitHub Desktop.
xkeysnail config
# -*- coding: utf-8 -*-
import re
from xkeysnail.transform import *
# [Global modemap] Change modifier keys as in xmodmap
define_modmap({
Key.CAPSLOCK: Key.LEFT_CTRL
})
# Keybindings for Firefox/Chrome
define_keymap(re.compile("Firefox|Google-chrome|Chromium|Vivaldi-stable"), {
K("M-RIGHT_BRACE"): K("C-TAB"),
K("M-LEFT_BRACE"): K("C-Shift-TAB"),
K("M-r"): K("C-r"),
}, "Firefox and Chrome")
# Keybindings for Zeal https://github.com/zealdocs/zeal/
define_keymap(re.compile("Zeal"), {
# Ctrl+s to focus search area
K("C-s"): K("C-k"),
}, "Zeal")
# Emacs-like keybindings in non-Emacs applications
define_keymap(lambda wm_class: wm_class not in ("Emacs", "URxvt", "Lxterminal"), {
# Cursor
K("C-b"): with_mark(K("left")),
K("C-f"): with_mark(K("right")),
K("C-p"): with_mark(K("up")),
K("C-n"): with_mark(K("down")),
K("C-h"): with_mark(K("backspace")),
# Forward/Backward word
K("M-b"): with_mark(K("C-left")),
K("M-f"): with_mark(K("C-right")),
# Beginning/End of line
K("C-a"): with_mark(K("home")),
K("C-e"): with_mark(K("end")),
# Newline
K("C-m"): K("enter"),
K("C-j"): K("enter"),
K("C-o"): [K("enter"), K("left")],
# Copy
K("M-c"): [K("C-c"), set_mark(False)],
K("M-a"): [K("C-a"), set_mark(False)],
K("M-v"): [K("C-v"), set_mark(False)],
K("M-x"): [K("C-x"), set_mark(False)],
K("M-w"): [K("C-w"), set_mark(False)],
K("M-z"): [K("C-z"), set_mark(False)],
K("M-t"): [K("C-t"), set_mark(False)],
K("M-f"): [K("C-f"), set_mark(False)],
K("M-s"): [K("C-s"), set_mark(False)],
# Delete
K("C-d"): [K("delete"), set_mark(False)],
K("M-d"): [K("C-delete"), set_mark(False)],
# Kill line
K("C-k"): [K("Shift-end"), K("C-x"), set_mark(False)],
}, "Macos-like keys")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment