Ceci est une ancienne révision du document !
Welcome back to another issue of command and conquer. We talked about screen in a previous issue, where I mentioned tmux. This issue is where that happens. Installation They say a picture is worth a thousand words, let’s see if this works. Once you have installed it, launch it by typing “tmux” and you should see a bar appear across the bottom of the terminal (shown below). Let’s talk about the key combinations and switches here, as that is what tmux revolves around. In the general category, I’d put ‘making mistakes’. Yes, tmux is very helpful in correcting you, if you do. In fact, I’d recommend you make them. This really is the best way to learn. Unlike programming, where almost everything is “Syntax error” and no help is provided. I’d suggest starting with the tmux command and following it with every letter in the alphabet. It may seem dumb, but this is how you learned as an infant. It is a LOT better than me just “telling” you. Don’t worry, I will still be giving you a lot of information, but I want you to discover some for yourself.
Ain’t tmux grand? If you remember our article on screen, the key combination to tell screen that you were going to give it a command, was CTRL+a. (Let’s call it a “primer”). In tmux, it is CTRL+b. The most important one I’d like to tell you about is the ‘?’. If you press CTRL+b, and then a question mark, help will be displayed. The nice thing here is that you can use your mouse wheel to scroll up and down that list. Though all this may seem silly to GUI users, there will come a time you will have to surf the terminal and why not make it as comfortable as possible? In tmux, you can have tabs or windows, allowing you to do one thing that may run a while, and open another “window” in the same terminal to do something else. You don’t see another window per-se, but a “new” window within the current one. You can name these windows simply by using the CTRL+b to “prime” it, followed by a ‘,’ (comma). Type the new name and it will be displayed in the bottom instead of “bash” (see above). This makes it easy to remember what you were doing in which window, if you have a lot of them open. As with screen, p and n will be the previous and next window if you enter them after the primer. If you would like to see all the “windows” that you have open, it is w after the “primer”, and to go back to the “last” window you were on, it is l after the primer. When you use the “w” command, the windows are listed with numbers, you can go straight to any of those with the number of that window directly after the primer keys. You can also find a window by the name you gave it, another reason to name your windows. Type your primer, followed by an f and then simply type part of the word to find your window. Obviously you will have to get specific if you named your windows something like “docker1” “docker2” and “docker3”. Hint: don’t.
Now you may want to kill a window and not the whole terminal. This is where you use the ampersand “&” (which will look different depending on the font). Shift+7 on my keyboard. You should get a prompt to ask you if you’d like to kill it. If you would like to group windows, you can easily move them with the ‘.’ period after the primer, though in all honesty, I have never used that functionality, ever. To have some fun with tmux, I like to use it after the primer. It gives me a clock (time) to see when I can go home. XD What can I say, being a prostitute is a hard life, I give my body to my boss for a minimum of 8 hours a day, and I don’t wear a watch. Now tmux is a lot more in-depth than a simple ‘command and conquer’ could cover, but I’d like to cover more bases than hotkeys. Tmux also understands commands. For instance, you can type ‘tmux ls’ to list all of the open windows or sessions. Just like vi / vim, there is a “hidden” menu that appears after you press “:” (colon) after the primer (shown above). This allows for even more functionality; for instance, typing the word “new” after that colon, will open a new window. Personally I find it easier to use the hotkeys, but to each his own. (Though you can do more this way). My advice from earlier stands, type a letter and tab complete to see options here too. Here I typed “set” then tabbed to get results.
But that is not all, you can go a step further and set up a “dotfile” and load that up. When you get to the colon, simply start typing source and tab complete to load a source file: source-file ~/.tmux.conf (You can grab nice files from the internet, just be sure to read them first to understand what they do.) I will link you here: https://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/ https://linuxhint.com/customize-tmux-configuration/ Some helpful resources. Enjoy.
A lot of Vim jockeys enjoy tmux, because of the bindings you can create. I am honestly not a fan, but I will include a sprinkling here for those of you who are (not listed in those links): bind s split-window -v splitting bind v split-window -h splitting bind h select-pane -L motion keys bind j select-pane -D motion keys bind k select-pane -U motion keys bind l select-pane -R motion keys setw -g mode-keys vi vim motion keys while in copy mode bind - resize-pane -D 1 resize pane down by 1 bind + resize-pane -U 1 resize pane up by 1 bind < resize-pane -L 1 resize pane to left by 1 bind > resize-pane -R 1 resize pane to right by 1 Which brings me back to the “?”. If you would like to split a pane, say vertically, you can use the “%” after the primer. It is easy to look these up with the built-in help “?”. I will not rehash what you can find there. Please figure out yourself how to use those hotkeys from that, hey it’s a learning experience. You may not use the terminal much just playing minecraft, but once you get into creating your own minecraft server, you may understand. Did we make mistakes? Let us know misc@fullcirclemagazine.org