Skip to content

Instantly share code, notes, and snippets.

@emneo-dev
Last active January 10, 2024 07:46
Show Gist options
  • Save emneo-dev/c82b9d6165365b66e8b132acb32c9449 to your computer and use it in GitHub Desktop.
Save emneo-dev/c82b9d6165365b66e8b132acb32c9449 to your computer and use it in GitHub Desktop.
Simple tmux guide to help first year Epitech students to go through the stumpers

tmux guide for Epitech students

Why use tmux

During the stumpers (solo and duo) you will be exclusively working inside a tty (Try pressing Ctrl+F4 and you will see what it is), you will therefore not be able to have multiple windows right next to eachothers or switch between windows quite that easily.

To those problems come one really cool solution, the terminal multiplexer, or tmux for short. It is a program already installed on your computer (If you are using the Epitech's dump, else you might have to install it using your package manager) that allows you to precisely do the tasks that were hard/impossible to do in a tty that we just saw before.

We will therefore see in that document how to use the bare minimum you will need of tmux for your stumpers with its default configuration (If you want to modify the default tmux config to make it suit your need more there will be a section dedicated to that at the end of that file).

Commands

Important commands/controls

If started by a $ it means the command is to be run inside a terminal, else through tmux command system.

tmux commands work by first hitting a prefix key and then the command's key

The default tmux prefix key is Ctrl-B, assume that every command that is now listed here now needs to be prefixed by that prefix key.

Once again most things in tmux are configurable and that includes the prefix key. More info at the configuration section.

$ tmux launches tmux in your current directory

d detaches from the current tmux session

$ tmux a re-attaches to the last attached session

% split the current pane in two with a vertical line

" split the current pane in two with an horizontal line

arrow_keys allow you to switch between different panes (e.g. Ctrl-B left_arrow focuses to the pane on the left

c creates a new window and switches to it

0-9 allows you to switch between the different created windows (e.g. Ctrl-3 will switch to the window with the id 3, in general the 4th one you have)

w shows you a simple gui of all the windows and panes you have opened with a preview of what is executing/executed inside

The less useful commands

t shows a big clock in the current pane, you can quit with q

, allows you to rename a window, which makes it easier to go around your windows

? shows you a list of commands available to you in tmux

space switched between different pane dispositions

Going further

The manual page for tmux is a gold mine for all the different commands you can use, so don't hesitate to check it out with man tmux.

Configuration

tmux uses a simple configuration file found in $HOME/.config/tmux/tmux.conf (I believe it is not created by default), this file can be tweaked in a million ways and I will not really document it here more than I should.

If you want to customize it to your heart's content you can read through the manual (Which will take you way too long), or you could just simply look some configurations online from people that already went through the pain of searching for all that information.

I personnaly recommend looking at this configuration: https://github.com/nasso/tmux

It is a very simple config that changes the status bar of tmux and changes some bindings to match more closely with vi bindings (e.g. the movement between panes is done with hjkl instead of the arrow keys).

Afterword

tmux is extremely useful and powerful, especially if you are stuck in a terminal (Which is the case in stumpers).

But of course this is just the multiplexer, if you want to make full use of its power and be prepared properly for the stumpers you also NEED to learn a good terminal text/code editor.

emacs is a really good choice and as a ton of learning to go over with it, but other editors also exist like vim, and the choice between which one you will take goes to whichever feels the best to use. So take your time to tests things out and to figure out which is best for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment