Fireship · @fireship

Tmux in 100 Seconds

Uploaded September 22, 2024 · Length 3:02

Tmux in 100 Seconds

Summary

Learn how to use Tmux to organize and manage multiple terminal sessions in a single window.

  • tmux
  • terminal multiplexer
  • linux
  • unix
  • terminal organization
  • session management

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    t-mo an open- Source terminal

  2. 0:02

    multiplexer that can juggle multiple

  3. 0:04

    terminal sessions from a single window

  4. 0:06

    it was created by Nicholas Marriott in

  5. 0:08

    2007 after becoming frustrated with the

  6. 0:10

    limitations of G screen and is offered

  7. 0:12

    under the more permissive BSD license as

  8. 0:14

    you can see here I'm building some

  9. 0:16

    crappy software and I have a terminal

  10. 0:18

    window open for a web server one for

  11. 0:20

    postgress one for my engine X logs one

  12. 0:22

    for htop one for Nano and one for repel

  13. 0:24

    to say hello world it's complete chaos

  14. 0:26

    but things get a lot better if I run

  15. 0:28

    this t-x command first which will summon

  16. 0:30

    this magic little status bar now I can

  17. 0:32

    take all these Terminals and combine

  18. 0:34

    them into a single window where they're

  19. 0:35

    organized in the status bar like an

  20. 0:36

    array I can easily navigate between them

  21. 0:38

    without ever touching the mouse to split

  22. 0:40

    them into panes both horizontally and

  23. 0:42

    vertically and can give each one of them

  24. 0:43

    a custom name and if I accidentally

  25. 0:45

    closed it all is not lost because the

  26. 0:47

    session is still running in the

  27. 0:48

    background also if you're constantly

  28. 0:50

    switching between multiple failed side

  29. 0:52

    projects it's timec consuming to

  30. 0:53

    manually resurrect a bunch of terminal

  31. 0:55

    Windows to set up your environment a

  32. 0:57

    t-mo can be controlled with scripting to

  33. 0:59

    Define sessions programmatically with

  34. 1:01

    just a few lines of bash code we can

  35. 1:03

    instantly fire up multiple terminals for

  36. 1:05

    our project with descriptive names and

  37. 1:07

    fancy colors but you don't even have to

  38. 1:08

    do it all from scratch because t-mo has

  39. 1:10

    a bunch of pre-built plugins like

  40. 1:12

    resurrect will restore your environment

  41. 1:14

    after reboot or use power line to

  42. 1:15

    customize it in ways that would make

  43. 1:17

    even the most flamboyant peacock jealous

  44. 1:19

    to get started install it on any Unix

  45. 1:21

    like machine including Mac OS Linux and

  46. 1:23

    WSL then open up a terminal window and

  47. 1:26

    start a new session go ahead and run any

  48. 1:28

    random process then create a new

  49. 1:30

    terminal window by hitting control Bravo

  50. 1:32

    let go then hit Charlie a new terminal

  51. 1:34

    is pushed onto the stack and we can

  52. 1:36

    navigate between them with contrl B

  53. 1:38

    followed by their index number we can

  54. 1:39

    also navigate with the arrow keys or

  55. 1:41

    split these terminals into panes with

  56. 1:43

    quotee for vertical or percent for

  57. 1:44

    horizontal pretty cool but oh no I just

  58. 1:47

    closed it but it didn't actually die it

  59. 1:49

    only detached from reality if we open up

  60. 1:51

    the terminal we can run t-mo LS to list

  61. 1:54

    out all the active sessions when we find

  62. 1:55

    the one we're looking for we can

  63. 1:57

    reattach to it and get back to work

  64. 1:59

    what's really awesome though is that if