How to create a new window at the last index of my current session

14 views
Skip to first unread message

Sanish Suresh

unread,
Oct 22, 2020, 5:17:31 AM10/22/20
to tmux-users
Hi all,

I am hoping to find an answer to this from this group. I have tried different options after reading the man page, but all in vain.

I want to add windows at the last index of my current session. Let us say I have windows at the indices: 1, 2, 7, 8, 12, 13. I want to write a script, which will automatically figure out the last window index and then add a new window after it (14 in this example).

new-window [-adkP] [-c start-directory] [-F format] [-n window-name] [-t target-window] [shell-command]

For "target-window", the man page says that  ‘^’ selects the highest numbered window. Accordingly I tried different variations, nothing seem to be working. Any help will be greatly appreciated.

Regards,
Sanish

Nicholas Marriott

unread,
Oct 22, 2020, 5:53:07 AM10/22/20
to Sanish Suresh, tmux-users
If your tmux is new enough then "tmux neww -at'{end}'" otherwise you will need to write a script that uses list-windows.

--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/d7822a0c-2ea6-45d2-9b9c-3a0d6de795f8n%40googlegroups.com.

Sanish Suresh

unread,
Oct 23, 2020, 2:04:52 AM10/23/20
to tmux-users
Thanks, I am on an old release and the option doesn't seem to work. As you suggested, I wrote a script to get the last window index and got the job done.
Reply all
Reply to author
Forward
0 new messages