From 72cf1056e8cac3838955da05700c28b646bf37df Mon Sep 17 00:00:00 2001 From: work Date: Tue, 23 Jan 2024 15:57:39 +0300 Subject: [PATCH] Util : Add _is_tmux. --- .config/bash/module/Tmux.sh | 2 +- .config/bash/module/Util.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.config/bash/module/Tmux.sh b/.config/bash/module/Tmux.sh index 9b5f2de..5060fbe 100644 --- a/.config/bash/module/Tmux.sh +++ b/.config/bash/module/Tmux.sh @@ -11,7 +11,7 @@ function ta() { tmux new-session -s "${name}" -d &> /dev/null # Attach to session. - if [[ "${TERM_PROGRAM}" = "tmux" ]]; then + if _is_tmux; then tmux switch-client -t "${name}" else tmux attach-session -t "${name}" diff --git a/.config/bash/module/Util.sh b/.config/bash/module/Util.sh index 79bfa7b..4910879 100644 --- a/.config/bash/module/Util.sh +++ b/.config/bash/module/Util.sh @@ -116,3 +116,8 @@ function _contains() { return 1 } + +# Check if inside Tmux. +function _is_tmux() { + [[ "${TERM_PROGRAM}" = "tmux" ]] +}