I'm writing a script to leverage Tmux to run some commands; however, rather than having to constantly run tmux list-windows
, get a count number, and assume the last window number, I'm wondering if there's a way to just simply rename the last window that was created so that I can reference that window from its name going forward.
Here's what I'm currently doing:
last_window=$(tmux list-windows | wc -l)
tmux rename-window -t session_name:$(last_window) new_window_name
but this seems a little messy. Any thoughts?