aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicm <nicm>2019-03-14 21:31:43 +0000
committernicm <nicm>2019-03-14 21:31:43 +0000
commit38064e759342b38fbeea48ea716b7d29679271b1 (patch)
treed7e87ee2d174ed2ad6f370fd93aacebff795f389
parent1416ceb57589ba119a36d9f32d919d3444f7b0d0 (diff)
downloadrtmux-38064e759342b38fbeea48ea716b7d29679271b1.tar.gz
rtmux-38064e759342b38fbeea48ea716b7d29679271b1.tar.bz2
rtmux-38064e759342b38fbeea48ea716b7d29679271b1.zip
Add T format modifier like E but also do strftime(3).
-rw-r--r--format.c19
-rw-r--r--tmux.16
2 files changed, 20 insertions, 5 deletions
diff --git a/format.c b/format.c
index 6f042f8a..530e2403 100644
--- a/format.c
+++ b/format.c
@@ -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 {
@@ -1001,7 +1002,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/
@@ -1018,7 +1019,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++;
@@ -1305,6 +1306,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;
@@ -1432,6 +1436,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) {
diff --git a/tmux.1 b/tmux.1
index 49e82643..12da91ec 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3719,6 +3719,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