mirror of
https://github.com/zoriya/flake.git
synced 2026-05-23 23:28:09 +00:00
Auto kill temp sessions when switching to a named session
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user