Blog de programación, errores, soluciones

Chose Language:
comments
Author: Admin/Publisher |finished | checked

A basic guide to Tmux

In this entry, I will create a basic guide to Tmux. The topics covered will include: What is Tmux? Why might it be useful for you? And its basic commands.

¿What is Tmux?

Tmux is a terminal multiplexer that allows us to switch between multiple programs in the terminal and also lets us access them again from another terminal.

¿Why use Tmux?

If you’re on Windows, this might not seem very interesting, really. Windows is known for its graphical interface, which makes common tasks easier for users. But when it comes to servers, things change.

Linux plays a significant role in the server world, and you won’t always have access to Linux’s GUI because it comes with additional costs. With that cost, a company could instead allocate more space, memory, etc.

Therefore, on a large number of servers, only the console is used, and this is where Tmux becomes relevant.

A simple terminal is not the same as one that can be split into windows, panes, and has additional advantages.

Basic Comands Tmux

In this section, we will look at the most basic commands—those that will keep you using Tmux without getting stuck when you’re on a client’s server or your own server.

Console / Terminal

These are the commands you will use in the console to start Tmux or resume windows from a previous terminal session.

To create a new session, you can type:

tmux new

Resume what you had open in the previous terminal.

tmux a

You can list the sessions at any time with:

tmux ls

We can also name the session when we create it.

tmux new -s nombre_sesion

This way, we can use it:

tmux attach -t nombre_sesion

Inside tmux

At any time, you can use Ctrl + b followed by ?. If you don’t remember a command, Ctrl + b followed by ? will show you a list with a brief description of the commands.

You can exit the session with the following command:

convinación descripción
ctrl + b  d  exit session

Windows

Let’s look at the commands for windows. With these commands, you can create a window, delete one, or select a specific window.

convinación descripción
ctrl + b  c  creates a new window
ctrl + b  &  ask to delete actual window
ctrl + b a number in the array select the window based on the array number

Panels

Commands for panes: Panes can be especially useful when you’re configuring servers, so keep them in mind.

convinación descripción
Panel Creation
ctrl + b  %  divide the panel with a vertical line
ctrl + b  "  divide the panel with a horizontal line
Ajuste de panel
manteniedo ctrl + b  ←  ajusta el panel en direccion izquierda
manteniedo ctrl + b  →  ajusta el panel en direccion derecha
manteniedo ctrl + b  ↑  ajusta el panel hacia arriba
manteniedo ctrl + b  ↓  ajusta el panel hacia abajo
Cambio de panel
sin mantener ctrl + b  ←  pasa al panel que se encuentra a la izquierda
sin mantener ctrl + b  →  pasa al panel que se encuentra a la derecha
sin mantener ctrl + b  ↑  pasa al panel que se encuentra arriba
sin mantener ctrl + b  ↓  pasa al panel que se encuentra abajo

Line command mode

Line commands: Line commands are especially used to delete a panel or all the panels.

convinación descripción
ctrl + b  :  habilita la linea de comandos

In the command line, we can use the following commands:

To delete all the panes:

:kill-pane -a

To delete the panel you’re currently in:

:kill-pane

Delete a session: This will remove everything associated with the session, including windows and panes.

:kill-session

Copy and paste

We also have commands for copying and pasting, but personally, I prefer using the mouse—select what I want and then middle-click where I want to paste what I’ve selected.

Basically, these are the commands, which you can see in a response on Unix StackExchange.

  1. Ctrl+b[ Enter copy(?) mode.
  2. Move to start/end of text to highlight.
  3. Ctrl+Space

Start highlighting text (on Arch Linux). When I’ve compiled tmux from source on OSX and other Linux’s, just Space on its own usually works. Selected text changes the colours, so you’ll know if the command worked.

  1. Move to opposite end of text to copy.
  2. Alt+w Copies selected text into tmux clipboard.
    On Mac, use Esc+w. Try Enter if none of the above work.
  3. Move cursor to opposite tmux pane, or completely different tmux window. Put the cursor where you want to paste the text you just copied.
  4. Ctrl+b] Paste copied text from tmux clipboard.
https://unix.stackexchange.com/questions/58763/copy-text-from-one-tmux-pane-to-another-using-vim
Category: en-others
Something wrong? If you found an error or mistake in the content you can contact me on Twitter | @luisg2249_luis.
Last 4 post in same category

Comments