25.10.13

tmux > screen

Never "exit" again.
Why TMUX? 

Even developers, in todays climate, have to deal with multiple deployment scenarios and environments.  Some of use more than others --- but in any case, every day, when I start work, I have to ssh into a VPN.  Then, i have to ssh into 2 or 3 servers to check on them.  I find myself creating new ssh terminals all day long and manually resizing them with my mouse.

And then when my ssh connection dies, i have to redo it all - and i lost my history :(

Rather than managing your terminals manually, its best to install tmux on a server thats always on.  At that point - you can simply ssh into the server and attach to your tmux session.  Since tmux multiplexes your terminal windows for you, you never have to worry about losing connectivity - if you do - all your work is still in place on your server , and to get back to it, you just ssh in and run tmux attach.

Why another post on TMUX?

Sometimes the simplest way to get started is to follow a recipe that gets you started... So do this, and even if your ssh connection dies, you will never again have to worry about losing your terminal histories and neatly organized layouts.

The image in this post is an image of what you should end up with : 3 windows, all on a server , that you can switch back and forth between using [ctrl - b] + arrow keys.

Do this:

First install it:
   
    #Do something like this
    su -c 'rpm -Uvh http://mirror.steadfast.net/epel/6/x86_64/epel-release-6-8.noarch.rpm'
    yum install tmux
Now that its installed, create a new named session, and detach from it:
   
   tmux new -s mysession
   [ctrl + b] + d 
   tmux attach -t mysession
FYI, a great summary is here of commands to customize your layout : http://lukaszwrobel.pl/blog/tmux-tutorial-split-terminal-windows-easily . C+P Here for convenience:
 -   Ctrl+b " - split pane horizontally.
 -   Ctrl+b % - split pane vertically.
 -   Ctrl+b arrow key - switch pane.
 -   Hold Ctrl+b, don't release it and hold one of the arrow keys - resize pane.
 -   Ctrl+b c - (c)reate a new window.
 -   Ctrl+b n - move to the (n)ext window.
 -   Ctrl+b p - move to the (p)revious window.
 
So lets create some tabs now.
   
[ctrl + b] + % #this creates a tab on the right side for you
[ctrl + b] ->  #this switches you into the right tab
[ctrl + b] "   #this further splits the right tab into another vertical terminal 
And thats it !

Oh and dont forget this awesome trick that rearranges all your windows for you (hit it multiple times - and each time you get a different configuration).

[ctrl + b] <SPACE> #rearrange windows.  keep spacing till you get the desired arrangement.

No comments:

Post a Comment