aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-05-20 19:29:13 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-05-20 19:29:13 +0000
commit1af2021de6b004c932832061c2c0a03581a52af4 (patch)
tree4f3257833e4b54c8b19d6321cb5e0d7a274c244d
parent3ea5e06bfb04278fa53885e551bc363a84bad8d1 (diff)
downloadrtmux-1af2021de6b004c932832061c2c0a03581a52af4.tar.gz
rtmux-1af2021de6b004c932832061c2c0a03581a52af4.tar.bz2
rtmux-1af2021de6b004c932832061c2c0a03581a52af4.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.
-rw-r--r--cmd-command-prompt.c17
-rw-r--r--tmux.19
2 files changed, 21 insertions, 5 deletions
diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c
index 0bb4e209..52ee747f 100644
--- a/cmd-command-prompt.c
+++ b/cmd-command-prompt.c
@@ -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);
diff --git a/tmux.1 b/tmux.1
index 1e3c57b2..87949d34 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1255,7 +1255,7 @@ The
.Ar shell-command
string may contain the special character sequences supported by the
.Ic status-left
-command.
+option.
If no
.Ar shell-command
is given, the current pipe (if any) is closed.
@@ -2624,6 +2624,7 @@ Open the command prompt in a client.
This may be used from inside
.Nm
to execute commands interactively.
+.Pp
If
.Ar template
is specified, it is used as the command.
@@ -2637,6 +2638,12 @@ a single prompt is displayed, constructed from
if it is present, or
.Ql \&:
if not.
+The
+.Ar prompts
+may contain the special character sequences supported by the
+.Ic status-left
+option.
+.Pp
Before the command is executed, the first occurrence of the string
.Ql %%
and all occurrences of