Takatoshi Matsumoto
2015-02-27 07:40:07 UTC
Hi, this patch adds session_activity and session_activity_string.
With these additions, it's possible to do some operations to sessions by active time from CLI.
e.g. getting last active session
tmux list-sessions -F'#{session_activity} #{session_id} #{session_name}' | tr -d '$' | sort -k 1 -k 2n
---
format.c | 6 ++++++
tmux.1 | 2 ++
2 files changed, 8 insertions(+)
diff --git a/format.c b/format.c
index 776de96..2ef5b84 100644
--- a/format.c
+++ b/format.c
@@ -503,6 +503,12 @@ format_defaults_session(struct format_tree *ft, struct session *s)
*strchr(tim, '\n') = '\0';
format_add(ft, "session_created_string", "%s", tim);
+ t = s->activity_time.tv_sec;
+ format_add(ft, "session_activity", "%lld", (long long) t);
+ tim = ctime(&t);
+ *strchr(tim, '\n') = '\0';
+ format_add(ft, "session_activity_string", "%s", tim);
+
format_add(ft, "session_attached", "%u", s->attached);
format_add(ft, "session_many_attached", "%u", s->attached > 1);
}
diff --git a/tmux.1 b/tmux.1
index f615dd0..876dd74 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3153,6 +3153,8 @@ The following variables are available, where appropriate:
.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane"
.It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
+.It Li "session_activity" Ta "" Ta "Integer time session last had activity"
+.It Li "session_activity_string" Ta "" Ta "String time session last had activity"
.It Li "session_created" Ta "" Ta "Integer time session created"
.It Li "session_created_string" Ta "" Ta "String time session created"
.It Li "session_group" Ta "" Ta "Number of session group"
With these additions, it's possible to do some operations to sessions by active time from CLI.
e.g. getting last active session
tmux list-sessions -F'#{session_activity} #{session_id} #{session_name}' | tr -d '$' | sort -k 1 -k 2n
---
format.c | 6 ++++++
tmux.1 | 2 ++
2 files changed, 8 insertions(+)
diff --git a/format.c b/format.c
index 776de96..2ef5b84 100644
--- a/format.c
+++ b/format.c
@@ -503,6 +503,12 @@ format_defaults_session(struct format_tree *ft, struct session *s)
*strchr(tim, '\n') = '\0';
format_add(ft, "session_created_string", "%s", tim);
+ t = s->activity_time.tv_sec;
+ format_add(ft, "session_activity", "%lld", (long long) t);
+ tim = ctime(&t);
+ *strchr(tim, '\n') = '\0';
+ format_add(ft, "session_activity_string", "%s", tim);
+
format_add(ft, "session_attached", "%u", s->attached);
format_add(ft, "session_many_attached", "%u", s->attached > 1);
}
diff --git a/tmux.1 b/tmux.1
index f615dd0..876dd74 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3153,6 +3153,8 @@ The following variables are available, where appropriate:
.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane"
.It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
+.It Li "session_activity" Ta "" Ta "Integer time session last had activity"
+.It Li "session_activity_string" Ta "" Ta "String time session last had activity"
.It Li "session_created" Ta "" Ta "Integer time session created"
.It Li "session_created_string" Ta "" Ta "String time session created"
.It Li "session_group" Ta "" Ta "Number of session group"
--
2.3.0
2.3.0