Ceci est une ancienne révision du document !
CnC
As promised in the last issue, we move over to tmux. We can fall into the house with the door. Type: sudo apt install tmux - if you do not have it, and open a terminal and type: tmux. Unlike screen, we immediately see something has changed. We have an info bar at the bottom, with the session number, what’s in it, and machine name and the time.
Type: man tmux - This is another one of those man pages that use C-b for CTRL+b. Speaking of, as not to be confused with screen, that uses C-a as the control key. Because it is CTRL+b, I suggest you start using the control key on the right. (We *can change it, but for now I’m sticking with the defaults.) Check your version with tmux -V - if it is in the 3.xx range, we should be good. Older versions have their own quirks. Lets avoid 1.xx and 2.xx.
What I like about tmux is that help is at your fingertips. Please hit: CTRL+b then press ? - and you should be treated to boatloads of key combos. Quit out of that with q, and type ping 127.0.0.1 <enter>, and just like we did with screen, hit CTRL+b and then press the c key. Screen should be fresh in your mind, so try out “previous” and “next” like we did in the last issue. If you are relatively new to Ubuntu and Linux in general, and you were able to complete that instruction without grabbing the last issue, pat yourself on the back. You make me proud!
At the bottom in the information bar, you should see a star next to the “screen” you are in. You can see I’m in screen “2”.
Remember, the screens (windows) together are a session.
Speaking of screens or windows, renaming them uses a different key, type: CTRL+b then press , (comma). Also, unlike screen, you need to remove the current name before typing a new one. Rename one now. Cool! Switch between them with CTRL+b and then press the window number. See? Easier every time! Tmux also has a: CTRL+b then press l - I’ll leave you to figure that one out (and it’s not what you think!).
Where screen had CTRL+a and “ , tmux has CTRL+b and w to do the same thing, and the arrow keys work here too. Also unlike screen, you not only have an asterisk next to the current window, but you also have a “-” next to the last used window. CTRL+b and l again, if you did not figure it out before.
Like with Tilix, we can split windows into “panes” or just more “windows”, if you like; I’m not going to get pedantic here. Type: CTRL+b and press “ - to open a pane below your current one. If I want to go back to the pane above, where I was, I need to type: CTRL+b and then press o (oh, not zero), and repeat it to move down again. Did you notice anything? If not, look at the dividing line colors. This helps you know where you are if you have a lot of panes. CTRL+b and q should number your panes for you. Should you wish to branch out horizontally instead, it should open to the right, try: CTRL+b and press %, and to close a session, use CTRL+b and & (ampersand) to close it. Yeah, burn it all down!!
If you wish to DJ, then you need CRTL+b and CTRL+o (It should “rotate” clockwise).
If you have not been following along, please follow along now. You see, there is this “top” derivative named btop. It can be installed with: sudo apt install btop. Why do we need this? You see, btop cannot run in a window less than 80×24. I need you to open a new tmux session, split it vertically, and run btop in the bottom one. Now I want you to make the terminal smaller, to the point where btop cannot run.
To fix this, we need to use the resize pane. CTRL+b then ESC+up arrow.
Go ahead and see if you can fix the issue, now that you know how. (We will talk about this at the end, what I feel is broken with tmux).
Something like this:
Sweet, now you know. This is a silly one to remember, so I had you do it yourselves.
To rip that window out and chuck it against the wall, requires violence! You guessed it, CTRL+b and ! - and the window will stand on its own and the pane it was in, would have disappeared. Go ahead and try that now.
Tmux also has a privacy screen. If there is something you do not want others to see, simply press CTRL+b and t in that pane, and it should be covered, but beware, any key will dispel it. To close panes, we use: CTRL+b and x - but you need to confirm, just be aware of that, don’t just press enter.
Detaching from a session in tmux is: CTRL+b then d - or simply typing tmux detach. To see what other sessions there are, you type: tmux ls - If you are inside a tmux session, you can get a list of sessions with CTRL+b and s
***It is important to remember the difference here. If you type screen ls, you get an error and if you type tmux -ls you also get an error. Tmux does not use the “-” before the ls, but screen does, and the error messages you get are not helpful.
Attaching to a session requires only the session number, so the syntax is: tmux attach -t <session name/number>
I usually only have one, so I just type tmux attach (I really appreciate the alternatives of tmux attach/detach as opposed to the shortcut keys).
Speaking of connecting to session numbers, just like on screen, we can rename the session: CTRL+b and $ and you have to remove the “0” already there. Keep in mind that only the first 7 characters are displayed so typing in “Japan_jump_server_session” will display only as Japan_ (Honestly, the only time I have renamed sessions was during training, I prefer the short numbers as it is less typing).
You can also kill sessions by name: tmux kill-session -t <session name/number>
As of version 3.3 of tmux, what still irks me is that when I physically resize a terminal, it does it lopsided. You may have figured that out with our btop example. Which brings me to tilix. Oops, just realised I have already gone over our 1000 word limit, we can continue in the next issue.
Any complaints, misc@fullcirclemagazine.org