ankitj
ankitj

Reputation: 473

Is there a tmux shortcut to create a new session?

Just like leader_key + C creates a new window inside a session. Is there a similar shortcut for creating a new session ? Currently, I use leader_key + new

Upvotes: 15

Views: 19876

Answers (4)

Thilak Reddy
Thilak Reddy

Reputation: 1

You can create this keybinding in the .tmux.config:

bind-key L command-prompt -p "Enter session name:" "new-session -s '%%'"
bind-key C command-prompt -p "Enter window name:" "new-window -n '%%'"

Upvotes: 0

m4110c
m4110c

Reputation: 587

Why not just create a keybinding for that in your .tmux.conf?

These two settings let you create/kill a new session when pressing Prefix S (Shift+s) or Prefix K (Shift+k) respectively:

bind S command-prompt -p "New Session:" "new-session -A -s '%%'"
bind K confirm kill-session

Prefix Shift+s will open a command prompt in the status line, asking for a new session name. It will either create a new session with that name or attach to an already existing session by that name.

Upvotes: 20

Pylinux
Pylinux

Reputation: 11816

From inside tmux you can just do

  1. ctrl+B
  2. then write :new<enter>

Upvotes: 12

Olivier Cartier
Olivier Cartier

Reputation: 226

There are no predefined shortcuts, the only native way to do it is :

  • Create session: tmux new -s session_name

  • Ctrl-B + d to detach

  • Return to your session: tmux attach-session -t session_name

Upvotes: 15

Related Questions