I would like to determine the OS X keyboard layout (or \"input source\" as OS X calls it) from the terminal so that I can show it in places like the tmux status bar.
I was searching for an answer to an issue I was having with the keyboard layout that lead me to this post. I found the solution for my problem here.
Resolved Issues You might experience difficulty logging into your account because the keyboard layout may change unexpectedly at the Login window. (40821875)
Workaround: Log in to your account, launch Terminal, and execute the following command:
sudo rm -rf /var/db/securityagent/Library/Preferences/com.apple.HIToolbox.plist
This is an Apple official release note for Mojave