From 5aa3098bb6c25e954cacc168a599d78447b4d005 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 15 Jan 2009 23:42:21 +0000 Subject: Support #S #H in status-left/right. --- status.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'status.c') diff --git a/status.c b/status.c index 59ccdc62..bdb7e303 100644 --- a/status.c +++ b/status.c @@ -1,4 +1,4 @@ -/* $Id: status.c,v 1.62 2009-01-14 19:29:32 nicm Exp $ */ +/* $Id: status.c,v 1.63 2009-01-15 23:42:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -25,6 +25,7 @@ #include #include #include +#include #include "tmux.h" @@ -291,7 +292,7 @@ status_replace(struct session *s, char *fmt, time_t t) { struct winlink *wl = s->curw; static char out[BUFSIZ]; - char in[BUFSIZ], ch, *iptr, *optr, *ptr, *endptr; + char in[BUFSIZ], tmp[256], ch, *iptr, *optr, *ptr, *endptr; size_t len; long n; @@ -316,9 +317,22 @@ status_replace(struct session *s, char *fmt, time_t t) if (n <= 0) n = LONG_MAX; + ptr = NULL; switch (*iptr++) { + case 'H': + if (ptr == NULL) { + if (gethostname(tmp, sizeof tmp) != 0) + fatal("gethostname"); + ptr = tmp; + } + /* FALLTHROUGH */ + case 'S': + if (ptr == NULL) + ptr = s->name; + /* FALLTHROUGH */ case 'T': - ptr = wl->window->active->base.title; + if (ptr == NULL) + ptr = wl->window->active->base.title; len = strlen(ptr); if ((size_t) n < len) len = n; -- cgit