tmux.conf只有当我的操作系统是 Mac 时,我才会执行一些我的代码。但是,我想tmux.conf在多个不同的操作系统上使用我的。如何使命令以 tmux 当前运行的操作系统为条件?
che*_*ner 57
使用if-shell命令:
if-shell "uname | grep -q Darwin" "tmux-cmd1; tmux-cmd2;" "tmux-cmd3; tmux-cmd4"
Run Code Online (Sandbox Code Playgroud)
您可能希望将特定于操作系统的命令放在单独的文件中,并通过“源文件”命令执行它们。
if-shell "uname | grep -q Darwin" "source-file .tmux-macosx" "source-file .tmux-linux"
Run Code Online (Sandbox Code Playgroud)
Iva*_*van 13
Jimeh https://github.com/jimeh/dotfiles/commit/3838db8有答案。此外,Chris Johnsen 因在 GitHub 问题上帮助人们而值得称赞:https : //Github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/issues/8#issuecomment-4134987
基本上,您设置了一个名为的 shell 脚本safe-reattach-to-user-namespace,用于检查是否存在真正的 reattach... 命令。
#! /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
Run Code Online (Sandbox Code Playgroud)