aboutsummaryrefslogtreecommitdiff
path: root/cmd-choose-tree.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2013-02-10 17:52:51 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2013-02-10 17:52:51 +0000
commitf1ce95915c612ef3b429dc7d2f635b5758b27669 (patch)
tree4151a79b448c88fb48972a8466f7d19bfd1cbf28 /cmd-choose-tree.c
parentaadc87f5a79865f404f4b6cb0f4892daa17e7365 (diff)
downloadrtmux-f1ce95915c612ef3b429dc7d2f635b5758b27669.tar.gz
rtmux-f1ce95915c612ef3b429dc7d2f635b5758b27669.tar.bz2
rtmux-f1ce95915c612ef3b429dc7d2f635b5758b27669.zip
Allow choose commands to be used outside tmux, so long as at least one client
is attached.
Diffstat (limited to 'cmd-choose-tree.c')
-rw-r--r--cmd-choose-tree.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c
index 77eda5d7..d1f106e4 100644
--- a/cmd-choose-tree.c
+++ b/cmd-choose-tree.c
@@ -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);