LoginSignup
1
1

More than 5 years have passed since last update.

tmuxでセッションの有無を判別して起動するスクリプト

Posted at

既に誰か書いていそうだけど備忘録代わりに。
tmuxで毎回アタッチすべきセッションがあるかどうかとか気にする事がないように簡単なシェルスクリプトにしてみた。

#!/bin/bash

tmux ls > /dev/null
if [ $? -eq 1 -a -z "$TMUX" ]; then
    exec tmux
elif [ -z "$TMUX" ] ; then
    exec tmux attach
else
    echo "sessions should be nested with care."
fi

これをPathの通った場所に保存して実行するとセッションが残っている場合は最後のモノから利用し、なければ新規で使うようになります。

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1