Skip to content

Commit

Permalink
Add keybinding for deleting session
Browse files Browse the repository at this point in the history
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`).
  • Loading branch information
whame committed Oct 4, 2022
1 parent e5f63d0 commit 406618e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions keybindings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions tmux-modal.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 406618e

Please sign in to comment.