guywithacube / dotfiles

0 stars 0 forks source link

Refactor non-portable usage of `set-hook -R session-created` #16

Closed guywithacube closed 1 year ago

guywithacube commented 1 year ago

Currently, "automatically configuring" the TERM environment variable in tmux relies on the session-created hook.

Calling set-hook -R session-created when tmux does not have any sessions has different functionality between tmux 3.2a and tmux 3.3a. This may occur when set-hook -R session-created is directly from tmux.conf.

tmux 3.2a

Invoking tmux new-session results in:

server exited unexpectedly

The ending of tmux-server-24242.log is as follows:

1673642800.543227 cmd_parse_build_commands: set-hook -R session-created
1673642800.543232 cmd_find_best_session: 0 sessions to try
1673642800.543237 cmdq_next <global>: [set-hook/0x7fca8380e320] (0), flags 0
1673642800.543244 cmdq_fire_command <global>: (1537) set-hook -R session-created
1673642800.543248 cmd_find_best_session: 0 sessions to try
1673642800.543252 cmd_find_current_client: no target, return 0x0
1673642800.543255 cmd_find_best_session: 0 sessions to try
1673642800.543259 cmd_find_current_client: no target, return 0x0
1673642800.543263 cmd_find_best_session: 0 sessions to try
1673642800.543267 cmd_find_target: target none, type pane, item 0x7fca8380e320, flags QUIET,CANFAIL
1673642800.543271 cmd_find_best_session: 0 sessions to try
1673642800.543275 cmd_find_target: error
1673642800.543279 format_defaults: c=none
1673642800.543283 format_defaults: s=none
1673642800.543286 format_defaults: wl=none
1673642800.543290 format_defaults: wp=none
1673642800.543294 format_expand1: expanding format: session-created
1673642800.543298 format_expand1: result is: session-created

tmux 3.3a

Invoking tmux new-session operates as expected. The relevant tmux server log has nothing substantial.


Ideally, these dotfiles should be as portable as possible. So, it would be nice to find a solution that works on any version of tmux.