Git Product home page Git Product logo

presentation-tmux's Introduction

TMUX - A Terminal Multiplexer

Speaker: Nick Diesslin

Twitter handle: @ndiesslin


Key Takeaways

  • What is TMUX?
    • Alternatives
  • Benefits
  • Getting started
  • How to configure
  • Plugins
  • How to use
  • Commands
  • Use cases
  • Expanding upon TMUX, creating widgets

What is TMUX?

  • TMUX is a terminal multiplexer
  • TMUX runs sessions, sessions contain windows and windows contain panes
  • The biggest benefit is being able to run multiple terminal commands at the same time
  • TMUX is for UNIX like operating systems

Alternatives to TMUX

TMUX is recommended, but to be fair there are other terminal session managers available

  • Screen (Older GNU terminal session manager)
  • Byobu

Benefits

  • The terminal will now run sessions, which can be detached and attached to a terminal window
  • Tabs, split screens in session
  • Configurable
  • Zooming in panes
  • Saved and restored sessions (with plugins)

Getting Started

  • TMUX is available with most package managers
  • Mac
brew install tmux
  • Debian based linux
apt-get install tmux 
  • Then type tmux to start a session
tmux
  • TMUX has what is called a prefix key, this is the keyboard combination you will need to interact with TMUX. By default it is ctrl+b
ctrl+b

How to configure

  • TMUX will load configurations based off of the .tmux.conf file in your home directory (~)
  • You can steal someone's configuration from the internet to start off in a better place, but you will want to review in case there are any unfamiliar keybindings
  • Default tmux command prefix: Most of the users on the internet remap ctrl+b to ctrl+a
  • TMUX uses 256 color palette
  • To see the colors available for configurations run this script
for i in {0..255}; do
    printf "\x1b[38;5;${i}mcolour${i}\x1b[0m\n"
done

Plugins

How to use

  • Creating windows
  • Splitting windows into panes
  • Resizing panes
  • Zooming in and out of pane

Commands

Sessions

  • Load tmux session
tmux
  • Load tmux session with name - beneficial if multiple people work on same machine
tmux new -s mysession
  • Show running tmux sessions
ctrl+b s
  • Detach from session
ctrl+b d

Windows/Tabs

  • Create new window
ctrl+b c
  • Close current window
ctrl+b &

Panes

  • Split pane vertically
ctrl+b %
  • Split pane horizontally
ctrl+b "
  • Switching panes
ctrl+b (any arrow key for direction)

Copy Mode

  • Copy mode puts the session in a mode that allows you to interact with your terminal session in a similar way to vim. This is especially helpful with things like searching logs.

  • Enter copy mode

ctrl+b [
  • Arrow up and down to go through lines in sessions, or you can use j to move down or k to move up like in vim.

  • Visually select a line

Shift+v
  • Copy highlighted line
y

Giant clock

ctrl+b t

Use cases

  • Comparing multiple servers in split view
  • Saving and restoring sessions for saving time with local development
  • Multiple users working on same server, each could spin up their own TMUX session
  • Creating a session with a command that you can check in on

Expanding on TMUX

Creating a status widget

  • TMUX can run any script and display this in the status bar. This means you can really use any scripting language to create some sort of status bar widget.

  • Simple example of something that could be used in statusbar

touch ~/pingtest.sh
echo "ping google.com" >> ~/pingtest.sh
  • Add this to statusbar
#(sh ~/pingtest.sh)

Running a command with a TMUX session

  • TMUX can be helpful if you need to run a command to check in on later, this could be on a server for example.
tmux new-session -d -s temporary_session 'sh ~/pingtest.sh'
  • Attach to our session we created
tmux attach -t temporary_session

presentation-tmux's People

Contributors

ndiesslin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.