1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

iterm2にフォーカスが当たるときに自動で英数に切り替えたい

Posted at
  • Hammerspoonを採用する
    • lua言語で書かれている
    • 軽量でOSS
    • Mac用のOS自動化ツール

使い方

hammerspoonをインストールする

brew install --cask hammerspoon

dotfilesに設定ファイルを格納する

mkdir hammerspoon

init.luaを作成する

-- init.lua
-- iTerm2にフォーカスが当たったら英数キーを送信
local function applicationWatcher(appName, eventType, appObject)
    if (eventType == hs.application.watcher.activated) then
        if (appName == "iTerm2") then
            hs.eventtap.keyStroke({}, 'eisu')
        end
    end
end

appWatcher = hs.application.watcher.new(applicationWatcher)
appWatcher:start()

hammerspoonを起動して、Reload Configを実行することでスクリプトが動作するようになる

CleanShot 2025-10-05 at 10.00.13.png

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?