mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Add -F format to new-window and split-window to use with the -P flag,
from George Nachman.
This commit is contained in:
parent
178a20718c
commit
03dca66ae2
@ -30,9 +30,9 @@ int cmd_new_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_new_window_entry = {
|
const struct cmd_entry cmd_new_window_entry = {
|
||||||
"new-window", "neww",
|
"new-window", "neww",
|
||||||
"ac:dkn:Pt:", 0, 1,
|
"ac:dF:kn:Pt:", 0, 1,
|
||||||
"[-adk] [-c start-directory] [-n window-name] [-t target-window] "
|
"[-adkP] [-c start-directory] [-F format] [-n window-name] "
|
||||||
"[command]",
|
"[-t target-window] [command]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@ -42,12 +42,16 @@ const struct cmd_entry cmd_new_window_entry = {
|
|||||||
int
|
int
|
||||||
cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
const char *cmd, *cwd;
|
struct client *c;
|
||||||
char *cause;
|
const char *cmd, *cwd;
|
||||||
int idx, last, detached;
|
const char *template;
|
||||||
|
char *cause;
|
||||||
|
int idx, last, detached;
|
||||||
|
struct format_tree *ft;
|
||||||
|
char *cp;
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
||||||
@ -116,7 +120,23 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
} else
|
} else
|
||||||
server_status_session_group(s);
|
server_status_session_group(s);
|
||||||
|
|
||||||
if (args_has(args, 'P'))
|
if (args_has(args, 'P')) {
|
||||||
ctx->print(ctx, "%s:%u", s->name, wl->idx);
|
template = "#{session_name}:#{window_index}";
|
||||||
|
if (args_has(args, 'F'))
|
||||||
|
template = args_get(args, 'F');
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
if ((c = cmd_find_client(ctx, NULL)) != NULL)
|
||||||
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
|
||||||
|
cp = format_expand(ft, template);
|
||||||
|
ctx->print(ctx, "%s", cp);
|
||||||
|
free(cp);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,9 @@ int cmd_split_window_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_split_window_entry = {
|
const struct cmd_entry cmd_split_window_entry = {
|
||||||
"split-window", "splitw",
|
"split-window", "splitw",
|
||||||
"c:dl:hp:Pt:v", 0, 1,
|
"c:dF:l:hp:Pt:v", 0, 1,
|
||||||
"[-dhvP] [-c start-directory] [-p percentage|-l size] [-t target-pane] "
|
"[-dhvP] [-c start-directory] [-F format] [-p percentage|-l size] "
|
||||||
"[command]",
|
"[-t target-pane] [command]",
|
||||||
0,
|
0,
|
||||||
cmd_split_window_key_binding,
|
cmd_split_window_key_binding,
|
||||||
NULL,
|
NULL,
|
||||||
@ -59,12 +59,16 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct window *w;
|
struct window *w;
|
||||||
struct window_pane *wp, *new_wp = NULL;
|
struct window_pane *wp, *new_wp = NULL;
|
||||||
struct environ env;
|
struct environ env;
|
||||||
const char *cmd, *cwd, *shell;
|
const char *cmd, *cwd, *shell;
|
||||||
char *cause, *new_cause;
|
char *cause, *new_cause;
|
||||||
u_int hlimit, paneidx;
|
u_int hlimit;
|
||||||
int size, percentage;
|
int size, percentage;
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
struct layout_cell *lc;
|
struct layout_cell *lc;
|
||||||
|
const char *template;
|
||||||
|
struct client *c;
|
||||||
|
struct format_tree *ft;
|
||||||
|
char *cp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -135,9 +139,22 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
|
|
||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if (window_pane_index(new_wp, &paneidx) != 0)
|
template = "#{session_name}:#{window_index}.#{pane_index}";
|
||||||
fatalx("index not found");
|
if (args_has(args, 'F'))
|
||||||
ctx->print(ctx, "%s:%u.%u", s->name, wl->idx, paneidx);
|
template = args_get(args, 'F');
|
||||||
|
|
||||||
|
ft = format_create();
|
||||||
|
if ((c = cmd_find_client(ctx, NULL)) != NULL)
|
||||||
|
format_client(ft, c);
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, new_wp);
|
||||||
|
|
||||||
|
cp = format_expand(ft, template);
|
||||||
|
ctx->print(ctx, "%s", cp);
|
||||||
|
free(cp);
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
8
tmux.1
8
tmux.1
@ -1249,6 +1249,7 @@ is moved to
|
|||||||
.Op Fl c Ar start-directory
|
.Op Fl c Ar start-directory
|
||||||
.Op Fl n Ar window-name
|
.Op Fl n Ar window-name
|
||||||
.Op Fl t Ar target-window
|
.Op Fl t Ar target-window
|
||||||
|
.Op Fl F Ar format
|
||||||
.Op Ar shell-command
|
.Op Ar shell-command
|
||||||
.Xc
|
.Xc
|
||||||
.D1 (alias: Ic neww )
|
.D1 (alias: Ic neww )
|
||||||
@ -1306,7 +1307,11 @@ start-up files.
|
|||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fl P
|
.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
|
||||||
|
.Fl F .
|
||||||
.It Ic next-layout Op Fl t Ar target-window
|
.It Ic next-layout Op Fl t Ar target-window
|
||||||
.D1 (alias: Ic nextl )
|
.D1 (alias: Ic nextl )
|
||||||
Move a window to the next layout and rearrange the panes to fit.
|
Move a window to the next layout and rearrange the panes to fit.
|
||||||
@ -1491,6 +1496,7 @@ commands.
|
|||||||
.Fl p Ar percentage Oc
|
.Fl p Ar percentage Oc
|
||||||
.Op Fl t Ar target-pane
|
.Op Fl t Ar target-pane
|
||||||
.Op Ar shell-command
|
.Op Ar shell-command
|
||||||
|
.Op Fl F Ar format
|
||||||
.Xc
|
.Xc
|
||||||
.D1 (alias: Ic splitw )
|
.D1 (alias: Ic splitw )
|
||||||
Create a new pane by splitting
|
Create a new pane by splitting
|
||||||
|
Loading…
Reference in New Issue
Block a user