diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-01-15 23:42:21 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-01-15 23:42:21 +0000 |
commit | 5aa3098bb6c25e954cacc168a599d78447b4d005 (patch) | |
tree | 94e2c800f20ea5cf0a829622abf22580466b5634 /status.c | |
parent | 3f20549f66f3041d2fe5f0f7ad458e85a1f80a8c (diff) | |
download | rtmux-5aa3098bb6c25e954cacc168a599d78447b4d005.tar.gz rtmux-5aa3098bb6c25e954cacc168a599d78447b4d005.tar.bz2 rtmux-5aa3098bb6c25e954cacc168a599d78447b4d005.zip |
Support #S #H in status-left/right.
Diffstat (limited to 'status.c')
-rw-r--r-- | status.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -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 <nicm@users.sourceforge.net> @@ -25,6 +25,7 @@ #include <stdlib.h> #include <string.h> #include <time.h> +#include <unistd.h> #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; |