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 OS's. How can I make a command conditional to the OS on which tmux is currently running?
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"
Jimeh https://github.com/jimeh/dotfiles/commit/3838db8 has the answer. Also Chris Johnsen deserves a lot of credit for helping people on the GitHub issue here: https://Github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/issues/8#issuecomment-4134987
Basically, you set up a shell script called
safe-reattach-to-user-namespace that checks for the existence of the real reattach... command.
#! /usr/bin/env bash # If reattach-to-user-namespace is not available, just run the command. if [ -n "$(command -v reattach-to-user-namespace)" ]; then reattach-to-user-namespace $@ else exec "$@" fi