0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Karabiner Element custom rule for iTerm + CLI Emacs

Last updated at Posted at 2025-10-06

Karabiner config for emacs (iterm2)

MacOSの設定でCtrl-SpaceはデフォルトでIMの変更にアサインされている。
そのためemacsで頻出の Ctrl + Space による Mart setが動作しない。

Karabiner Element にこちらのカスタムルールを適用することで、
iTerm2についてはCtrl+SpaceをCtrl-Shift-2に書き換え、
emacs ではCtrl-Sift-2 = Ctrl-Spaceと認識させ、Mart set を使えるようにする。

本カスタマイズはUSキーボード版でチェックしています。日本語版だと各自チェックしてください。

{
  "description": "iTerm2: Ctrl-Space → Ctrl-Shift-2 (^@)",
  "manipulators": [
    {
      "type": "basic",
      "from": {
        "key_code": "spacebar",
        "modifiers": { "mandatory": ["control"], "optional": ["any"] }
      },
      "to": [
        { "key_code": "2", "modifiers": ["left_control", "left_shift"] }
      ],
      "conditions": [
        {
          "type": "frontmost_application_if",
          "bundle_identifiers": ["^com\\.googlecode\\.iterm2(\\.nightly)?$"]
        }
      ]
    }
  ]
}

想定される副作用としては emacs 以外で Ctrl+Shift+2相当をつかっているキーバインドが、Ctrl+Spaceで勝手に動いてしまうことでしょうか。

JISキーボード版は以下で解決できるようですが、未チェックです。(Ctrl-[をターゲットにする)

{
  "description": "iTerm2: Ctrl-Space → C-@ (JIS)",
  "manipulators": [{
    "type": "basic",
    "from": { "key_code": "spacebar", 
    "modifiers": { "mandatory": ["control"], "optional": ["any"] } 
    },
    "to": [
        { "key_code": "open_bracket", "modifiers": ["left_control", "left_shift"] }
    ],
    "conditions": [
        { 
          "type": "frontmost_application_if", 
          "bundle_identifiers": ["^com\\.googlecode\\.iterm2(\\.nightly)?$"]
        }
    ]
  }]
}

もっと良いやり方があったら教えてください。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?