summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2021-06-10 07:52:57 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2021-06-10 07:52:57 +0000
commit8d7600ec2cfd24dde9d5c201d004d31ccef0b45c (patch)
treefaf5eb7125df37cd70baa0d38310d36056299cf7 /usr.bin
parenta435d1624e2febb4e7e85e15718a5eb5ae1e6c69 (diff)
Add -F for command-prompt and use it to fix "Rename" on the window menu,
GitHub issue 2699.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-command-prompt.c12
-rw-r--r--usr.bin/tmux/key-bindings.c4
-rw-r--r--usr.bin/tmux/tmux.19
3 files changed, 16 insertions, 9 deletions
diff --git a/usr.bin/tmux/cmd-command-prompt.c b/usr.bin/tmux/cmd-command-prompt.c
index 73dcb74c077..cea9b9d981e 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.54 2021/06/10 07:50:03 nicm Exp $ */
+/* $OpenBSD: cmd-command-prompt.c,v 1.55 2021/06/10 07:52:56 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -40,8 +40,8 @@ const struct cmd_entry cmd_command_prompt_entry = {
.name = "command-prompt",
.alias = NULL,
- .args = { "1kiI:Np:t:T:", 0, 1 },
- .usage = "[-1kiN] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE
+ .args = { "1FkiI:Np:t:T:", 0, 1 },
+ .usage = "[-1FkiN] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE
" [-T type] [template]",
.flags = CMD_CLIENT_TFLAG,
@@ -59,7 +59,7 @@ struct cmd_command_prompt_cdata {
char *next_prompt;
char *template;
- int idx;
+ int idx;
};
static enum cmd_retval
@@ -87,7 +87,9 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
cdata->template = NULL;
cdata->idx = 1;
- if (args->argc != 0)
+ if (args->argc != 0 && args_has(args, 'F'))
+ cdata->template = format_single_from_target(item, args->argv[0]);
+ else if (args->argc != 0)
cdata->template = xstrdup(args->argv[0]);
else
cdata->template = xstrdup("%1");
diff --git a/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c
index d17058c3c1f..24e512b5604 100644
--- a/usr.bin/tmux/key-bindings.c
+++ b/usr.bin/tmux/key-bindings.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key-bindings.c,v 1.134 2021/06/10 07:50:03 nicm Exp $ */
+/* $OpenBSD: key-bindings.c,v 1.135 2021/06/10 07:52:56 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -41,7 +41,7 @@
" 'Kill' 'X' {kill-window}" \
" 'Respawn' 'R' {respawn-window -k}" \
" '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}" \
- " 'Rename' 'n' {command-prompt -I \"#W\" \"rename-window -- '%%'\"}" \
+ " 'Rename' 'n' {command-prompt -FI \"#W\" \"rename-window -t#{window_id} -- '%%'\"}" \
" ''" \
" 'New After' 'w' {new-window -a}" \
" 'New At End' 'W' {new-window}"
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index e566311914e..626ff832dde 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.839 2021/06/10 07:50:04 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.840 2021/06/10 07:52:56 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -5392,7 +5392,7 @@ See
for possible values for
.Ar prompt-type .
.It Xo Ic command-prompt
-.Op Fl 1ikN
+.Op Fl 1FikN
.Op Fl I Ar inputs
.Op Fl p Ar prompts
.Op Fl t Ar target-client
@@ -5407,6 +5407,11 @@ to execute commands interactively.
If
.Ar template
is specified, it is used as the command.
+With
+.Fl F ,
+.Ar template
+is expanded as a format.
+.Pp
If present,
.Fl I
is a comma-separated list of the initial text for each prompt.