Skip to content

Commit

Permalink
fix(tmux): improve trap to go back to last sess OR default
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Jan 14, 2024
1 parent 0fce95d commit 0f791cd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules/tmux/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,18 @@
vim-tmux-navigator
];
};

programs.fish.interactiveShellInit = ''
# traps the shell quit and switch to the last session if it's the last pane
# if last session is not available anymore, switch to default
function __trap_exit_tmux
test (tmux list-windows | count) = 1 || exit
test (tmux list-panes | count) = 1 || exit
tmux switch-client -l || tmux switch-client -t default
end
if set -q TMUX
trap __trap_exit_tmux EXIT
end
'';
}

0 comments on commit 0f791cd

Please sign in to comment.