Outils pour utilisateurs

Outils du site


issue125:tutoriel2

Ceci est une ancienne révision du document !


If you work a lot in GNU/Linux command-line or in a terminal emulator, as a programmer or system administrator, then you will realize soon that the usage of the mouse is slowing you down in your daily work. The command-line usage, without any desktop environment, is limited to only one window. In a desktop environment, the terminal emulator provides more screens, but it needs a mouse to navigate. The so-called tmux application brings us a flexible, productive, mouse-free, terminal environment. This can be your new IDE (Integrated Development Environment) without any GUI (Graphical User Interface). The name of the tmux application refers to the words “terminal multiplexer”. This tool contains separate windows (like tabs in a text editor), and/or different horizontal or vertical panes inside a window. The windows are great to run different programs/scripts in parallel; the panes are great to run two or more programs on the same screen. The whole environment is managed via the keyboard.

Si vous travaillez beaucoup dans GNU/Linux en ligne de commande ou dans un émulateur de terminal, comme programmeur ou administrateur système, alors vous réaliserez bientôt que l'usage de la souris vous ralentit dans votre travail quotidien. L'usage de la ligne de commande, sans environnement de bureau, est limité à une seule fenêtre. Dans un environnement de bureau, l'émulateur de terminal fournit plus d'écrans, mais il nécessite une souris pour naviguer.

L“'application appelée tmux apporte un environnement de terminal souple, productif et sans souris. Ce peut être votre environnement de développement intégré (IDE) sans aucun interface graphique (GUI). Le nom de l'application tmux se réfère aux « terminal multiplexeur » (multiplexeur de terminal). cet outil contient des fenêtres séparées (comme les onglets dans un éditeur de texte), et/ou différents panneaux horizontaux ou verticaux dans une fenêtre. Les fenêtres sont grandes pour pouvoir faire tourner différents programmes/scripts en parallèle ; les panneaux sont grands pour faire tourner deux programmes ou plus dans le même écran. Tout l'environnement est géré à partir du clavier.

The picture shows my tmux with my own configuration. Currently, it has one window with three panes (one vertical on the left and two horizontals on the right). The left one runs a “vim”, the right top one runs the “htop” application, and the right bottom one runs a pure “zsh” shell. All the programs are running in parallel and can be seen at the same time. Can you imagine a better working environment? For example, if you are a web developer, you can run the editor, the database, and the console at the same time on one screen. And navigation between them can be achieved by just the keyboard – without using the mouse at all. Tmux uses a server-client model which has a great benefit. When we start tmux, a new session is opened on the server. When we leave the application (this is called “detach”), the session remains open in the background together with the running windows/panes/programs/scripts. Later on, we can join this session again (this is called “attach”), and we are able to continue the work where we left. Additionally, we can detach from the session on workstation_A, and we can reattach on workstation_B over ssh as well. This feature is similar to the one used in the GNU-Screen program.

An additional benefit is that it can be used either in a graphical environment inside terminal emulator, or in pure console mode. The memory footprint is also very impressive; it needs only 3-4 MB memory per session/window which is important when you use an old computer. Tmux is licensed under BSD. The official website is: https://tmux.github.io/ The source code is available in github: https://github.com/tmux/tmux The latest release runs on OpenBSD, FreeBSD, NetBSD, Linux, OS X, and Solaris. Installation of tmux There are two ways to use tmux on your machine: (a) use the package manager or (b) build from source from github. Be advised that version 2.2 or higher has to be used at the time of reading this article series, earlier versions can have configuration incompatibilities or missing features. Personally, I use both Debian 8 (jessie) stable and Xubuntu 16.04 LTS, and their repositories contain the old version 1.9/2.1, so I have preferred to download the source code and compile it by myself.

The tool has dependencies as well, be sure that the needed packages are available on your system: GCC compiler, libevent and ncurses. Let’s get them: sudo apt install build-essential libevent-dev libcnurses5-dev Tmux can be downloaded from its main web page or directly from github. The latest version is 2.4, available since April 20, 2017. Type the following commands in terminal:

cd ~ wget https://github.com/tmux/tmux/releases/download/2.4/tmux-2.4.tar.gz tar -zxvf tmux-2.4.tar.gz cd tmux-2.4 ./configure make sudo make install cd .. rm -rf tmux-2.4/ tmux-2.4.tar.gz In order to be sure that the installation was successful, get the version of the newly added tmux: tmux –V tmux 2.4 Starting tmux is very simple; in a terminal/console: tmux After executing the start command, the following screen will be shown:

What you see (below) is an opened tmux “session” (labeled with ”[0]“ in the status bar) with one active window (labeled with “0:zsh*” in the status bar). It seems similar to a normal terminal or console, every command can be executed in the same way. Additionally, the screen has an informal status bar which has a configurable layout. Quitting from tmux is also very easy: exit This will terminate the current tmux session.

Conclusion This article covers the first steps to become a daily tmux user. Hopefully, it was enough to draw attention to this impressive tool. The next chapters will bring us the detailed usage of sessions, windows and panes. Later on, we are going to dig into the configuration of tmux. Get Productive! Get tmux! Command Reference tmux = start the program tmux -V = get the version of tmux exit = terminate the program

issue125/tutoriel2.1507637113.txt.gz · Dernière modification : 2017/10/10 14:05 de d52fr