From 9adae124ebdd4c08cab42705cf9e3b844c1825e2 Mon Sep 17 00:00:00 2001 From: Gil Portenseigne Date: Wed, 25 Sep 2024 11:37:54 +0200 Subject: [PATCH] retour de tmux --- .config/bash/gil_specific.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.config/bash/gil_specific.sh b/.config/bash/gil_specific.sh index fd09027..b6143d1 100644 --- a/.config/bash/gil_specific.sh +++ b/.config/bash/gil_specific.sh @@ -1,6 +1,6 @@ export EDITOR=$HOME/.local/bin/nvim.appimage -export TERMINAL=gnome-terminal -export SHELL=/usr/bin/bash +export TERMINAL=st +export SHELL=/usr/bin/tmux export PATH=$HOME/.local/bin:$PATH @@ -59,3 +59,22 @@ reboot_to_windows () sudo grub-reboot "$windows_title" && sudo reboot } alias windows='reboot_to_windows' + + +session_name="gil" + +# 1. First you check if a tmux session exists with a given name. +tmux has-session -t=$session_name 2> /dev/null + +# 2. Create the session if it doesn't exists. +if [[ $? -ne 0 ]]; then + TMUX='' tmux new-session -d -s "$session_name" +fi + +# 3. Attach if outside of tmux, switch if you're in tmux. +if [[ -z "$TMUX" ]]; then + tmux attach -t "$session_name" +else + tmux switch-client -t "$session_name" +fi +