小编kla*_*mcm的帖子

将 tmux 变量传递到 tmux.conf 中的 shell 命令中

我正在尝试编辑 tmux 的左下角状态部分。我想展示

会话:#{session_name}

使用此设置将此字符串的当前最大长度设置为 20

状态左长度 20

这工作正常,但一旦我输入超过 20 的会话名称(包括“Session:”),tmux 就会截断文本。我想处理整个字符串,以便任何超过 20 个字符的内容都会像这样显示

会话: mysessio...

IE。字符串被修剪为 20 个字符,最后三个字符被替换为点。我有一个正在运行的 bash 脚本,可以做我想做的事情

string="verylongstringfortesting"
lengthLimit=10

if [ ${#string} -gt $lengthLimit ]
then
  echo ${string:0:$(($lengthLimit-3))}"..."
fi
Run Code Online (Sandbox Code Playgroud)

我该如何将其嵌入到 tmux.conf 中?我知道 #(shell-command) 并且我尝试过 #(echo #{session_name}) 但似乎没有返回会话名称。

shell tmux configuration

5
推荐指数
1
解决办法
3348
查看次数

标签 统计

configuration ×1

shell ×1

tmux ×1