DEV Community

Ryan Collins
Ryan Collins

Posted on • Originally published at gozgeek.com on

๐Ÿ–ฅ Session aliases with tmux

I use tmux as my screen multiplexer, and in the past, I used control-A d to disconnect and tmux a -d to reattach to the session. This gets cumbersome if I havenโ€™t created a tmux session yet, since tmux a -d will give me an error that no session exists.

Aliases to the rescue

To help start sessions, and now name them, I use the following alias:

alias tma="tmux new -ADs"
Enter fullscreen mode Exit fullscreen mode

To create a session named main or re-attach to a disconnected session, I can now type tma main. The alias will create a session named main if one doesnโ€™t exist, or reconnect to the session named main. This also makes it easy to create named tmux sessions without having to remember the syntax.

Oldest comments (0)