summaryrefslogtreecommitdiffstats
path: root/.zshrc
diff options
context:
space:
mode:
authorTyler Davis <tydavis@gmail.com>2022-05-21 02:59:36 +0000
committerTyler Davis <tydavis@gmail.com>2022-05-21 02:59:36 +0000
commitb2a69a00798034ebae4fed8b501f2274f4a9810a (patch)
treed46f31b6d6efcba1729e27ec591f37e822e7b842 /.zshrc
parent4ba5d6d99eef47c14ee481f895b120d025327115 (diff)
downloaddotfiles-b2a69a00798034ebae4fed8b501f2274f4a9810a.tar.gz
dotfiles-b2a69a00798034ebae4fed8b501f2274f4a9810a.zip
zsh: add automatic tmux session
Diffstat (limited to '.zshrc')
-rw-r--r--.zshrc15
1 files changed, 15 insertions, 0 deletions
diff --git a/.zshrc b/.zshrc
index ae50701..1272f85 100644
--- a/.zshrc
+++ b/.zshrc
@@ -147,3 +147,18 @@ alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
export PS1="%m [%n:%c]%# "
+if [ "$(command -v tmux)" ]; then
+ ## == TMUX sessions ==
+ tmux has-session -t main 2>/dev/null
+
+ # Create the session if it doesn't exists.
+ if [[ $? -ne 0 ]]; then
+ TMUX='' tmux new-session -d -s main
+ fi
+
+ if [[ -z "$TMUX" ]]; then
+ tmux attach-session -t main
+ else
+ tmux switch-client -t main
+ fi
+fi