The following command will lock your Mac, forcing you to enter a password to unlock it:
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
Create a Bash alias:
alias lock="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
Add a tmux keybinding for Control
+a
,l
:
bind-key l run-shell '/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend'