TMUX is sysadmin's black magic.
If you ever had to remotely log into one fo your servers (or even your raspberryPi), you know how annoying it is when you want several terminals: either you open locally several terminals and log in each of them over SSH, or you simply surrender.
In the same context, I am sure you had to run a lengthy command on the remote machine, but could disconnect because that would kill the remote process nor change from one computer to another while sharing the remote session.
If you identify your self with this, then call 555-get-me-tmux and order now! (or better yet, continue reading)
# pacman -S tmux # for archlinux # apt-get install tmux # for ubuntu # pretty please install tmux # other distros :P
Breaking the ice
TMUX is intended to stand between you and any system you run it on. To open TMUX simply call it from within any terminal.
$ tmux
By default TMUX will pass all user input to the underlying terminal, but will recognize some special commands that allow it to unfold all its potential. BY default TMUX will wait for CTRL+b, once it detects it TMUX will interprete the next input keystroke as a command. This special combination is called the PREFIX.
For example, try CTRL+b and then write a colon (":"). TMUX will enter command mode and you will be able to write new commands. Now try writing split-window and press enter. Your window will divide in two.
Tiling windows
TMUX accepts a lot of commands, and you can even write your own scripts. But to make things more agile, the most important commands are bound to easily accessible keys:
- CTRL+b then " will divide your window horizontally
- CTRL+b then % will divide it vertically
- CTRL+b then "arrow keys" lets you navigate though the different panels.
- CTRL+b then ? will output other key combinations
You can also create multiple windows containing different panels.
- CTRL+b then c creates a new window
- CTRL+b then w navigates all windows (hit enter to select)
Multiple sessions
But my favorite aspect of TMUX is the possibility to detach from it and leave it running in the background, allowing me to reattach on a later moment from anywhere I want!
That means I can log into my server, create panels and windows, run heavy commands and completely disconnect. And it will continue running even if you close your SSH session. Then later, reconnect from a different computer and check how everything is going.
To detach from the current session hit CTRL+b and then d. You will be back to your original non-tiling and boring terminal.
If you want to reattach to that session, write the following command:
$ tmux attach-session
And there you go. You are back in! Note that you can even have different sessions and attach them independently or share them in real time among different users.
Once you have tried TMUX, tell me down in the comments if you liked it. Or feel free to ask any question, I will answer in no time.
What now? What about a better TMUX theme or mouse support?
No comments :
Post a Comment