mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 19:39:04 +00:00
Allow choose commands to be used outside tmux, so long as at least one client
is attached.
This commit is contained in:
parent
aadc87f5a7
commit
f1ce95915c
@ -51,11 +51,10 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
const char *template;
|
||||
u_int idx;
|
||||
|
||||
if (ctx->curclient == NULL) {
|
||||
ctx->error(ctx, "must be run interactively");
|
||||
if ((c = cmd_current_client(ctx)) == NULL) {
|
||||
ctx->error(ctx, "no client available");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
c = ctx->curclient;
|
||||
|
||||
if ((template = args_get(args, 'F')) == NULL)
|
||||
template = CHOOSE_BUFFER_TEMPLATE;
|
||||
|
@ -57,11 +57,10 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
char *action;
|
||||
u_int i, idx, cur;
|
||||
|
||||
if (ctx->curclient == NULL) {
|
||||
ctx->error(ctx, "must be run interactively");
|
||||
if ((c = cmd_current_client(ctx)) == NULL) {
|
||||
ctx->error(ctx, "no client available");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
c = ctx->curclient;
|
||||
|
||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
@ -47,13 +47,14 @@ enum cmd_retval
|
||||
cmd_choose_list_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c;
|
||||
struct winlink *wl;
|
||||
const char *list1;
|
||||
char *template, *item, *copy, *list;
|
||||
u_int idx;
|
||||
|
||||
if (ctx->curclient == NULL) {
|
||||
ctx->error(ctx, "must be run interactively");
|
||||
if ((c = cmd_current_client(ctx)) == NULL) {
|
||||
ctx->error(ctx, "no client available");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
@ -77,7 +78,7 @@ cmd_choose_list_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
{
|
||||
if (*item == '\0') /* no empty entries */
|
||||
continue;
|
||||
window_choose_add_item(wl->window->active, ctx, wl, item,
|
||||
window_choose_add_item(wl->window->active, c, wl, item,
|
||||
template, idx);
|
||||
idx++;
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
struct args *args = self->args;
|
||||
struct winlink *wl, *wm;
|
||||
struct session *s, *s2;
|
||||
struct client *c;
|
||||
struct window_choose_data *wcd = NULL;
|
||||
const char *ses_template, *win_template;
|
||||
char *final_win_action, *cur_win_template;
|
||||
@ -83,12 +84,13 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
ses_template = win_template = NULL;
|
||||
ses_action = win_action = NULL;
|
||||
|
||||
if (ctx->curclient == NULL) {
|
||||
ctx->error(ctx, "must be run interactively");
|
||||
if ((c = cmd_current_client(ctx)) == NULL) {
|
||||
ctx->error(ctx, "no client available");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
s = ctx->curclient->session;
|
||||
if ((s = c->session) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
@ -172,7 +174,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
}
|
||||
|
||||
wcd = window_choose_add_session(wl->window->active,
|
||||
ctx, s2, ses_template, (char *)ses_action, idx_ses);
|
||||
c, s2, ses_template, (char *)ses_action, idx_ses);
|
||||
|
||||
/* If we're just choosing sessions, skip choosing windows. */
|
||||
if (sflag && !wflag) {
|
||||
@ -210,7 +212,7 @@ windows_only:
|
||||
cur_win_template = final_win_template_last;
|
||||
|
||||
window_choose_add_window(wl->window->active,
|
||||
ctx, s2, wm, cur_win_template,
|
||||
c, s2, wm, cur_win_template,
|
||||
final_win_action,
|
||||
(wflag && !sflag) ? win_ses : idx_ses);
|
||||
|
||||
|
@ -139,11 +139,10 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
const char *template;
|
||||
u_int i, match_flags;
|
||||
|
||||
if (ctx->curclient == NULL) {
|
||||
ctx->error(ctx, "must be run interactively");
|
||||
if ((c = cmd_current_client(ctx)) == NULL) {
|
||||
ctx->error(ctx, "no client available");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
c = ctx->curclient;
|
||||
s = c->session;
|
||||
|
||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||
|
21
tmux.1
21
tmux.1
@ -1078,8 +1078,7 @@ For the meaning of the
|
||||
flag, see the
|
||||
.Sx FORMATS
|
||||
section.
|
||||
This command works only from inside
|
||||
.Nm .
|
||||
This command works only if at least one client is attached.
|
||||
.It Xo
|
||||
.Ic choose-list
|
||||
.Op Fl l Ar items
|
||||
@ -1105,8 +1104,7 @@ also accepts format specifiers.
|
||||
For the meaning of this see the
|
||||
.Sx FORMATS
|
||||
section.
|
||||
This command works only from inside
|
||||
.Nm .
|
||||
This command works only if at least one client is attached.
|
||||
.It Xo
|
||||
.Ic choose-session
|
||||
.Op Fl F Ar format
|
||||
@ -1128,8 +1126,7 @@ For the meaning of the
|
||||
flag, see the
|
||||
.Sx FORMATS
|
||||
section.
|
||||
This command works only from inside
|
||||
.Nm .
|
||||
This command works only if at least one client is attached.
|
||||
.It Xo
|
||||
.Ic choose-tree
|
||||
.Op Fl s
|
||||
@ -1193,8 +1190,7 @@ and
|
||||
options, see the
|
||||
.Sx FORMATS
|
||||
section.
|
||||
This command only works from inside
|
||||
.Nm .
|
||||
This command works only if at least one client is attached.
|
||||
.It Xo
|
||||
.Ic choose-window
|
||||
.Op Fl F Ar format
|
||||
@ -1216,8 +1212,7 @@ For the meaning of the
|
||||
flag, see the
|
||||
.Sx FORMATS
|
||||
section.
|
||||
This command works only from inside
|
||||
.Nm .
|
||||
This command works only if at least one client is attached.
|
||||
.It Ic display-panes Op Fl t Ar target-client
|
||||
.D1 (alias: Ic displayp)
|
||||
Display a visible indicator of each pane shown by
|
||||
@ -1261,8 +1256,7 @@ For the meaning of the
|
||||
flag, see the
|
||||
.Sx FORMATS
|
||||
section.
|
||||
This command only works from inside
|
||||
.Nm .
|
||||
This command works only if at least one client is attached.
|
||||
.It Xo Ic join-pane
|
||||
.Op Fl bdhv
|
||||
.Oo Fl l
|
||||
@ -3310,8 +3304,7 @@ For the meaning of the
|
||||
flag, see the
|
||||
.Sx FORMATS
|
||||
section.
|
||||
This command works only from inside
|
||||
.Nm .
|
||||
This command works only if at least one client is attached.
|
||||
.It Ic clear-history Op Fl t Ar target-pane
|
||||
.D1 (alias: Ic clearhist )
|
||||
Remove and free the history for the specified pane.
|
||||
|
6
tmux.h
6
tmux.h
@ -2204,13 +2204,13 @@ struct window_choose_data *window_choose_data_create (int,
|
||||
void window_choose_data_free(struct window_choose_data *);
|
||||
void window_choose_data_run(struct window_choose_data *);
|
||||
struct window_choose_data *window_choose_add_window(struct window_pane *,
|
||||
struct cmd_ctx *, struct session *, struct winlink *,
|
||||
struct client *, struct session *, struct winlink *,
|
||||
const char *, char *, u_int);
|
||||
struct window_choose_data *window_choose_add_session(struct window_pane *,
|
||||
struct cmd_ctx *, struct session *, const char *,
|
||||
struct client *, struct session *, const char *,
|
||||
char *, u_int);
|
||||
struct window_choose_data *window_choose_add_item(struct window_pane *,
|
||||
struct cmd_ctx *, struct winlink *, const char *,
|
||||
struct client *, struct winlink *, const char *,
|
||||
char *, u_int);
|
||||
void window_choose_expand_all(struct window_pane *);
|
||||
|
||||
|
@ -863,11 +863,10 @@ window_choose_scroll_down(struct window_pane *wp)
|
||||
}
|
||||
|
||||
struct window_choose_data *
|
||||
window_choose_add_session(struct window_pane *wp, struct cmd_ctx *ctx,
|
||||
window_choose_add_session(struct window_pane *wp, struct client *c,
|
||||
struct session *s, const char *template, char *action, u_int idx)
|
||||
{
|
||||
struct window_choose_data *wcd;
|
||||
struct client *c = ctx->curclient;
|
||||
|
||||
wcd = window_choose_data_create(TREE_SESSION, c, c->session);
|
||||
wcd->idx = s->idx;
|
||||
@ -887,11 +886,10 @@ window_choose_add_session(struct window_pane *wp, struct cmd_ctx *ctx,
|
||||
}
|
||||
|
||||
struct window_choose_data *
|
||||
window_choose_add_item(struct window_pane *wp, struct cmd_ctx *ctx,
|
||||
window_choose_add_item(struct window_pane *wp, struct client *c,
|
||||
struct winlink *wl, const char *template, char *action, u_int idx)
|
||||
{
|
||||
struct window_choose_data *wcd;
|
||||
struct client *c = ctx->curclient;
|
||||
char *expanded;
|
||||
|
||||
wcd = window_choose_data_create(TREE_OTHER, c, c->session);
|
||||
@ -918,12 +916,11 @@ window_choose_add_item(struct window_pane *wp, struct cmd_ctx *ctx,
|
||||
}
|
||||
|
||||
struct window_choose_data *
|
||||
window_choose_add_window(struct window_pane *wp, struct cmd_ctx *ctx,
|
||||
window_choose_add_window(struct window_pane *wp, struct client *c,
|
||||
struct session *s, struct winlink *wl, const char *template,
|
||||
char *action, u_int idx)
|
||||
{
|
||||
struct window_choose_data *wcd;
|
||||
struct client *c = ctx->curclient;
|
||||
char *expanded;
|
||||
|
||||
wcd = window_choose_data_create(TREE_WINDOW, c, c->session);
|
||||
|
Loading…
Reference in New Issue
Block a user