diff options
author | 2013-03-24 09:21:27 +0000 | |
---|---|---|
committer | 2013-03-24 09:21:27 +0000 | |
commit | e159b2e939fcbaae2d502598f8658febcc5d452d (patch) | |
tree | 9522e94486c70655129523dbc4c0b7bbe29c3cf7 /usr.bin/tmux/names.c | |
parent | Add pane_current_command format. (diff) | |
download | wireguard-openbsd-e159b2e939fcbaae2d502598f8658febcc5d452d.tar.xz wireguard-openbsd-e159b2e939fcbaae2d502598f8658febcc5d452d.zip |
Add option command-prefix which is automatically prepended to any
command (apart from a naked default-shell). The default is "exec ".
Diffstat (limited to 'usr.bin/tmux/names.c')
-rw-r--r-- | usr.bin/tmux/names.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/usr.bin/tmux/names.c b/usr.bin/tmux/names.c index 4e11d6bf21e..53df39cb4d9 100644 --- a/usr.bin/tmux/names.c +++ b/usr.bin/tmux/names.c @@ -1,4 +1,4 @@ -/* $OpenBSD: names.c,v 1.19 2013/03/22 10:31:22 nicm Exp $ */ +/* $OpenBSD: names.c,v 1.20 2013/03/24 09:21:27 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -26,8 +26,8 @@ #include "tmux.h" -void window_name_callback(unused int, unused short, void *); -char *parse_window_name(const char *); +void window_name_callback(int, short, void *); +char *parse_window_name(struct window *, const char *); void queue_window_name(struct window *w) @@ -73,9 +73,9 @@ window_name_callback(unused int fd, unused short events, void *data) */ if (w->active->cmd != NULL && *w->active->cmd == '\0' && name != NULL && name[0] == '-' && name[1] != '\0') - wname = parse_window_name(name + 1); + wname = parse_window_name(w, name + 1); else - wname = parse_window_name(name); + wname = parse_window_name(w, name); free(name); } @@ -98,18 +98,22 @@ default_window_name(struct window *w) if (w->active->screen != &w->active->base) return (xstrdup("[tmux]")); if (w->active->cmd != NULL && *w->active->cmd != '\0') - return (parse_window_name(w->active->cmd)); - return (parse_window_name(w->active->shell)); + return (parse_window_name(w, w->active->cmd)); + return (parse_window_name(w, w->active->shell)); } char * -parse_window_name(const char *in) +parse_window_name(struct window *w, const char *in) { - char *copy, *name, *ptr; + char *copy, *name, *ptr, *prefix; + size_t prefixlen; + + prefix = options_get_string(&w->options, "command-prefix"); + prefixlen = strlen(prefix); name = copy = xstrdup(in); - if (strncmp(name, "exec ", (sizeof "exec ") - 1) == 0) - name = name + (sizeof "exec ") - 1; + if (strncmp(name, prefix, prefixlen) == 0) + name = name + prefixlen; while (*name == ' ') name++; |