From 8a368e3d3b7b85bc65f49602af1dafbf6f57332c Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Wed, 10 Apr 2019 12:20:32 +0200 Subject: [PATCH] Start tmux also for alacritty. --- zsh/.config/zsh/.zshrc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index fa88b99..e18af7b 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -1,5 +1,16 @@ -# If connected over SSH and not already in tmux, start tmux. -if [[ -o interactive ]] && [[ -n $SSH_TTY ]] && [[ -z $TMUX ]] && type tmux &> /dev/null; then +# Check if we want a multiplexer. +# +# We want one if we are either: +# - connected over SSH (for security), or +# - using alacritty, since it doesn't have tabs. +function want_multiplexer() { + [[ $TERM == "alacritty" ]] || \ + [[ -n $SSH_TTY ]] +} + + +# If we want a multiplexer and not already in tmux, start tmux. +if [[ -o interactive ]] && want_multiplexer && [[ -z $TMUX ]] && type tmux &> /dev/null; then if tmux has-session &> /dev/null; then tmux attach else @@ -8,6 +19,8 @@ if [[ -o interactive ]] && [[ -n $SSH_TTY ]] && [[ -z $TMUX ]] && type tmux &> / exit $? fi +unset -f want_multiplexer + # Check for service-managed keyring if [[ -z $SSH_AUTH_SOCK ]] && [[ -S $XDG_RUNTIME_DIR/ssh-agent.socket ]]; then export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"