diff options
author | Thomas Adam <thomas@xteddy.org> | 2019-03-14 22:02:39 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2019-03-14 22:02:39 +0000 |
commit | 2c755e3c55a35e412d75a870005547f77418c5b3 (patch) | |
tree | 83e7d582d6b95385f6d0ea521955c2d114e8992f | |
parent | d58bccfc636fe0778fa1abefdb0a171165f27784 (diff) | |
parent | 38064e759342b38fbeea48ea716b7d29679271b1 (diff) | |
download | rtmux-2c755e3c55a35e412d75a870005547f77418c5b3.tar.gz rtmux-2c755e3c55a35e412d75a870005547f77418c5b3.tar.bz2 rtmux-2c755e3c55a35e412d75a870005547f77418c5b3.zip |
Merge branch 'obsd-master'
-rw-r--r-- | cmd-display-message.c | 2 | ||||
-rw-r--r-- | cmd-pipe-pane.c | 2 | ||||
-rw-r--r-- | format.c | 21 | ||||
-rw-r--r-- | server-client.c | 2 | ||||
-rw-r--r-- | tmux.1 | 6 |
5 files changed, 25 insertions, 8 deletions
diff --git a/cmd-display-message.c b/cmd-display-message.c index 5856e2d8..6dd210ac 100644 --- a/cmd-display-message.c +++ b/cmd-display-message.c @@ -86,7 +86,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item) ft = format_create(item->client, item, FORMAT_NONE, 0); format_defaults(ft, target_c, s, wl, wp); - msg = format_expand_time(ft, template, time(NULL)); + msg = format_expand_time(ft, template, 0); if (args_has(self->args, 'p')) cmdq_print(item, "%s", msg); else if (c != NULL) diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c index 48e66add..574ad462 100644 --- a/cmd-pipe-pane.c +++ b/cmd-pipe-pane.c @@ -109,7 +109,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item) /* Expand the command. */ ft = format_create(item->client, item, FORMAT_NONE, 0); format_defaults(ft, c, s, wl, wp); - cmd = format_expand_time(ft, args->argv[0], time(NULL)); + cmd = format_expand_time(ft, args->argv[0], 0); format_free(ft); /* Fork the child. */ @@ -95,9 +95,10 @@ format_job_cmp(struct format_job *fj1, struct format_job *fj2) #define FORMAT_QUOTE 0x8 #define FORMAT_LITERAL 0x10 #define FORMAT_EXPAND 0x20 -#define FORMAT_SESSIONS 0x40 -#define FORMAT_WINDOWS 0x80 -#define FORMAT_PANES 0x100 +#define FORMAT_EXPANDTIME 0x40 +#define FORMAT_SESSIONS 0x80 +#define FORMAT_WINDOWS 0x100 +#define FORMAT_PANES 0x200 /* Entry in format tree. */ struct format_entry { @@ -1017,7 +1018,7 @@ format_build_modifiers(struct format_tree *ft, const char **s, u_int *count) /* * Modifiers are a ; separated list of the forms: - * l,m,C,b,d,t,q + * l,m,C,b,d,t,q,E,T,S,W,P * =a * =/a * =/a/ @@ -1034,7 +1035,7 @@ format_build_modifiers(struct format_tree *ft, const char **s, u_int *count) cp++; /* Check single character modifiers with no arguments. */ - if (strchr("lmCbdtqESWP", cp[0]) != NULL && + if (strchr("lmCbdtqETSWP", cp[0]) != NULL && format_is_end(cp[1])) { format_add_modifier(&list, count, cp, 1, NULL, 0); cp++; @@ -1321,6 +1322,9 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen, case 'E': modifiers |= FORMAT_EXPAND; break; + case 'T': + modifiers |= FORMAT_EXPANDTIME; + break; case 'S': modifiers |= FORMAT_SESSIONS; break; @@ -1448,6 +1452,11 @@ done: free(value); value = new; } + else if (modifiers & FORMAT_EXPANDTIME) { + new = format_expand_time(ft, value, 0); + free(value); + value = new; + } /* Perform substitution if any. */ if (sub != NULL) { @@ -1498,6 +1507,8 @@ format_expand_time(struct format_tree *ft, const char *fmt, time_t t) if (fmt == NULL || *fmt == '\0') return (xstrdup("")); + if (t == 0) + t = time(NULL); tm = localtime(&t); if (strftime(s, sizeof s, fmt, tm) == 0) diff --git a/server-client.c b/server-client.c index 098ff45e..7c879d2b 100644 --- a/server-client.c +++ b/server-client.c @@ -1547,7 +1547,7 @@ server_client_set_title(struct client *c) ft = format_create(c, NULL, FORMAT_NONE, 0); format_defaults(ft, c, NULL, NULL, NULL); - title = format_expand_time(ft, template, time(NULL)); + title = format_expand_time(ft, template, 0); if (c->title == NULL || strcmp(title, c->title) != 0) { free(c->title); c->title = xstrdup(title); @@ -3821,6 +3821,12 @@ will expand the format twice, for example is the result of expanding the content of the .Ic status-left option rather than the content itself. +.Ql T: +is like +.Ql E: +but also expands +.Xr strftime 3 +specifiers. .Ql S: , .Ql W: or |