summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-command-prompt.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2011-05-20 19:29:13 +0000
committernicm <nicm@openbsd.org>2011-05-20 19:29:13 +0000
commite71ec0f652f623faf2980a37ca1f458dc7c7c983 (patch)
tree58c199ab8c7f21140e8e122f513c0d23ab1dea1f /usr.bin/tmux/cmd-command-prompt.c
parentRemove a silly XXX for a bit of code that is only used once - no value (diff)
downloadwireguard-openbsd-e71ec0f652f623faf2980a37ca1f458dc7c7c983.tar.xz
wireguard-openbsd-e71ec0f652f623faf2980a37ca1f458dc7c7c983.zip
Pass prompts through status_replace so that they can be more helpful
(such as showing the previous session name when renaming). From Tiago Cunha.
Diffstat (limited to 'usr.bin/tmux/cmd-command-prompt.c')
-rw-r--r--usr.bin/tmux/cmd-command-prompt.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/usr.bin/tmux/cmd-command-prompt.c b/usr.bin/tmux/cmd-command-prompt.c
index 480afdccdeb..3b5f0f793f8 100644
--- a/usr.bin/tmux/cmd-command-prompt.c
+++ b/usr.bin/tmux/cmd-command-prompt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-command-prompt.c,v 1.15 2011/01/05 22:38:28 nicm Exp $ */
+/* $OpenBSD: cmd-command-prompt.c,v 1.16 2011/05/20 19:29:13 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -82,7 +82,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
const char *prompts;
struct cmd_command_prompt_cdata *cdata;
struct client *c;
- char *prompt, *ptr;
+ char *prompt, *prompt_replaced, *ptr;
size_t n;
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
@@ -116,8 +116,12 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
ptr = strsep(&cdata->next_prompt, ",");
if (prompts == NULL)
prompt = xstrdup(ptr);
- else
- xasprintf(&prompt, "%s ", ptr);
+ else {
+ prompt_replaced = status_replace(c, NULL, NULL, NULL, ptr,
+ time(NULL), 0);
+ xasprintf(&prompt, "%s ", prompt_replaced);
+ xfree(prompt_replaced);
+ }
status_prompt_set(c, prompt, cmd_command_prompt_callback,
cmd_command_prompt_free, cdata, 0);
xfree(prompt);
@@ -133,6 +137,7 @@ cmd_command_prompt_callback(void *data, const char *s)
struct cmd_list *cmdlist;
struct cmd_ctx ctx;
char *cause, *newtempl, *prompt, *ptr;
+ char *prompt_replaced;
if (s == NULL)
return (0);
@@ -142,8 +147,12 @@ cmd_command_prompt_callback(void *data, const char *s)
cdata->template = newtempl;
if ((ptr = strsep(&cdata->next_prompt, ",")) != NULL) {
- xasprintf(&prompt, "%s ", ptr);
+ prompt_replaced = status_replace(c, NULL, NULL, NULL, ptr,
+ time(NULL), 0);
+ xasprintf(&prompt, "%s ", prompt_replaced);
status_prompt_update(c, prompt);
+
+ xfree(prompt_replaced);
xfree(prompt);
cdata->idx++;
return (1);