📜  tmux 检查会话是否存在 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:17.906000             🧑  作者: Mango

代码示例1
session="workspace"

# Check if the session exists, discarding output
# We can check $? for the exit status (zero for success, non-zero for failure)
tmux has-session -t $session 2>/dev/null

if [ $? != 0 ]; then
  # Set up your session
fi

# Attach to created session
tmux attach-session -t $session