From ebd8e331d628a26c9dcc2e599f91b15f1016dc20 Mon Sep 17 00:00:00 2001 From: Fabian Ising Date: Mon, 24 Oct 2022 12:53:18 +0200 Subject: [PATCH] Reattach tmux sessions on alacritty start --- .config/alacritty/alacritty.yml | 8 ++++++-- tmux/tmux_attach.sh | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100755 tmux/tmux_attach.sh diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml index 2b7c95c..ea07fa1 100644 --- a/.config/alacritty/alacritty.yml +++ b/.config/alacritty/alacritty.yml @@ -30,10 +30,14 @@ scrolling: history: 0 shell: - program: tmux + program: zsh + args: + - "-c" + - "$HOME/.tmux/tmux_attach.sh" alt_send_esc: false live_config_reload: true key_bindings: - - { key: F, mods: Control, command: {program: "zsh", args: ["-c","PATH=/usr/local/bin:$PATH python3 ~/.config/alacritty/color_switcher.py 2>&1 >> /tmp/ala.log"]} } + - { key: F, mods: Control, command: {program: "zsh", args: ["-c","PATH=/usr/local/bin:$PATH python3 ~/.config/alacritty/color_switcher.py"]} } + - { key: T, mods: Command, command: {program: "alacritty", args: ["-e","zsh"]} } # Spawn alacritty without tmux diff --git a/tmux/tmux_attach.sh b/tmux/tmux_attach.sh new file mode 100755 index 0000000..7745b9c --- /dev/null +++ b/tmux/tmux_attach.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# +# tmux-attach - attach to first unattached session or +# create new session if none are found +# +N=$(tmux ls | grep -v attached | head -1 | cut -d: -f1) + +if [[ ! -z $N ]] +then + ATTACH_OPTS="attach -t $N" +fi + +exec tmux $ATTACH_OPTS