summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-04-24 21:32:07 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-04-24 21:32:07 +0000
commiteb288aae3223576ebe3f68f5faaa1c4fd02cb73b (patch)
tree44150e3eecb037e1fa5e6c248b4616f67c8d341a
parentdc8fb9fb23f22ef4f2aedaee55d6e008b0089be3 (diff)
Provide #h for short hostname (no domain) from Michal Mazurek.
-rw-r--r--status.c7
-rw-r--r--tmux.11
2 files changed, 8 insertions, 0 deletions
diff --git a/status.c b/status.c
index ecf19b25..3e5c69ce 100644
--- a/status.c
+++ b/status.c
@@ -410,6 +410,13 @@ status_replace1(struct client *c, struct session *s, struct winlink *wl,
fatal("gethostname failed");
ptr = tmp;
goto do_replace;
+ case 'h':
+ if (gethostname(tmp, sizeof tmp) != 0)
+ fatal("gethostname failed");
+ if ((ptr = strchr(tmp, '.')) != NULL)
+ *ptr = '\0';
+ ptr = tmp;
+ goto do_replace;
case 'I':
xsnprintf(tmp, sizeof tmp, "%d", wl->idx);
ptr = tmp;
diff --git a/tmux.1 b/tmux.1
index af6b78e2..45db380a 100644
--- a/tmux.1
+++ b/tmux.1
@@ -2005,6 +2005,7 @@ may contain any of the following special character sequences:
.It Li "#(shell-command)" Ta "First line of the command's output"
.It Li "#[attributes]" Ta "Colour or attribute change"
.It Li "#H" Ta "Hostname of local host"
+.It Li "#h" Ta "Hostname of local host without the domain name"
.It Li "#F" Ta "Current window flag"
.It Li "#I" Ta "Current window index"
.It Li "#P" Ta "Current pane index"