Browse Source

tmus script corrected

84582af
Dirk Alders 2 years ago
parent
commit
c24bd5ad9d
1 changed files with 8 additions and 7 deletions
  1. 8
    7
      tmux_ssh

+ 8
- 7
tmux_ssh View File

@@ -1,13 +1,14 @@
1 1
 #!/bin/sh
2 2
 #
3
-SESSION=$(tmux ls -F "#{session_name}")
4 3
 
5
-echo $NEW
4
+for s in $(tmux list-sessions -F '#{session_name}'); do
5
+    p=$(tmux list-panes -F '#{pane_tty}' -t "$s")
6
+    if [ "$p" = "$(tty)" ]; then
7
+        # Session already running
8
+        exit 0
9
+    fi
10
+done
6 11
 
7
-if [ "$SESSION" = "" ]; then
8
-	tmux attach-session -t default_ssh || tmux new-session -s default_ssh
9
-else
10
-	echo tmux-session \"$SESSION\" already running.
11
-fi
12
+tmux attach-session -t default_ssh || tmux new-session -s default_ssh
12 13
 
13 14
 

Loading…
Cancel
Save