From 406618e4e2b14b36427858b87d5446b8805d54c9 Mon Sep 17 00:00:00 2001 From: Waqar Hameed Date: Tue, 4 Oct 2022 23:23:36 +0200 Subject: [PATCH] Add keybinding for deleting session The keybinding `s D` matches `w D`. Moreover, this is considered a "dangerous" command and will therefore ask for confirmation if yes/no prompt is configured (option `@modal-yesno-cmd`). --- README.md | 13 +++++++------ keybindings.conf | 3 +++ tmux-modal.tmux | 6 ++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4bf4d18..7f192d0 100644 --- a/README.md +++ b/README.md @@ -172,12 +172,13 @@ usual, `q` exits the sticky command). ### Session -| Keybinding | Description | tmux Command | -|------------|--------------------------------------------------------------|--------------------| -| `s d` | Detach session. | `detach-client` | -| `s h` | Select previous session. This is an alias for `g s h`. | `switch-client -p` | -| `s l` | Select next session. This is an alias for `g s l`. | `switch-client -n` | -| `s t` | Select session with tree view. This is an alias for `g s t`. | `choose-tree -Zs` | +| Keybinding | Description | tmux Command | +|------------|--------------------------------------------------------------|-----------------------------------------------------------------| +| `s d` | Detach session. | `detach-client` | +| `s h` | Select previous session. This is an alias for `g s h`. | `switch-client -p` | +| `s l` | Select next session. This is an alias for `g s l`. | `switch-client -n` | +| `s t` | Select session with tree view. This is an alias for `g s t`. | `choose-tree -Zs` | +| `s D` | Delete session. | `kill-session` (see option [`@modal-yesno-cmd`](#yesno-prompt)) | ### Go to diff --git a/keybindings.conf b/keybindings.conf index b90ccfc..6ba1d6c 100644 --- a/keybindings.conf +++ b/keybindings.conf @@ -210,6 +210,9 @@ KBD_SESS_NEXT=l ## KBD_GOTO_SESS_TREE). KBD_SESS_TREE=t +## Delete session. +KBD_SESS_DEL=D + # "Go to" command prefix. KBD_GOTO=g diff --git a/tmux-modal.tmux b/tmux-modal.tmux index 145b5f4..6f2d9a2 100755 --- a/tmux-modal.tmux +++ b/tmux-modal.tmux @@ -262,6 +262,9 @@ KBD_SESS_NEXT=l ## KBD_GOTO_SESS_TREE). KBD_SESS_TREE=t +## Delete session. +KBD_SESS_DEL=D + # "Go to" command prefix. KBD_GOTO=g @@ -367,9 +370,11 @@ fi if [ $YESNO_OPT_VAL == off ]; then KILL_PANE=kill-pane KILL_WINDOW=kill-window + KILL_SESSION=kill-session else KILL_PANE='confirm-before -p "kill-pane #P? (y/n)" kill-pane' KILL_WINDOW='confirm-before -p "kill-window #W? (y/n)" kill-window' + KILL_SESSION='confirm-before -p "kill-session #S? (y/n)" kill-session' fi # Start with modal command keytable. @@ -544,6 +549,7 @@ bind-key -T $KT_SESS $KBD_SESS_DETACH detach-client bind-key -T $KT_SESS $KBD_SESS_PREV switch-client -p bind-key -T $KT_SESS $KBD_SESS_NEXT switch-client -n bind-key -T $KT_SESS $KBD_SESS_TREE choose-tree -Zs +bind-key -T $KT_SESS $KBD_SESS_DEL $KILL_SESSION EOF # goto.