Outils pour utilisateurs

Outils du site


issue217:c_c

Ceci est une ancienne révision du document !


CnC

Last issue we looked at tmux after screen. I was going to move onto something else this month, but I realised that I left out a few things. The first being how to change the horrible CTRL+b to CTRL+a or CTRL+l depending on the side of the keyboard you prefer. This will not disable CTRL+b, but it will add your key binding of choice as an alternative or you can disable it with unbind.

Open a terminal and type nano .tmux.conf

We will set an option with set-option, make it global with -g and tell it we want our prefix to be CTRL+a like screen. We will then unbind the CTRL+b key prefix.

Once done, write out and quit or exit and save. Tmux shows any error messages from commands in configuration files in the first session created, and continues to process the rest of the configuration file.

Now fire up tmux and test out the new settings.

That brings me to: CTRL+b and : -This is the other place you can type commands that are valid for the current session only, unlike our conf-file.

Let’s do that quickly, open a terminal with tmux and open the tmux command line, now type: set-option -g status-style bg=cyan -and press <enter> (To support older terminals, tmux supports black and white and six colours by default, but we can force it to use 256 with set -g default-terminal “screen-256color”.) You should see the information bar at the bottom go from green to cyan. Now press CTRL+b and & -If you had more than one pane, please close those too. Now tmux should have exited. Open tmux again. You will notice that the information bar is now green again. If you copy that command to the tmux.conf file, the change becomes permanent. The command is taken directly from the man page, so head over to the “COMMAND PARSING AND EXECUTION” section and try adding that second option to your configuration file. As I said in the last issue, I really like that the short-cut key combinations have command substitutions. Press: CTRL+b and : -and type neww (new-window) and press <enter>

Now I don’t know about you, but this one command at a time does not do it for me, so let’s repeat the exercise and type this instead: neww;splitw -on the command line. Do not insert spaces as the man page has or the command will fail. There are options to these commands as well, for instance, you could open a window in a folder that you want to work in. Open the tmux command line and type neww -c /etc

At this point, tmux just starts to become its own thing and you can get lost in the weeds as a newbie, so we will stay near the surface. As an alternative we also have tilix, but unlike tmux, the man page for tilix is empty by comparison. (we will get to this in another issue)

*Note: The command: tilix -q will not work in a wayland session. I use Byobu as my wrapper for screen and tmux. You can specify what you want to work with when starting byobu, by typing byobu-screen or byobu-tmux or just byobu if you set up a configuration file. I find this a lot easier when I have to do things remotely that require screen and something locally, that I use tmux for. The power of byobu is in the configuration files. You will find them under: /home/<username>/.config/byobu Here you can tweak how tmux or screen behaves as well as how they look. Yes, that’s right we can rice our sessions! *Tip: do not run byobu as root (don’t use sudo byobu) as it will change the ownership of your configuration files to the root user. There is a way to do it, but just rule-of-thumb this.

Open a terminal and type byobu. (it defaults to byobu-tmux) If you don’t have byobu installed, type: sudo apt install byobu

You will know byobu is running by its fancy information bar. Do the following:

echo “ start” <enter>

press F2

echo “middle” <enter>

press F2

echo “end” <enter>

press F3, now press F4.

Notice that we are doing the same as we did in earlier issues, but the work flow is a lot easier and simple with single key presses. Our modifiers are CTRL and SHIFT. Press: SHIFT+F2. What happened was that we split our window into two panes, with the new pane below the old one and then byobu numbered the panes for you. Now try it with the other modifier, press: CTRL+F2. You should also see a decent line around the pane you are currently in.

We can now do the same with F3 and F4 and modify it with SHIFT. Give that a go. Now use CTRL+b and so like we did in the previous issue. Try CTRL+F6 and then finally, SHIT+F6. (F6 being the violent key, hehehehe)

Since we did all this in the previous three issues, I’m not going to explain each one, suffice to say, I’m showing you how easy it is with byobu.

If you start byobu again, it will attach itself automatically to the last open session, you don’t need to do anything. In byobu, if you want to rename a window, you simply press F8 and start typing.

There are lots of resources out on the internet regarding ricing, so I will not repeat them here. (Also I usually leave mine as default as it serves my needs, but if you spend a lot of time in it, you may want to start editing the configuration files.)

That brings me to one more tip, if you mess up or do not like the results, simply delete the corresponding configuration file.

Lets do that quickly. Press CTRL+SHIFT+F5 a few times until the information bar is well and truly ugly. You will notice that ending a session will not reset the ugly colours. Navigate to: /home/<username>/.config/byobu and delete the “color.tmux” file. Now when you start a new instance of byobu, it will create this file again, so do not worry. There you go, you should be back to defaults. :)

As per usual, any errors, report them to: misc@fullcirclemagazine.org

issue217/c_c.1747497588.txt.gz · Dernière modification : 2025/05/17 17:59 de philou511