Thanks for committing the previous patch. Here is a patch that adds a -F
format arg to new-window that can be used in conjunction with -P. Note that
it doesn't support any of the window pane format strings because it doesn't
seem to make sense in this context.
Index: cmd-new-window.c
===================================================================
--- cmd-new-window.c (revision 2710)
+++ cmd-new-window.c (working copy)
@@ -30,9 +30,9 @@
const struct cmd_entry cmd_new_window_entry = {
"new-window", "neww",
- "ac:dkn:Pt:", 0, 1,
- "[-adk] [-c start-directory] [-n window-name] [-t target-window] "
- "[command]",
+ "ac:dkn:Pt:F:", 0, 1,
+ "[-adkP] [-c start-directory] [-n window-name] [-t target-window] "
+ "[-F format] [command]",
0,
NULL,
NULL,
@@ -42,12 +42,15 @@
int
cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
{
- struct args *args = self->args;
- struct session *s;
- struct winlink *wl;
- const char *cmd, *cwd;
- char *cause;
- int idx, last, detached;
+ struct args *args = self->args;
+ struct session *s;
+ struct winlink *wl;
+ struct client *c;
+ const char *cmd, *cwd;
+ const char *template;
+ char *cause;
+ int idx, last, detached;
+ struct format_tree *ft;
if (args_has(args, 'a')) {
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
@@ -116,7 +119,19 @@
} else
server_status_session_group(s);
- if (args_has(args, 'P'))
- ctx->print(ctx, "%s:%u", s->name, wl->idx);
+ if (args_has(args, 'P')) {
+ if (args_has(args, 'F'))
+ template = args_get(args, 'F');
+ else
+ template = "#{session_name}:#{window_index}";
+ c = cmd_find_client(ctx, NULL);
+ ft = format_create();
+ if (c != NULL)
+ format_client(ft, c);
+ format_session(ft, s);
+ format_winlink(ft, s, wl);
+ ctx->print(ctx, "%s", format_expand(ft, template));
+ }
+
return (0);
}
Index: tmux.1
===================================================================
--- tmux.1 (revision 2710)
+++ tmux.1 (working copy)
@@ -1253,6 +1253,7 @@
.Op Fl c Ar start-directory
.Op Fl n Ar window-name
.Op Fl t Ar target-window
+.Op Fl F Ar format
.Op Ar shell-command
.Xc
.D1 (alias: Ic neww )
@@ -1310,7 +1311,14 @@
.Pp
The
.Fl P
-option prints the location of the new window after it has been created.
+option prints information about the new window after it has been created.
+By default, it uses the format
+.Ql #{session_name}:#{window_index} ,
+but a different format may be specified with the
+.Fl F
+flag with a
+.Ar format
+argument.
.It Ic next-layout Op Fl t Ar target-window
.D1 (alias: Ic nextl )
Move a window to the next layout and rearrange the panes to fit.
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users