Ver código fonte

添加 tmux.sh

1585346868 1 mês atrás
pai
commit
5205b770aa
1 arquivos alterados com 21 adições e 0 exclusões
  1. 21 0
      tmux.sh

+ 21 - 0
tmux.sh

@@ -0,0 +1,21 @@
+
+
+#!/bin/bash
+
+# 设置默认的会话名称
+SESSION_NAME="ngs"
+
+# 检查是否提供了会话名称作为参数
+if [ -n "$1" ]; then
+    SESSION_NAME="$1"
+fi
+
+# 检查是否已经存在同名的 tmux 会话
+if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
+    echo "Session '$SESSION_NAME' already exists. Attaching..."
+else
+    echo "Session '$SESSION_NAME' does not exist. Creating a new session..."
+fi
+
+# 创建新会话或附加到现有会话
+tmux new-session -A -s "$SESSION_NAME"