Quantcast
Channel: Vimタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 5608

vimでインサートモードを抜ける時のあれ(Hammerspoon版)

$
0
0

Sierra にアップグレードして困らないための準備

前準備

Hammerspoonのインストール

$ brew cask install hammerspoon

Lutzifer/keyboardSwitcherのインストール

本家の brew installはコケるので、とりあえず以下でインストール。

$ brew install oppara/homebrew/keyboardswitcher

init.lua

init.lua
localfunctionkeyCode(key,modifiers)modifiers=modifiersor{}returnfunction()hs.eventtap.event.newKeyEvent(modifiers,string.lower(key),true):post()hs.timer.usleep(1000)hs.eventtap.event.newKeyEvent(modifiers,string.lower(key),false):post()endendlocalfunctionswitchToUs()localcmd='/usr/local/bin/keyboardSwitcher select U.S.'os.execute(cmd)hs.console.printStyledtext(cmd)endlocalctrlBracket=hs.hotkey.bind({'ctrl'},'[',keyCode('escape'),switchToUs)localfunctionhandleGlobalEvent(name,event,app)ifevent==hs.application.watcher.activatedthenlocalbundleId=string.lower(app.frontmostApplication():bundleID())ifbundleId=='com.apple.terminal'thenctrlBracket:enable()elsectrlBracket:disable()endendendwatcher=hs.application.watcher.new(handleGlobalEvent)watcher:start()

備考

read は出来る

$ defaults read com.apple.HIToolbox AppleSelectedInputSources
$ defaults read com.apple.HIToolbox AppleSelectedInputSources | xargs | cut -d';' -f3 | cut -d'=' -f2

write が:confounded:

$ defaults write com.apple.HIToolbox AppleSelectedInputSources -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 0; "KeyboardLayout Name" = "U.S."; }'


Viewing all articles
Browse latest Browse all 5608

Trending Articles