Try this please:

Index: cmd-kill-pane.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/cmd-kill-pane.c,v
retrieving revision 1.25
diff -u -p -r1.25 cmd-kill-pane.c
--- cmd-kill-pane.c     22 Apr 2017 10:22:39 -0000      1.25
+++ cmd-kill-pane.c     6 Apr 2018 09:48:30 -0000
@@ -47,9 +47,8 @@ cmd_kill_pane_exec(struct cmd *self, str
        struct winlink          *wl = item->target.wl;
        struct window_pane      *loopwp, *tmpwp, *wp = item->target.wp;
 
-       server_unzoom_window(wl->window);
-
        if (args_has(self->args, 'a')) {
+               server_unzoom_window(wl->window);
                TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) {
                        if (loopwp == wp)
                                continue;
@@ -60,13 +59,6 @@ cmd_kill_pane_exec(struct cmd *self, str
                return (CMD_RETURN_NORMAL);
        }
 
-       if (window_count_panes(wl->window) == 1) {
-               server_kill_window(wl->window);
-               recalculate_sizes();
-       } else {
-               layout_close_pane(wp);
-               window_remove_pane(wl->window, wp);
-               server_redraw_window(wl->window);
-       }
+       server_kill_pane(wp);
        return (CMD_RETURN_NORMAL);
 }
Index: server-fn.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/server-fn.c,v
retrieving revision 1.113
diff -u -p -r1.113 server-fn.c
--- server-fn.c 28 Feb 2018 08:55:44 -0000      1.113
+++ server-fn.c 6 Apr 2018 09:48:30 -0000
@@ -178,6 +178,22 @@ server_lock_client(struct client *c)
 }
 
 void
+server_kill_pane(struct window_pane *wp)
+{
+       struct window   *w = wp->window;
+
+       if (window_count_panes(w) == 1) {
+               server_kill_window(w);
+               recalculate_sizes();
+       } else {
+               server_unzoom_window(w);
+               layout_close_pane(wp);
+               window_remove_pane(w, wp);
+               server_redraw_window(w);
+       }
+}
+
+void
 server_kill_window(struct window *w)
 {
        struct session          *s, *next_s, *target_s;
Index: tmux.h
===================================================================
RCS file: /cvs/src/usr.bin/tmux/tmux.h,v
retrieving revision 1.822
diff -u -p -r1.822 tmux.h
--- tmux.h      16 Mar 2018 15:15:39 -0000      1.822
+++ tmux.h      6 Apr 2018 09:48:30 -0000
@@ -1920,6 +1920,7 @@ void       server_status_window(struct window
 void    server_lock(void);
 void    server_lock_session(struct session *);
 void    server_lock_client(struct client *);
+void    server_kill_pane(struct window_pane *);
 void    server_kill_window(struct window *);
 int     server_link_window(struct session *,
             struct winlink *, struct session *, int, int, int, char **);
Index: window-tree.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/window-tree.c,v
retrieving revision 1.29
diff -u -p -r1.29 window-tree.c
--- window-tree.c       29 Mar 2018 08:03:51 -0000      1.29
+++ window-tree.c       6 Apr 2018 09:48:30 -0000
@@ -18,6 +18,7 @@
 
 #include <sys/types.h>
 
+#include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -860,8 +861,6 @@ window_tree_destroy(struct window_tree_m
        if (--data->references != 0)
                return;
 
-       mode_tree_free(data->data);
-
        for (i = 0; i < data->item_size; i++)
                window_tree_free_item(data->item_list[i]);
        free(data->item_list);
@@ -881,6 +880,7 @@ window_tree_free(struct window_pane *wp)
                return;
 
        data->dead = 1;
+       mode_tree_free(data->data);
        window_tree_destroy(data);
 }
 
@@ -965,7 +965,7 @@ window_tree_command_callback(struct clie
 {
        struct window_tree_modedata     *data = modedata;
 
-       if (s == NULL || data->dead)
+       if (s == NULL || *s == '\0' || data->dead)
                return (0);
 
        data->entered = s;
@@ -987,6 +987,62 @@ window_tree_command_free(void *modedata)
        window_tree_destroy(data);
 }
 
+static void
+window_tree_kill_each(__unused void* modedata, void* itemdata,
+    __unused struct client *c, __unused key_code key)
+{
+       struct window_tree_itemdata     *item = itemdata;
+       struct session                  *s;
+       struct winlink                  *wl;
+       struct window_pane              *wp;
+
+       window_tree_pull_item(item, &s, &wl, &wp);
+
+       switch (item->type) {
+       case WINDOW_TREE_NONE:
+               break;
+       case WINDOW_TREE_SESSION:
+               if (s != NULL) {
+                       server_destroy_session(s);
+                       session_destroy(s, __func__);
+               }
+               break;
+       case WINDOW_TREE_WINDOW:
+               if (wl != NULL)
+                       server_kill_window(wl->window);
+               break;
+       case WINDOW_TREE_PANE:
+               if (wp != NULL)
+                       server_kill_pane(wp);
+               break;
+       }
+}
+
+static int
+window_tree_kill_callback(struct client *c, void *modedata, const char *s,
+    __unused int done)
+{
+       struct window_tree_modedata     *data = modedata;
+
+       if (s == NULL || *s == '\0' || data->dead)
+               return (0);
+       if (tolower((u_char) s[0]) != 'y' || s[1] != '\0')
+               return (0);
+
+       if (mode_tree_count_tagged(data->data) != 0) {
+               mode_tree_each_tagged(data->data, window_tree_kill_each, c,
+                   KEYC_NONE, 1);
+       } else {
+               window_tree_kill_each(modedata,
+                   mode_tree_get_current(data->data), c, KEYC_NONE);
+       }
+
+       data->references++;
+       cmdq_append(c, cmdq_get_callback(window_tree_command_done, data));
+
+       return (0);
+}
+
 static key_code
 window_tree_mouse(struct window_tree_modedata *data, key_code key, u_int x,
     struct window_tree_itemdata *item)
@@ -1054,10 +1110,13 @@ window_tree_key(struct window_pane *wp, 
 {
        struct window_tree_modedata     *data = wp->modedata;
        struct window_tree_itemdata     *item, *new_item;
-       char                            *name, *prompt;
+       char                            *name, *prompt = NULL;
        struct cmd_find_state            fs;
        int                              finished;
-       u_int                            tagged, x, y;
+       u_int                            tagged, x, y, idx;
+       struct session                  *ns;
+       struct winlink                  *nwl;
+       struct window_pane              *nwp;
 
        item = mode_tree_get_current(data->data);
        finished = mode_tree_key(data->data, c, &key, m, &x, &y);
@@ -1073,6 +1132,43 @@ window_tree_key(struct window_pane *wp, 
                break;
        case '>':
                data->offset++;
+               break;
+       case 'x':
+               tagged = mode_tree_count_tagged(data->data);
+               if (tagged != 0)
+                       xasprintf(&prompt, "Kill %u tagged? ", tagged);
+               else {
+                       window_tree_pull_item(item, &ns, &nwl, &nwp);
+                       switch (item->type) {
+                       case WINDOW_TREE_NONE:
+                               break;
+                       case WINDOW_TREE_SESSION:
+                               if (ns != NULL) {
+                                       xasprintf(&prompt, "Kill session %s? ",
+                                           ns->name);
+                               }
+                               break;
+                       case WINDOW_TREE_WINDOW:
+                               if (nwl != NULL) {
+                                       xasprintf(&prompt, "Kill window %u? ",
+                                           nwl->idx);
+                               }
+                               break;
+                       case WINDOW_TREE_PANE:
+                               if (nwp != NULL &&
+                                   window_pane_index(nwp, &idx) == 0) {
+                                       xasprintf(&prompt, "Kill pane %u? ",
+                                           idx);
+                               }
+                       }
+               }
+               if (prompt == NULL)
+                       break;
+               data->references++;
+               status_prompt_set(c, prompt, "", window_tree_kill_callback,
+                   window_tree_command_free, data,
+                   PROMPT_SINGLE|PROMPT_NOFORMAT);
+               free(prompt);
                break;
        case ':':
                tagged = mode_tree_count_tagged(data->data);


On Thu, Apr 05, 2018 at 03:03:48PM -0500, Matt Zagrabelny wrote:
>    On Thu, Apr 5, 2018 at 10:13 AM, Nicholas Marriott
>    <nicholas.marri...@gmail.com> wrote:
> 
>      No we have moved away from configurable key bindings in choose mode.
> 
>    Bummer.
>    A 
> 
>      I don't mind having a key but it would need a confirmation prompt.
> 
>    How about Ctrl+X for a key? Typing two keys is less likely to result in an
>    accidental kill of a session.
>    -m

-- 
You received this message because you are subscribed to the Google Groups 
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tmux-users+unsubscr...@googlegroups.com.
To post to this group, send an email to tmux-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to