Tmux configuration conditional to OS


There's some lines of my tmux.conf which I'd like executed only if my OS is Mac. However, I'd like to use my tmux.conf on multiple different operating systems. How can I make a command conditional to the OS on which tmux is currently running?

Best Answer

Use the if-shell command:

if-shell "uname | grep -q Darwin" "tmux-cmd1; tmux-cmd2;" "tmux-cmd3; tmux-cmd4"

You may want to put OS-specific commands in separate files, and execute them via the "source-file" command.

if-shell "uname | grep -q Darwin" "source-file .tmux-macosx" "source-file .tmux-linux"
Related Question