A keyboard switching program for the command line.
Code is from this stackoverflow question
- requires xcode command line tools
build/kbswitchto place in path
kbswitch listlist all available inputs
kbswitch com.apple.keylayout.ABCfor English (macos Ventura)
kbswitch com.apple.inputmethod.Kotoeri.RomajiTyping.Japanesefor Japanese (macos Ventura)
There is an objective-c version
kbswitch.m that can be compiled with
clang -framework Carbon -framework Foundation filename.m -o filename. However, this doesn’t necessarily work as is because it requires
com.apple.keylayout prepended to the keyboard layout.
Switch to English keyboard in Vim
If you want to switch from (other language) to English when going from insert mode to normal mode in vim/neovim, add this to your config:
inoremap <ESC> <ESC>:execute 'silent! !kbswitch com.apple.keylayout.ABC'<CR>:echon ''<CR>
Note that the exectuble must be in your $PATH.