Tmux 在调用 `shell` 以显示来自 Bash 命令的输出时不显示换行符

Tmux doesn't show line breaks when calling `shell` to display output from Bash command

给定以下文本文件"HelloWorld.txt"

Hello World

~~~line break~~~

This is a text file

在 .tmux.conf 中,我配置了以下设置:

bind F1 shell "cat HelloWorld.txt"

当我使用这个快捷方式时,Tmux 打印如下:

Hello World

This is a text file

那个换行符神秘地消失了。

如何保留换行符?

我找不到错误报告,但这似乎是 tmux 的 run-shell 命令的行为方式。 workaround I found 是通过 sed 管道输出,用 space.

替换每个空行

你的例子会变成这样:

bind F1 run-shell "cat HelloWorld.txt | sed 's/^$/ /'"