From 96ebea7a5b20ceb94264194d5e5f0cb371a651d2 Mon Sep 17 00:00:00 2001 From: tusqasi <2002.tushar.kuntawar@gmail.com> Date: Tue, 18 May 2021 10:56:31 +0530 Subject: [PATCH 1/3] Better functioning of tmux_session.sh Now it asks for the name of new session --- tmux_session.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tmux_session.sh b/tmux_session.sh index 419d8b6..3fb55d4 100755 --- a/tmux_session.sh +++ b/tmux_session.sh @@ -2,15 +2,22 @@ function tmux_sessions() { - tmux list-session -F '#S' + # Get all existing sessions + tmux list-session -F '#S'|cut -d'-' -f 1 } +# Take the choice of session in TMUX_SESSION +TMUX_SESSION=$( (tmux_sessions; echo "New") | rofi -dmenu -p "Select existing tmux session") -TMUX_SESSION=$( (echo new; tmux_sessions) | rofi -dmenu -p "Select tmux session") - -if [[ x"new" = x"${TMUX_SESSION}" ]]; then - rofi-sensible-terminal -e tmux new-session & +if [[ x"New" = x"${TMUX_SESSION}" ]]; then + # Ask for name of session + NAME=$(rofi -dmenu -p "Name for new session") + rofi-sensible-terminal -e tmux new-session -t "${NAME}" & elif [[ -z "${TMUX_SESSION}" ]]; then echo "Cancel" else - rofi-sensible-terminal -e tmux attach -t "${TMUX_SESSION}" & + if tmux_sessions | grep -q '${TMUX_SESSION}'; then + rofi-sensible-terminal -e tmux attach -t ${TMUX_SESSION} & + else + rofi-sensible-terminal -e tmux new -t ${TMUX_SESSION} & + fi fi From ee99ca8ca457120b8c8a0f14d934b6de230d6f79 Mon Sep 17 00:00:00 2001 From: tusqasi <2002.tushar.kuntawar@gmail.com> Date: Tue, 18 May 2021 14:54:19 +0530 Subject: [PATCH 2/3] Corrected the beheviour this is the update --- tmux_session.sh | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tmux_session.sh b/tmux_session.sh index 3fb55d4..917a8c8 100755 --- a/tmux_session.sh +++ b/tmux_session.sh @@ -2,22 +2,17 @@ function tmux_sessions() { - # Get all existing sessions - tmux list-session -F '#S'|cut -d'-' -f 1 + tmux list-session -F '#S' } -# Take the choice of session in TMUX_SESSION -TMUX_SESSION=$( (tmux_sessions; echo "New") | rofi -dmenu -p "Select existing tmux session") +TMUX_SESSION=$( (tmux_sessions; echo 'New') | rofi -dmenu -p 'Select existing tmux session') if [[ x"New" = x"${TMUX_SESSION}" ]]; then - # Ask for name of session - NAME=$(rofi -dmenu -p "Name for new session") - rofi-sensible-terminal -e tmux new-session -t "${NAME}" & + NAME=$(rofi -dmenu -p 'Name for new session') + echo "hear" + alacritty -e tmux new-session -s "${NAME}" & elif [[ -z "${TMUX_SESSION}" ]]; then echo "Cancel" else - if tmux_sessions | grep -q '${TMUX_SESSION}'; then - rofi-sensible-terminal -e tmux attach -t ${TMUX_SESSION} & - else - rofi-sensible-terminal -e tmux new -t ${TMUX_SESSION} & - fi + echo "there" + alacritty -e tmux new -AD -s ${TMUX_SESSION} fi From cecfc75dc9b8f56c68b626175a13cc484c38d193 Mon Sep 17 00:00:00 2001 From: tusqasi <2002.tushar.kuntawar@gmail.com> Date: Tue, 18 May 2021 14:58:51 +0530 Subject: [PATCH 3/3] genralized --- tmux_session.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tmux_session.sh b/tmux_session.sh index 917a8c8..57e640f 100755 --- a/tmux_session.sh +++ b/tmux_session.sh @@ -9,10 +9,10 @@ TMUX_SESSION=$( (tmux_sessions; echo 'New') | rofi -dmenu -p 'Select existing tm if [[ x"New" = x"${TMUX_SESSION}" ]]; then NAME=$(rofi -dmenu -p 'Name for new session') echo "hear" - alacritty -e tmux new-session -s "${NAME}" & + rofi-sensible-terminal -e tmux new-session -s "${NAME}" & elif [[ -z "${TMUX_SESSION}" ]]; then echo "Cancel" else echo "there" - alacritty -e tmux new -AD -s ${TMUX_SESSION} + rofi-sensible-terminal -e tmux new -AD -s ${TMUX_SESSION} fi