浏览代码

Update tmu -z to calculate names automatically

Samuel W. Flint 4 年之前
父节点
当前提交
11d7747b1b
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. 9 1
      tmu

+ 9 - 1
tmu

@@ -21,7 +21,15 @@ do
             XWINFLAG=true
             ;;
         z)
-            ${TERMCMD} -e tmux
+            NAME=$(tmux list-sessions -F '#S' | grep term | sort -r | head -n 1)
+            if [ -n "${NAME}" ] ; then
+                NUM=$(echo $NAME | cut -d- -f 2)
+                NUM=$(( NUM + 1 ))
+                NAME="term-${NUM}"
+            else
+                NAME=term-0
+            fi
+            ${TERMCMD} -e tmux new -s "${NAME}"
             ;;
         l)
             if [[ $XWINFLAG != "true" ]] ; then