mirror of
https://github.com/tmux/tmux.git
synced 2026-10-11 04:44:25 +00:00
Merge branch 'obsd-master'
This commit is contained in:
16
format.c
16
format.c
@@ -127,6 +127,7 @@ format_job_cmp(struct format_job *fj1, struct format_job *fj2)
|
|||||||
#define FORMAT_QUOTE_SHELL_SQ 0x20000000
|
#define FORMAT_QUOTE_SHELL_SQ 0x20000000
|
||||||
#define FORMAT_OPTIONS 0x40000000
|
#define FORMAT_OPTIONS 0x40000000
|
||||||
#define FORMAT_ENVIRON 0x80000000ULL
|
#define FORMAT_ENVIRON 0x80000000ULL
|
||||||
|
#define FORMAT_DIFFERENCE 0x100000000ULL
|
||||||
|
|
||||||
/* Limit on recursion. */
|
/* Limit on recursion. */
|
||||||
#define FORMAT_LOOP_LIMIT 100
|
#define FORMAT_LOOP_LIMIT 100
|
||||||
@@ -4221,6 +4222,17 @@ format_relative_time(time_t t)
|
|||||||
return (xstrdup(out));
|
return (xstrdup(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make a time difference in seconds. */
|
||||||
|
static char *
|
||||||
|
format_time_difference(time_t t)
|
||||||
|
{
|
||||||
|
time_t now = time(NULL);
|
||||||
|
char *out;
|
||||||
|
|
||||||
|
xasprintf(&out, "%ld", (long)now - (long)t);
|
||||||
|
return (out);
|
||||||
|
}
|
||||||
|
|
||||||
/* Find a format entry. */
|
/* Find a format entry. */
|
||||||
static char *
|
static char *
|
||||||
format_find(struct format_tree *ft, const char *key, uint64_t modifiers,
|
format_find(struct format_tree *ft, const char *key, uint64_t modifiers,
|
||||||
@@ -4305,6 +4317,8 @@ found:
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
if (modifiers & FORMAT_RELATIVE)
|
if (modifiers & FORMAT_RELATIVE)
|
||||||
found = format_relative_time(t);
|
found = format_relative_time(t);
|
||||||
|
else if (modifiers & FORMAT_DIFFERENCE)
|
||||||
|
found = format_time_difference(t);
|
||||||
else if (modifiers & FORMAT_PRETTY)
|
else if (modifiers & FORMAT_PRETTY)
|
||||||
found = format_pretty_time(t, 0);
|
found = format_pretty_time(t, 0);
|
||||||
else {
|
else {
|
||||||
@@ -5684,6 +5698,8 @@ format_replace(struct format_expand_state *es, const char *key, size_t keylen,
|
|||||||
modifiers |= FORMAT_PRETTY;
|
modifiers |= FORMAT_PRETTY;
|
||||||
else if (strchr(fm->argv[0], 'r') != NULL)
|
else if (strchr(fm->argv[0], 'r') != NULL)
|
||||||
modifiers |= FORMAT_RELATIVE;
|
modifiers |= FORMAT_RELATIVE;
|
||||||
|
else if (strchr(fm->argv[0], 'd') != NULL)
|
||||||
|
modifiers |= FORMAT_DIFFERENCE;
|
||||||
else if (fm->argc >= 2 &&
|
else if (fm->argc >= 2 &&
|
||||||
strchr(fm->argv[0], 'f') != NULL) {
|
strchr(fm->argv[0], 'f') != NULL) {
|
||||||
free(time_format);
|
free(time_format);
|
||||||
|
|||||||
6
tmux.1
6
tmux.1
@@ -6815,10 +6815,14 @@ Adding
|
|||||||
will use shorter but less accurate time format for times in the past.
|
will use shorter but less accurate time format for times in the past.
|
||||||
.Ql r
|
.Ql r
|
||||||
.Pq Ql t/r
|
.Pq Ql t/r
|
||||||
will show the time relative to the current time, for example
|
will give the time relative to the current time, for example
|
||||||
.Ql \&1m
|
.Ql \&1m
|
||||||
or
|
or
|
||||||
.Ql 2m23s .
|
.Ql 2m23s .
|
||||||
|
.Ql d
|
||||||
|
.Pq Ql t/d
|
||||||
|
will give the difference from the time to current time in seconds (future
|
||||||
|
times are negative).
|
||||||
A custom format may be given using an
|
A custom format may be given using an
|
||||||
.Ql f
|
.Ql f
|
||||||
suffix (note that
|
suffix (note that
|
||||||
|
|||||||
Reference in New Issue
Block a user