Outils pour utilisateurs

Outils du site


issue184:c_c

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.

Bienvenue de retour dans un nouveau numéro de Command & Conquer. Nous avons parlé d'écran dans un numéro précédent où j'ai mentionné tmux. C'est dans ce numéro-ci que ça se passe.

Installation

On dit qu'une image vaut mille mots, voyons si cela fonctionne.

Une fois que vous l'avez installé, lancez-le en tapant « tmux » et vous devriez voir une barre apparaître en bas du terminal (voir ci-dessous).

Parlons ici des combinaisons de touches et des interrupteurs, car c'est autour de cela que tourne tmux.

Dans la catégorie générale, je mettrais « faire des erreurs ». Oui, tmux est très utile pour vous corriger, si vous en faites. En fait, je vous recommande de les faire. C'est vraiment la meilleure façon d'apprendre. Contrairement à la programmation, où presque tout est « erreur de syntaxe » et aucune aide n'est fournie. Je vous suggère de commencer par la commande tmux et de la suivre avec toutes les lettres de l'alphabet. Cela peut sembler stupide, mais c'est ainsi que vous avez appris quand vous étiez enfant. C'est BEAUCOUP mieux que de vous le dire. Ne vous inquiétez pas, je vous donnerai encore beaucoup d'informations, mais je veux que vous en découvriez certaines par vous-même.

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.

C'est pas génial, tmux ?

Si vous vous souvenez de notre article sur l'écran, la combinaison de touches pour dire à l'écran que vous allez lui donner une commande était CTRL+a. (Appelons ça une « amorce »). Dans tmux, c'est CTRL+b. Le plus important dont je voudrais vous parler est le « ? ». Si vous appuyez sur CTRL+b, puis sur un point d'interrogation, l'aide s'affichera. Ce qui est bien ici, c'est que vous pouvez utiliser la molette de votre souris pour faire défiler la liste vers le haut ou vers le bas. Bien que tout ceci puisse sembler idiot aux utilisateurs d'interface graphique, il y aura un moment où vous devrez naviguer dans le terminal et pourquoi ne pas le rendre aussi confortable que possible ?

Dans tmux, vous pouvez avoir des onglets ou des fenêtres, vous permettant de faire une chose qui peut durer un certain temps, et ouvrir une autre « fenêtre » dans le même terminal pour faire autre chose. Vous ne voyez pas une autre fenêtre en soi, mais une « nouvelle » fenêtre dans la fenêtre actuelle. Vous pouvez nommer ces fenêtres en utilisant simplement les touches CTRL+b pour les « amorcer », suivies d'une « , » (virgule). Tapez le nouveau nom et il sera affiché en bas à la place de « bash » (voir ci-dessus).

Cela permet de vous souvenir facilement de ce que vous faisiez dans chaque fenêtre, si vous en avez beaucoup d'ouvertes. Comme pour l'écran, p et n seront pour les fenêtres précédente et suivante si vous les entrez après l'amorce. Si vous souhaitez voir toutes les « fenêtres » que vous avez ouvertes, c'est w après l'amorce, et pour revenir à la « dernière » fenêtre sur laquelle vous étiez, c'est l après l'amorce. Lorsque vous utilisez la commande « w », les fenêtres sont listées avec des numéros et vous pouvez aller directement à l'une d'entre elles avec le numéro de cette fenêtre, directement après les touches d'amorce. Vous pouvez également trouver une fenêtre par le nom que vous lui avez donné, une autre raison de nommer vos fenêtres. Tapez votre amorce, suivi d'un f, puis tapez simplement une partie du mot pour trouver votre fenêtre. Évidemment, vous devrez être plus détaillé si vous avez nommé vos fenêtres « docker1 », « docker2 » et « docker3 ». Conseil : ne le faites pas.

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.

Bon. Vous pouvez vouloir tuer une fenêtre et pas tout le terminal. C'est là que vous utilisez l'esperluette « & » (qui aura une apparence différente selon la police). Shift+7 sur mon clavier. Vous devriez obtenir une invite vous demandant si vous souhaitez tuer la fenêtre. Si vous voulez grouper des fenêtres, vous pouvez facilement les déplacer avec le point « . » après l'amorce, bien qu'en toute honnêteté, je n'ai jamais utilisé cette fonctionnalité, jamais. Pour m'amuser avec tmux, j'aime l'utiliser après l'amorce. Cela me donne une horloge (temps) pour voir quand je peux rentrer chez moi. XD Que puis-je dire, être une prostituée est une vie difficile, je donne mon corps à mon patron pour un minimum de 8 heures par jour, et je ne porte pas de montre.

Mais tmux est beaucoup plus profond que ce qu'un simple « Command & Conquer » pourrait couvrir, mais j'aimerais couvrir plus de bases que les raccourcis clavier. Tmux comprend aussi des commandes. Par exemple, vous pouvez taper « tmux ls » pour lister toutes les fenêtres ou sessions ouvertes. Tout comme vi/vim, il y a un menu « caché » qui apparaît après avoir tapé « : » (deux points) après l'amorce (montré ci-dessus).

Cela permet encore plus de fonctionnalités ; par exemple, en tapant le mot « new » après ces deux points, vous ouvrirez une nouvelle fenêtre. Personnellement, je trouve qu'il est plus facile d'utiliser les touches de raccourci, mais à chacun sa façon de faire. (Bien que vous puissiez faire plus de choses de cette façon).

Mon conseil de tout à l'heure reste le même : tapez une lettre et appuyez sur la touche de tabulation pour voir les options ici aussi. Ici, j'ai tapé « set » puis j'ai tabulé pour obtenir des résultats.

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.

Mais ce n'est pas tout, vous pouvez aller un peu plus loin et créer un « dotfile » et le charger. Quand vous arrivez au deux-points, commencez simplement à taper source et tabulation complète pour charger un fichier source :

fichier-source ~/.tmux.conf

(Vous pouvez récupérer de beaux fichiers sur internet, assurez-vous simplement de les lire d'abord pour comprendre ce qu'ils font). Je vais vous mettre un lien ici :

https://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/

https://linuxhint.com/customize-tmux-configuration/

Quelques ressources utiles. Bonne lecture.

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

Beaucoup d'utilisateurs de Vim apprécient tmux à cause des liens que vous pouvez créer. Honnêtement, je ne suis pas un fan, mais je vais en inclure un peu ici pour ceux d'entre vous qui le sont (non listés dans ces liens) :

bind s split-window -v diviser

bind v split-window -h fractionnement

bind h select-pane -L touches de mouvement

bind j volet de sélection -D touches de mouvement

bind k volet de sélection -U touches de mouvement

bind l select-pane -R touches de mouvement

setw -g mode-keys vi touches de mouvement de vim en mode copie

bind - resize-pane -D 1 redimensionne le volet vers le bas de 1

bind + resize-pane -U 1 redimensionne le volet vers le haut de 1

bind < resize-pane -L 1 redimensionne le volet vers la gauche de 1

bind > resize-pane -R 1 redimensionne le volet à droite de 1

Ce qui me ramène au « ? ». Si vous souhaitez diviser un volet, par exemple verticalement, vous pouvez utiliser le « % » après l'amorce. L'aide intégrée « ? » permet d'y voir plus clair. Je ne vais pas répéter ce que vous pouvez y trouver. Trouvez vous-même comment utiliser ces touches de raccourci ; c'est une expérience d'apprentissage. Vous n'utiliserez peut-être pas beaucoup le terminal en jouant à Minecraft, mais une fois que vous aurez créé votre propre serveur Minecraft, vous comprendrez peut-être.

Avons-nous fait des erreurs ? Faites-nous le savoir misc@fullcirclemagazine.org

issue184/c_c.txt · Dernière modification : 2022/08/30 18:57 de auntiee