当没有正在运行的会话时,Tmux无法连接到"tmux ls"上的服务器错误 [英] Tmux failed to connect to server error on `tmux ls` when there are no running sessions

查看:48
本文介绍了当没有正在运行的会话时,Tmux无法连接到"tmux ls"上的服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅在我登录服务器时编写一个快速循环以列出现有的tmux会话,这取决于是否安装了tmux(通过CentOS上的.bashrc).

Just writing a quick loop to list out existing tmux sessions when I log into a server, depending on whether tmux is installed (via .bashrc on CentOS).

if rpm -q tmux; then
    echo -e "TMUX sessions running:\n"
    echo `tmux ls`
fi

当tmux有一个或两个会话时,这很好用,但是如果没有正在运行的tmux会话,我将无法连接到服务器:没有这样的文件或目录.

This works great when tmux has a session or two, but if there are no running tmux sessions, I'm getting failed to connect to server: No such file or directory.

有没有办法抑制这种情况?

Is there a way to suppress this?

谢谢!

推荐答案

结合使用@Barmar和@Etan Reisner的建议:

Using a combination of @Barmar and @Etan Reisner 's advice:

tmux ls 2> /dev/null

没有会话时,不会回显任何内容,否则将报告该列表.

Nothing is echoed in when there are no sessions, otherwise the list is reported.

这篇关于当没有正在运行的会话时,Tmux无法连接到"tmux ls"上的服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆