9

Is it possible to create a shortcut in Tmux which would kill current session? Typing "kill-session -t mysession" is not very convenient

I imagine something like

bind X kill-session -t $currentsesion

what I do not understand how to let bind know which session is current.

2 Answers 2

18

After playing around I found that I can make following shorcut which behaves the way I want:

  • Kills current session
  • Leaves all other sessions intact

bind X confirm-before "kill-session -t ''"

This solution seems to work but also looks like a hack. I hope there is a better way to do this.

EDIT

As pointed out in the comments, omitting the -t parameter will cause tmux to automatically use the current session so the code could also be shortened to:

bind X confirm-before kill-session

1
  • 5
    The empty string is certainly a valid way of spelling “the current session” as a target-session, but you can also just leave out the -t (and its argument): “the current session” is the default target-session if -t is not supplied. So just this should work: bind X confirm-before kill-session May 25, 2015 at 2:42
1

You can define shortcuts for tmux by editing ~/.tmux.conf, and supplying a suitable bind-key line. The manual page shows some examples.

For additional reading:

1
  • I understand how to create shortcuts, but I do not know how to refer to the current session
    – dimus
    May 24, 2015 at 14:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .