From 154d778f7caeb500f0c2be9960c43e45ca5a7c6e Mon Sep 17 00:00:00 2001 From: thek4n Date: Tue, 5 Mar 2024 23:24:42 +0300 Subject: [PATCH] feat(zsh): if tmux session ask to exit --- home/user/.config/bash/aliases | 1 - home/user/.config/bash/functions | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/home/user/.config/bash/aliases b/home/user/.config/bash/aliases index 0c07d7e..eba2472 100644 --- a/home/user/.config/bash/aliases +++ b/home/user/.config/bash/aliases @@ -38,7 +38,6 @@ alias path='echo -e ${PATH//:/\\n}' # shorts alias c='clear' -alias q='exit 0' alias h='history 0' alias j='jobs -l' diff --git a/home/user/.config/bash/functions b/home/user/.config/bash/functions index d46e89a..3600aff 100644 --- a/home/user/.config/bash/functions +++ b/home/user/.config/bash/functions @@ -221,4 +221,20 @@ most-often-commands() { # Disable tmux on remote machine ssht() { ssh -t "$1" 'TMUX=NO $SHELL -l' +} + +q() { + if [[ -n "$TMUX" ]]; then + local REPLY + echo -n "Tmux session - you really want to exit? [Y/n] " + read REPLY + + if [[ "$REPLY" == [Yy]* ]]; then + exit 0 + else + echo "Press 'Ctrl+b d' to detach tmux session" + return 0 + fi + fi + exit 0 } \ No newline at end of file