I'm trying to write a bind for a copy command where I want to test for tmux version and operating system. If tmux version is less than 2.4 and using Linux do one thing and with Mac another and same for greater than version 2.4.
If Linux:
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.4" | bc)" = 1 ]' " \
bind-key -t vi-copy y copy-pipe 'xclip -selection clipboard -in'" " \
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -selection clipboard -in'"
If Mac:
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.4" | bc)" = 1 ]' " \
bind-key -t vi-copy 'y' copy-pipe "reattach-to-user-namespace pbcopy" " \
bind -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel 'tmux save-buffer - | reattach-to-user-namespace pbcopy'"
You could use -a
in your test:
if '[ "blah" = 1 -a "$(uname)" = Linux ]' ...
Or each argument to if-shell is a tmux command so you can nest them:
if 'true' 'if "true" "whatever"'