How to use session-closed hook #4345
RobertWadeSteele
started this conversation in
General
Replies: 1 comment 3 replies
-
Don't think per-session |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm running
tmux 3.5a
. I had an idea for a popup script that can start sessions linked to the current session in a popup and then attach and detach when the hotkey is pressed repeatedly.Everything works great except that I want to clean up the popup sessions when the "parent" session is closed. I assumed hooks would be the obvious solution. When the popup session is created I set a hook on the "parent" session as follows.
When I enter
tmux show-hooks -t ${parent_session_name}
I can see that there is what looks like a hook entry that looks like the following.session-closed[0] kill-session -t dotfiles__popup__scratch
This hook entry is not on any other session so it seems I am correctly targeting the "parent" session. No matter how I close the parent session however the script never seems to run. I tried logging to a file and nothing was logged. Is this hook just not running for some reason? What am I doing wrong? The session-closed[0] portion makes me question if this hook is somehow targeting a session that doesn't exist despite passing a valid target session and only seeing the hook show up on said target session.
The script is below. This is pretty much the first script I've written in bash, period, let alone for tmux so I assume I'm just missing something but the man page doesn't seem to show anything beyond what I've already tried.
This discussion looks like it could be related but it's from so long ago that I can't imagine this is still the same issue. #1245 If this is the same issue then is there a reason this wasn't fixed back in 2018? Seems like this is a pretty useful hook which should work for targeted sessions.
Beta Was this translation helpful? Give feedback.
All reactions