Outils pour utilisateurs

Outils du site


issue217:c_c

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.

Dans le dernier numéro, nous avons abordé tmux après screen. J'allais passer à autre chose ce mois-ci, mais je me suis rendu compte que j'avais oublié quelques points. Le premier est de savoir comment remplacer le terrible CTRL+b par CTRL+a ou CTRL+l, selon le côté du clavier que vous préférez. Cela ne désactivera pas CTRL+b, mais ajoutera le raccourci clavier de votre choix. Vous pouvez également le désactiver avec unbind.

Ouvrez un terminal et saisissez :

nano .tmux.conf

Nous allons définir une option avec set-option, la rendre globale avec -g et lui indiquer que nous voulons que notre préfixe soit CTRL+a, comme screen. Nous allons ensuite dissocier le préfixe de la touche CTRL+b.

Une fois terminé, écrivez et quittez ou quittez et enregistrez. Tmux affiche les messages d'erreur des commandes des fichiers de configuration lors de la première session créée et continue de traiter le reste du fichier de configuration.

Démarrez maintenant tmux et testez les nouveaux paramètres.

Cela m'amène à : CTRL+b et : - C'est l'autre endroit où vous pouvez taper des commandes qui ne sont valables que pour la session en cours, contrairement à notre fichier de configuration.

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.

Pour le faire rapidement, ouvrez un terminal avec tmux et ouvrez la ligne de commande tmux. Saisissez :

set-option -g status-style bg=cyan - et appuyez sur <Entrée>

(Pour prendre en charge les terminaux plus anciens, tmux prend en charge le noir et blanc et six couleurs par défaut, mais vous pouvez le forcer à utiliser 256 couleurs avec set -g default-terminal “screen-256color”.)

La barre d'informations en bas devrait passer du vert au cyan. Appuyez maintenant sur CTRL+b et & - Si vous aviez plusieurs volets, fermez-les également. tmux devrait maintenant se fermer. Ouvrez à nouveau tmux. Vous remarquerez que la barre d'informations est à nouveau verte. Si vous copiez cette commande dans le fichier tmux.conf, la modification devient permanente. Cette commande est directement issue de la page de manuel. Consultez la section « COMMAND PARSING AND EXECUTION » (Analyse et exécution des commandes) et essayez d'ajouter cette deuxième option à votre fichier de configuration. Comme je l'ai dit dans le dernier numéro, j'apprécie beaucoup que les raccourcis clavier proposent des substitutions de commandes. Appuyez sur : CTRL+b et : -, puis tapez neww (nouvelle fenêtre) et appuyez sur <Entrée>.

Je ne sais pas pour vous, mais ce fonctionnement avec une commande à la fois ne me convient pas. Répétons donc l'exercice et saisissons plutôt :

neww;splitw

sur la ligne de commande. N'insérez pas d'espaces comme indiqué dans la page de manuel, sinon la commande échouera.

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.

Ces commandes offrent également des options. Par exemple, vous pouvez ouvrir une fenêtre dans un dossier que vous souhaitez utiliser. Ouvrez la ligne de commande tmux et saisissez :

neww -c /etc

À ce stade, tmux commence à prendre son indépendance et, en tant que débutant, vous risquez de vous perdre dans les détails ; nous allons donc rester à la surface.

Nous avons également tilix comme alternative, mais contrairement à tmux, sa page de manuel est vide (nous y reviendrons dans un autre article).

Remarque : La commande tilix -q ne fonctionne pas dans une session Wayland.

J'utilise Byobu comme wrapper pour screen et tmux. Vous pouvez spécifier ce que vous souhaitez utiliser au démarrage de byobu en saisissant byobu-screen ou byobu-tmux, ou simplement byobu si vous avez créé un fichier de configuration. Je trouve cela beaucoup plus simple lorsque je dois effectuer des tâches à distance nécessitant screen et des tâches locales pour lesquelles j'utilise tmux.

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.

La puissance de byobu réside dans ses fichiers de configuration. Vous les trouverez sous : /home/<nom d'utilisateur>/.config/byobu

Là, vous pouvez modifier le comportement et l'apparence de tmux ou de screen. Oui, c'est vrai, nous pouvons exécuter nos sessions !

Conseil : n'exécutez pas byobu en tant qu'utilisateur root (n'utilisez pas sudo byobu), car cela transférerait la propriété de vos fichiers de configuration à l'utilisateur root. Il existe une façon de la faire, mais prenez ça pour une règle générale.

Ouvrez un terminal et saisissez byobu (la valeur par défaut est byobu-tmux). Si byobu n'est pas installé, saisissez : sudo apt install byobu

Vous saurez que byobu est en cours d'exécution grâce à sa barre d'informations sophistiquée. Procédez comme suit :

echo “start” <enter>

appuyez sur F2

echo “middle” <enter>

appuyez sur F2

echo “end” <enter>

appuyez sur F3, puis sur 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, SHIFT+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.

Notez que nous procédons de la même manière que dans les numéros précédents, mais le processus est beaucoup plus facile et simplifié avec l'appui sur une seule touche.

Nos touches de modification sont Ctrl et Maj. Appuyez sur Maj+F2. Nous avons divisé notre fenêtre en deux volets, le nouveau volet étant situé sous l'ancien, puis Byobu a numéroté les volets pour vous. Essayez maintenant avec l'autre touche de modification : Ctrl+F2. Vous devriez également voir une ligne bien définie autour du volet dans lequel vous vous trouvez.

Nous pouvons maintenant faire la même chose avec F3 et F4 et modifier le résultat avec Maj. Essayez. Utilisez maintenant Ctrl+b, comme dans le numéro précédent. Essayez Ctrl+F6, puis enfin Maj+F6. (F6 étant la touche la plus puissante, héhéhéhé)

Comme nous avons fait tout cela dans les trois numéros précédents, je ne vais pas vous expliquer chaque option. Je vous montre simplement à quel point c'est facile avec Byobu.

Si vous redémarrez byobu, il se rattachera automatiquement à la dernière session ouverte ; vous n'avez rien à faire. Dans byobu, pour renommer une fenêtre, appuyez simplement sur F8 et commencez à saisir du texte.

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

Il existe de nombreuses ressources sur Internet concernant la configuration et la personnalisation ; je ne les répéterai donc pas ici. (Je laisse généralement les valeurs par défaut, car cela me convient, mais si vous y passez beaucoup de temps, vous pourriez commencer à modifier les fichiers de configuration.)

Ceci m'amène à un autre conseil : si vous faites une erreur ou que le résultat n'est pas satisfaisant, supprimez simplement le fichier de configuration correspondant.

Faisons-le rapidement. Appuyez plusieurs fois sur Ctrl+Maj+F5 jusqu'à ce que la barre d'informations soit vraiment inesthétique. Vous remarquerez que la fermeture d'une session ne réinitialise pas les couleurs disgracieuses. Accédez à : /home/<nom d'utilisateur>/.config/byobu et supprimez le fichier « color.tmux ». Lorsque vous démarrerez une nouvelle instance de byobu, ce fichier sera à nouveau créé, donc pas d'inquiétude. Et voilà, vous devriez être revenu aux valeurs par défaut. :)

Comme d'habitude, signalez toute erreur à : misc@fullcirclemagazine.org

issue217/c_c.txt · Dernière modification : 2025/06/02 08:24 de d52fr