new-window name doesn't expands formats

16 views
Skip to first unread message

Suraj N. Kurapati

unread,
Dec 29, 2019, 9:41:12 PM12/29/19
to tmux-users
Hello,

In the latest tmux 3.0a release (and possibly in a few prior releases),
the `new-window` command isn't expanding formats in the `-n` argument.

I use this feature to insert the session, window, and pane ID of the
currently active window into the name of the new window as follows:

new-window -n '#S:#I.#P' -a '...shell command goes here...'

Was this feature removed deliberately? The CHANGES file doesn't say.

Also, I searched through the git logs and found that this feature was
added on March 1, 2018 as "Expand formats in window and session names."
in commit 182357f24bc7e16d7d7c85cab0c61974f18df2e7.

Thanks for your consideration.

Nicholas Marriott

unread,
Dec 30, 2019, 8:12:42 AM12/30/19
to Suraj N. Kurapati, tmux-users
It must have got lost when I moved everything to spawn.c. Try this
please:

Index: spawn.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/spawn.c,v
retrieving revision 1.12
diff -u -p -r1.12 spawn.c
--- spawn.c 28 Nov 2019 09:45:16 -0000 1.12
+++ spawn.c 30 Dec 2019 13:12:04 -0000
@@ -80,6 +80,8 @@ spawn_log(const char *from, struct spawn
struct winlink *
spawn_window(struct spawn_context *sc, char **cause)
{
+ struct cmdq_item *item = sc->item;
+ struct client *c = item->client;
struct session *s = sc->s;
struct window *w;
struct window_pane *wp;
@@ -182,7 +184,8 @@ spawn_window(struct spawn_context *sc, c
/* Set the name of the new window. */
if (~sc->flags & SPAWN_RESPAWN) {
if (sc->name != NULL) {
- w->name = xstrdup(sc->name);
+ w->name = format_single(item, sc->name, c, s, NULL,
+ NULL);
options_set_number(w->options, "automatic-rename", 0);
} else
w->name = xstrdup(default_window_name(w));
> --
> 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/20191229183852.2580a2c6%40ratham.


Suraj N. Kurapati

unread,
Dec 30, 2019, 8:31:20 PM12/30/19
to Nicholas Marriott, tmux-users
Thanks, this patch worked! Formats are now expanded in `-n` argument.

Nicholas Marriott

unread,
Jan 1, 2020, 4:51:46 PM1/1/20
to Suraj N. Kurapati, tmux-users
Applied now, thanks!
Reply all
Reply to author
Forward
0 new messages