Auto kill temp sessions when switching to a named session

This commit is contained in:
2024-11-21 20:43:19 +01:00
parent 8d09a1e4d4
commit c6dd4702e1
2 changed files with 8 additions and 1 deletions
+6
View File
@@ -18,8 +18,14 @@ if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
exit 0
fi
current_session=$(tmux display-message -p "#S")
if ! tmux has-session "-t=$selected_name" 2> /dev/null; then
tmux new-session -ds "$selected_name" -c "$selected"
fi
tmux switch-client -t "$selected_name"
if [[ "$current_session" == \#* ]]; then
tmux kill-session -t "$current_session"
fi
+2 -1
View File
@@ -188,6 +188,7 @@
py = "python3 2> /dev/null || nix shell nixpkgs#python3 -c python3";
jctl = "sudo journalctl -n 1000 -fu";
sloc = "scc";
mi = "mediainfo";
# viu doesn't work with tmux, icat does. using that while waiting
viu = "kitty +kitten icat";
icat = "kitty +kitten icat";
@@ -234,7 +235,7 @@
initExtraFirst = ''
# Create a new tmux session (with a random name) and attach.
if [[ -z "$TMUX" ]]; then
exec tmux -u new-session -s "$(hexdump -n 4 -v -e '/1 "%02X"' /dev/urandom)"
exec tmux -u new-session -s "#$(hexdump -n 4 -v -e '/1 "%02X"' /dev/urandom)"
fi
'';
initExtraBeforeCompInit = builtins.readFile ./comp.zsh;