Tmux windows 10 install

Windows 10 — Using Git Bash With TMUX

Why Not Use WSL?

I tried the WSL and it isn’t quite seamless enough for me. I ran in to problems when editing in VSCode and having watchers on my files (ng serve, dotnet watch run, etc.). In addition, I kept running in to problems that only manifest themselves when running in WSL. For example, this issue with doing production builds and the terser plugin has made many a developer rage-quit on using WSL. Just figuring out that it was an issue with the WSL took a lot of time.

That terser plugin issue was never resolved and I ended up having to keep a git bash window open in addition to my WSL console window so I could do production builds. To make matters worse, my npm packages were platform-dependent so I couldn’t use the same project folder. So, my procedure was: commit whatever changes to test branch, push to repo, git pull on my «windows» project folder, and do a production build there. It wasn’t untenable but it was far from ideal.

Getting Started

  • Install git with git bash.
  • Install msys2. Follow instructions on that page and be sure to close window when it tells you to and reopen to complete setup.

Install TMUX

  • In a msys2 window, use Pacman to install tmux (pacman -S tmux).
  • Copy tmux and msys-event binaries from msys2 bin folder (probably C:\msys64\usr\bin) to git bash bin folder (probably C:\Program Files\Git\usr\bin).
  • Restart your git bash and try tmux command.

If everything went according to plan, you should see tmux running in your git bash:

Tmux Git Bash

Getting NPM Colors / Progress Working

If you run npm commands, you get no progress spinner or colors. The solution is to use winpty (which is installed as part of the git bash shell as it uses msys). Here’s an example of an npm install with and without winpty:

winpty vs normal npm command

To always use winpty, edit your bashrc (vim ~/.bashrc) and add the following alias:

alias npm="winpty npm.cmd"

Microsoft has recently released Windows 10 build 14361 to the Fast Ring Insiders. Apart from the regular fixes and improvements, Redmond has brought numerous changes to its Linux subsystem that runs Ubuntu on Windows 10.

In its official release notes, Microsoft has listed these changes that are highlighted by the newly-added support for Pseudo Terminal, enabling Tmux support.

For those unfamiliar with Tmux, it’s a command line tool that allows you to divide a terminal window into multiple panes. This terminal multiplexer allows the user to switch between different panes and render the output in each pane.

How to install and use Tmux on Ubuntu on Windows?

I hope that you’ve already installed Ubuntu on Windows 10. If you haven’t, follow our dedicated guide and proceed: How To Install And Run Bash On Ubuntu On Windows 10

Just like the usual Bash on Ubuntu, you can install Tmux in Windows 10 Bash using the apt-get command:

$ sudo apt-get install tmux

tmux installation on bash on ubuntu

Now you need to start Tmux by running tmux command. This will bring a status bar to the bottom of your Bash screen and clear your screen.

Now you are good to go. You can split the screen vertically using this: [CTRL B] + [%]. To split the new pane horizontally, use this: [CTRL B] + [“].

To navigate between the panes, you need to use this: [CTRL B] + [Arrow-key | P | N]

tmux on bash on windows 10

Talking about what Tmux can do, this was just a drop in the ocean. Using this powerful tool, one can make multi-paned terminals and build a customized dashboard full of multiple tools.

tmux on bash on windows 10 a

Another important change in Bash on Ubuntu on Windows 10 comes in the form of case sensitivity in DrvFs. So, now it can recognise a difference between HELLO.TXT and hello.txt. 

It should be noted that an unexpected behaviour may occur while using case sensitivity outside Bash on Windows.

Now Bash on Windows users can also chmod and delete read-only files from DrvFs. The connection to 0.0.0.0 and :: as localhost is also allowed.

To read the complete list of changes made to Microsoft’s Ubuntu port, visit here.

Did you find this article helpful? Don’t forget to drop your feedback in the comments section below.

Recommended: Microsoft’s Love Affair With Linux

Tmux on Windows Step 1: Install WSL. Step 2 (Optional): Upgrade to WSL2. Step 3: Install a Linux distro from the Windows store. Step 4 (Optional): Install Windows Terminal from the Windows store. Step 5: Launch the Linux distro application to complete the installation.

Can I run tmux on Windows?

In Windows 10 build 14361, available now to Windows Insiders fast-ring users, we’ve added Pseudo Terminal support to Windows Subsystem for Linux (WSL) which, along with improvements to Windows Console’s much improved support for rendering VT control sequences, enables Tmux support to light-up your console!Jun 8, 2016.

How to Install tmux Install Tmux on Ubuntu and Debian. sudo apt-get install tmux. Install Tmux on RedHat and CentOS. sudo yum install tmux. Start New tmux Session. To start a new session, in a terminal window type: tmux. Start a New Named Session. Split Pane tmux. Exit tmux Pane. Moving Between Panes. Resize Panes.

How do I run a tmux server?

Below are the most basic steps for getting started with Tmux: On the command prompt, type tmux new -s my_session , Run the desired program. Use the key sequence Ctrl-b + d to detach from the session. Reattach to the Tmux session by typing tmux attach-session -t my_session .

How do I enable tmux in terminal?

To configure your terminal to automatically start tmux as default, add the following lines to your ~/. bash_profile shell startup file, just above your aliases section. Save the file and close it. Then close and reopen the terminal to start using tmux by default, every time you open a terminal window.

How do I list all tmux sessions?

Now you can enter :list-sessions or :ls to see a list of active tmux sessions. By default, list-sessions is binded to the key combination <prefix> s . You can navigate the session list with j and k and activate one by pressing enter .

How do I use tmux on Windows?

This is what you do: Install before-mentioned msys2 package and run bash shell. Install tmux using the following command: pacman -S tmux. Go to msys2 directory, in my case it is C:\msys64\usr\bin. Copy tmux.exe and msys-event-2-1-4. dll to your Git for Windows directory, mine is C:\Program Files\Git\usr\bin .

What is tmux command?

It’s tmux, a so-called terminal multiplexer. Simply speaking, tmux acts as a window manager within your terminal 1 and allows you to create multiple windows and panes within a single terminal window.

Is tmux better than screen?

Tmux is more user-friendly than the Screen and contains a nice status bar with some info in it. Tmux features automatic window renaming while the Screen lacks this feature. The Screen allows session sharing with other users while Tmux does not. That is the great feature that Tmux lacks.

How do I find my tmux version?

as you can see, tmux currently running was executed from binary placed in /usr/bin/tmux. And, as result, you’ll get version of tmux currently running, not the one, that was installed. To get the version of the tmux server you can use display-message.

Is tmux a terminal emulator?

tmux is a terminal multiplexer so it lets you switch between several programs in one single terminal. terminator is a tool for arranging terminals. So you can keep using terminator and run tmux inside it, pretty much the same way you can use it with gnome terminal or any other terminal emulator.

How do I install tmux logging?

2 Answers Clone tmux-plugins/tmux-logging from github. Create conf file ( ~/.tmux.conf ), add to bottom of the config file: run-shell ~/clone/path/logging.tmux. Type this in a terminal: $ tmux source-file ~/.tmux.conf. Run tmux and toggle (to start) logging in the current pane: ctrl+b and shift+p.

Do tmux sessions expire?

Each session is persistent and will survive accidental disconnection (such as ssh(1) connection timeout) or intentional detaching (with the ‘C-b d’ key strokes). tmux may be reattached using: $ tmux attach In tmux, a session is displayed on screen by a client and all sessions are managed by a single server.

How do you use tmux commands?

First, you press Ctrl+B to get tmux ‘s attention. You then quickly press the next key to send a command to tmux . Commands are given by pressing letters, numbers, punctuation marks, or arrow keys. It’s the same in screen , except you press Ctrl+A to get its attention.

Why would you use tmux?

The great thing about tmux is it allows you to have multiple panes open at the same time, each with their own shell running, but using the same single ssh connection. Not only that, you can also have multiple “windows” open at the same time, a bit like tabs with more panes in them.

How do I switch between tmux?

When a tmux session starts, a single window is created by default. It is possible to attach multiple windows to the same session and switch between them as needed.Manage tmux Windows. Command Result Prefix + c Create a new window Prefix + p Switch to the previous window Prefix + n Switch to the next window.

What is Ctrl-B in tmux?

Sync Panes. You can do this by switching to the appropriate window, typing your Tmux prefix (commonly Ctrl-B or Ctrl-A) and then a colon to bring up a Tmux command line, and typing: :setw synchronize-panes. You can optionally add on or off to specify which state you want; otherwise the option is simply toggled.

Where are tmux sessions stored?

When we start a new instance of tmux, while a server is running, a new session is created inside the running server. (For Advanced users) You can run multiple tmux servers. See -L flag in the documentation. By default, the tmux server is named “default” and the socket is stored in /tmp.

How do I detach tmux?

You can also exit tmux by pressing : to go to the bottom bar of the tmux window. Then type kill-session. Note that the session will be gone and will not be reattachable. If you want to detach a session instead of simply closing it, use Ctrl-b d (d for “detach”).

I do a lot of work on the command line in Linux and Windows.
One of my favorite apps that makes working on the command line more efficient is Tmux.
There hasn’t been anything quite like it in Windows, until now.

The Windows Subsystem for Linux (WSL) changes all of this.

Here are the steps for installing the WSL on Windows, and installing Tmux.

Step 1: Install WSL


If you haven’t already done so, install the Windows Subsystem for Linux (WSL).

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
# Will likely require and prompt for a reboot
# If you want to upgrade to WSL2, do not reboot yet, otherwise reboot now

NOTE: If you are on Windows 2004 or later,
you should install WSL 2 for better performance / supportability.

Second NOTE: If you are running this on a VM like VirtualBox,
you will need to use WSL 1

Step 2 (Optional): Upgrade to WSL2


Enable the ‘Virtual Machine Platform’ Windows feature.

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
# Will likely require and prompt for a reboot
# Go ahead and reboot

Set WSL2 as the default WSL version

wsl --set-default-version 2
# Will likely require updating the kernel, Visit https://aka.ms/wsl2kernel
# Install the new kernel and reboot if needed

Step 3: Install a Linux distro from the Windows store


In the Windows store, you can search for your preferred Linux distribution.
Not all are available,
but I have successfully used Ubuntu, Debian, and Kali Linux.

Step 4 (Optional): Install Windows Terminal from the Windows store.


Since you are in the Windows Store,
I would recommend installing the Windows Terminal.

Step 5: Launch the Linux distro application to complete the installation


Run the application you installed from the Windows store;
it should be available on the start menu once it is installed.

Complete the initial user setup:

_config.yml

Step 6 (Optional): Run the Linux Shell in the Windows Terminal


If you launch the Windows Terminal now,
in the drop-down menu you should now have an option to select your Linux distro

If you want to set this as your default shell in the Windows Terminal,
you can update the settings Ctrl + , to do so.

Replace the GUID in defaultProfile with the one for your Linux app.
You can find the GUID in the list section under profiles.

You should see something like this:

    [
        "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
        "hidden": false,
        "name": "Ubuntu",
        "source": "Windows.Terminal.Wsl"
    ]

Set this GUID as the defaultProfile,
and this will be the shell that opens by default.

Step 6: Install tmux


Open up the Linux distro app
(or launch it from the Windows Terminal if you have it installed).
Update / upgrade the applications using the package manager

For Ubuntu / Debian / Kali Linux

sudo apt update
sudo apt upgrade -y

# If using Ubuntu, Tmux should be installed already
sudo apt install tmux

Step 7: Launch


If you are just getting started with Tmux, search for Tmux Cheatsheet for useful examples

_config.yml

Now you can multiplex your terminals til the cows come home.

I will go into detail on configuring Tmux in VIM style in a future post.

Post: Customizing Tmux with VIM keys

Thanks for reading

PS> exit

The tmux terminal multiplexer is often used in remote development, but it has interesting applications for local dev work as well. In this article, I’ll explain what a terminal multiplexer does, show you how to install tmux, run through the basic commands such as starting a tmux session, and show you how to navigate between windows and panes. Finally, I’ll show you why (and how) I use tmux for local development.

I’ll admit that local development isn’t the most obvious use case for tmux, but I started using it that way in 2016 and fell in love with this super awesome little tool. For me, the best part of using tmux for local dev work is the ability to almost instantly get my preferred command line “workspace” set up as soon as I fire up my terminal emulator.

Table of Contents

  1. What Is tmux?
  2. How to Install tmux
    1. Installing tmux on Linux
    2. Installing tmux on macOS
    3. Installing tmux on Windows
  3. How to Use tmux
    1. Command Structure
    2. Sessions
    3. Attaching and Detaching
    4. Windows and Panes
  4. Why Use tmux Locally?
  5. Wrapping Up

What is tmux?

The name “tmux” is a contraction of “terminal multiplexer.” This means you can open multiple split-views (panes) in a single terminal window, and each will function as its own independent terminal. They run visually, right next to each other, eliminating the need to open a new window.

It’s often thought of as a tool you use when working on a remote server, as it saves opening up multiple terminal (SSH) sessions to the machine when you’re trying to do a few things at once.

Maybe you’ve got a script you need to run that takes a while and at the same time you want to monitor its output to a log file with a command like tail -f. Perhaps all the while editing some other configuration files or scripts you’re getting ready to run next.

Normally you’d fire up three or more separate instances of your terminal application and SSH into the server with each one. With tmux you only need one SSH connection to the server.

The great thing about tmux is it allows you to have multiple panes open at the same time, each with their own shell running, but using the same, single SSH connection.

tmux with three panes.

Not only that, you can also have multiple windows open at the same time, a bit like tabs with more panes in them.

tmux with second window.

A huge benefit of using tmux on a remote server is that if your internet connection should die for any reason, that tmux session just keeps on truckin’. Your long-running job that you just kicked off and forgot to nohup and background with stream redirection keeps on going too. Just tmux attach once your internet is back and you’ve SSH’d into the server again, with all the same panes and windows there waiting for you. You can even detach from your current session, log back in at another computer, and find it’s still running.

How to Install tmux

Installation varies by operating system, but Linux and Mac systems typically only require a single command. Installing it on Windows is slightly trickier, as you have to use the Windows Subsystem for Linux (WSL) feature that premiered in Windows 10.

Installing tmux on Linux

Installing tmux on Linux uses sudo, but the following commands differ by distribution:

Ubuntu/Debian

sudo apt-get update
sudo apt-get install tmux

Fedora

sudo dnf -y install tmux

CentOS

sudo yum -y install tmux

Nixpkgs or NixOS

If you have Nixpkgs installed on Linux, macOS, or Windows WSL2, you can use the following command:

nix-env -iA nixpkgs.tmux

For NixOS, you can instead add programs.tmux to your configuration.nix file, optionally with some changes to the defaults:

  # tmux
  programs.tmux = {
    enable = true;
    shortcut = "a";
    baseIndex = 1;
    keyMode = "vi";
    secureSocket = false;
    clock24 = true;
  };

You can then just sudo nixos-rebuild switch to install and configure tmux.

Installing tmux on macOS

The easiest way to do this on a Mac is to use Homebrew. I highly recommend installing this package manager if you haven’t already. It makes life so much easier.

brew install tmux

Installing tmux on Windows

To get Windows to run tmux, you’ll need to install WSL and a Linux distro first.

The first step is to install WSL or WSL2, the upgraded version. To install WSL2, you’ll need to be running on Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11. Older builds of Windows can’t use WSL2, but may be able to manually install WSL.

A single command in Windows PowerShell or command prompt will take care of just about everything: enabling required components, downloading the latest Linux kernel, and installing Ubuntu for you:

wsl --install

You can change the Linux distro that will be installed by using the -d flag, followed by the name of the distro. You can see a list of the currently available distributions with this command:

wsl --list --online

You’ll have to import the distro manually if you want to use one that isn’t listed.

The next step is to create a username and password that you’ll use in Linux. Click your Start menu and open your Linux distribution. You may have to search for it.

Finding the new Ubuntu install on Windows.

Once it’s finished unpacking the files, Linux will prompt you to enter a username and password. Now that you’ve got a Linux distro up and running, the next step is to update your packages:

sudo apt update
sudo apt upgrade

Running the following Linux command will install tmux:

sudo apt install tmux

Congratulations! You have successfully installed tmux on Windows. 😅

To start tmux, open your terminal and let fly with this:

tmux

You’ll now see a single tmux window with just one pane and a status bar along the bottom. The status bar displays information about the current tmux session, including the name of the current session, the window numbers and the running process in their active pane, which window is active (*), the name of the host, and the time and date.

A screenshot of tmux showing the status bar.

As you’ll see later, a lot of the default tmux configuration can be changed.

Command Structure

Before diving into exactly how to use tmux, let’s take a moment to look at how it structures commands. All tmux commands consist of a prefix followed by a command. The most common prefix you’ll use with tmux is Ctrl+b. In all cases, you can press Ctrl+b instead of typing tmux within a tmux pane.

The default prefix is an awkward combination of keys. A lot of people (including me) configure tmux to use Ctrl+a instead. You can do this by adding these lines to your ~/.tmux.conf file:

unbind C-b
set -g prefix C-a

From this point forward, we’ll use Ctrl+a when referring to the prefix. If you decide not to remap the prefix, make sure to use Ctrl+b instead,

Sessions

Sessions are basic to tmux. Sessions can consist of multiple windows, any of which may have multiple panes. The active window is called a notion.

By starting tmux with the tmux command, you are starting a new session. The sessions are numbered by default, starting with 0. As shown in the cheat sheet below, you can create a named session instead by using the -s flag and following it with the session name.

tmux new -s [name]

You’re not required to give your sessions a name, but the default numbering does make it hard to keep track as your list of tmux sessions grows. You can rename existing tmux sessions using the rename-session command and the -t flag. That flag tells tmux to target-session.

tmux rename-session -t [old name or number] [new name]

For example, we can use this to rename our first session from 0 to something more descriptive.

Renaming a session in tmux.

As you can see in the bottom-left, the session has been renamed to learning.

Instead of typing out the entire command, like with most commands in tmux you can use a shortcut. In this case Ctrl+a and $ will get you a prompt to rename the session.

You can have multiple sessions running in the same terminal at the same time. The easiest way to create a new session is with the command tmux new-session. However, this will create a new session with default numbering. It’s better to use the -s flag and give our new session a descriptive name:

tmux new -s practice

Those sessions will continue to run until you close them with the kill-session command. You can see all the running sessions with tmux ls.

A view of the sessions in tmux.

To switch sessions without having to first detach, use Ctrl+a and s, and then select another session with arrow keys and Enter. You can also select the required session directly by entering its displayed number.

A view of tmux showing sessions and the number of windows in each session.

Attaching and Detaching

You will automatically attach to a new session when you start it. To reattach to an existing session, use the attach-session command, followed by the -t flag to target a named or numbered session:

tmux attach-session -t [session name or number]

As a shortcut, you can quickly attach to the last session you were using by not providing the -t … flag. In fact, tmux is very good at guessing what command you’d like to do and often the first letter or two of the command will be enough.

tmux a

To detach from all sessions, use tmux detach or press Ctrl+a followed by d. To detach from just the current session, you’ll have to target that session specifically with the -s flag:

tmux detach -s [session name or number]

Remember, detaching from the session does not stop any running process. Everything will continue to run until you stop the process or kill the session. You can end any active session by pressing Ctrl+a and x, and then y.

To kill all sessions, use the kill-server command.

tmux kill-server

Windows and Panes

Windows and panes are how you use tmux to its full potential. Panes are the part of a window where we run processes, commands, and scripts. So far in this tutorial, we’ve only used one window with a single pane. One of the great things about tmux is that you can run multiple processes at the same time, while keeping an eye on both because they’re in different panes in the same window.

You can split windows into panes either horizontally or vertically. To create two vertical panes, press Ctrl+a followed by %.

Splitting panes in tmux.

You’ll now have a new pane to the right of the first one. You can continue to split panes, either vertically with the command above, or by pressing Ctrl+a and to create horizontal panes.

Further pane splitting in tmux, this time splitting the right-hand pane horizontally.

I created a vertical split followed by a horizontal split, but you can set it up any way you like. By default, tmux activates the cursor in the most recently created pane. Navigate between them with a combination of Ctrl+a and your arrow keys. For example, if you want to move to a pane to the right, you would press Ctrl+a followed by . To go to the next pane, you can use Ctrl+a followed by o. Using Ctrl+a and ; instead toggles between the current and previous panes.

You can also navigate by using the pane numbers. Pressing Ctrl+a and q will very briefly show the pane numbers. Enter the number while it’s still being displayed, and you’ll automatically switch to that pane. This is a good test of your reflexes, but it’s actually one more keystroke than just using your arrow keys.

Three panes in tmux with pane numbers displayed.

Personally, I want even faster pane navigation, so I’ve configured tmux to enable Alt+arrow-key for switching panes by adding the following to my ~/.tmux.conf file.

# Use Alt-arrow keys without prefix key to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

To close a pane, use the exit command or press Ctrl+d. Doing this in the last open pane will exit tmux completely.

Resizing Panes

You can change the relative size of each pane. Naturally, increasing the size of one pane may cause others to shrink in proportion.

To change pane size, navigate to the correct pane and press Ctrl+a followed by :. Your status bar will change from green to yellow. You can then use the following commands to change the boundary lines of that pane. Note that you’re limited by the bounds of your terminal. For example, resizing a right-hand pane by moving the boundary line to the right will not work, as there is no space for the pane to expand into.

  • resize-pane -R: Expands the pane to the right.
  • resize-pane -L: Expands the pane to the left.
  • resize-pane -U: Expands the pane upward.
  • resize-pane -D: Expands the pane downward.

However, as that’s rather slow and laborious, tmux has a few key bindings configured by default for resizing quickly.

  • Ctrl+a Ctrl+arrow-key: Grows or shrinks the pane by 1 column or row.
  • Ctrl+a Alt+arrow-key: Grows or shrinks the pane by 5 columns or rows.

If you hold down that Alt key and mash the arrow key a few times, it’ll keep on resizing the pane without having to hit the Ctrl+a prefix again.

Navigating Between Windows

Use Ctrl+a and c to create a new window (think tab) in the current session. You will automatically switch to the new window when you create it.

You can navigate to another window by pressing Ctrl+a followed by the window’s number as displayed in the status bar, or switch to the next window with Ctrl+a and n. Entering Ctrl+a and p will take you back to the previous window.

To quickly toggle back and forwards between two windows, use Ctrl+a and l (that’s lowercase L, for “last”). You can tell which window is the last one by “-” following its name in the status bar, just like how the current window has “*” after its name.

A view of tmux showing currently selected and previous windows.

You may find while using tmux that you need to switch between windows across sessions. You can do this by pressing Ctrl+a followed by w to display a list of the current windows. It will not display windows for detached sessions. You can select the window you want by scrolling through the list with your arrow keys.

The list of open windows in tmux.

It can get a little confusing seeing a whole bunch of windows with just a number and : bash in the status bar. So you can rename the current window with Ctrl+a and ,.

Renaming the active window in tmux.

In the following screenshot you can see the result of naming both windows to reflect the projects they’ll be used for.

tmux showing two renamed windows.

Basic Commands Cheat Sheet

Below you’ll find a cheat sheet with the basic commands you’ll use most often with tmux. To see a complete list of all the keyboard shortcuts in tmux, press Ctrl+a followed by ?.

Command Description
tmux Starts tmux from the Mac Terminal or Linux.
tmux new -s [name] Starts a new named tmux session. Replace [name] with the name of your session.
tmux a # Attaches to a numbered session. Replace # with the number of your session.
tmux a -t [name] Same as above, but used with named sessions.
tmux ls Shows the complete list of all tmux sessions.
tmux kill-session -t [name] Closes the named session. Note that this is different from detaching from a session.
Detaching from a session will leave processes running.
exit Exits tmux without detaching from any sessions.

Why Use tmux Locally?

Using tmux on a remote server means internet connection problems may interrupt your work, but they won’t interrupt the processes you’re running. Given that connection issues can’t stop me using the command line on a machine I’m sitting right in front of, why do I use tmux locally? The biggest advantage is that as soon as I start my terminal emulator, my preferred command line workspace is waiting and ready to go.

In the video above, you can see me firing up Alacritty (my terminal emulator), having shown that there was no other terminal emulator open beforehand. I was able to attach to my already running “dev” tmux session, switch to another window, switch to my “dbi” session, and then check on the still running WP Offload Media acceptance tests I kicked off earlier. If you look closely you’ll notice windows still there for WP Offload SES development, WP Migrate testing, and working with various storage providers. Everything was just as I left it, even though there was no previously open terminal emulator window.

I have a tmux window for each of the projects I’m currently working on. Each of those windows generally has at least a couple of panes where the current working directory is within the project’s source tree or related folders. I hop between the projects with a quick Ctrl+a N, where “N” is the number of the window. So to get to my WP Offload Media stuff I just hit Ctrl+a 2.

On my “admin” window I usually have htop open in one pane as it’s handy for quickly seeing what’s hogging my machine’s resources if things start getting slow. Otherwise, the other two panes are generally used for updating my .dotfiles, reading man pages, or general support stuff like curl -I https://cdn.example.com/some/customers/bucket/object.png.

Before using tmux, when I still used a Mac, I used Magnet for rearranging terminal windows after MercuryMover went away. It wasn’t ideal for getting things set up nicely. Trying to get to a specific window quickly without having to resort to my trackpad was nearly impossible, and I’ve always struggled to get tiling terminal emulators to work how I like.

The great thing is tmux acts more like a tiling window manager, giving you lots of ways to get to your panes in a window, and rearrange them to suit your workflow. If you’re trying to reduce how much you use a mouse or trackpad, you’ll be very happy.

In fact, after using tmux for just a little while, I started looking at tiling window managers on my Linux machines. I used the excellent Qtile window manager for quite a while, but these days I tend to use i3-gaps. This led to using a tiling window manager on macOS too! Eventually though, I couldn’t resist switching to Linux full time, and now I use NixOS with the aforementioned i3wm fork for my desktop. So be warned, using tmux day in, day out, could lead you to massively improving your entire desktop experience! 😂

What Happens When You Reboot?

“Okay smarty pants, what happens when you reboot your machine and that tmux session dies? Where’s your nice comfortable multi-window workspace now?”

Let me introduce you to my very favorite tmux plugins, tmux-resurrect and tmux-continuum.

In the video, I willfully kill my beloved “dev” and other tmux sessions, create a new session with tmux new -s dev, and by pressing Ctrl+a and Ctrl+r, I resurrect my previous sessions to how they were before I killed the tmux server.

It’s incredibly useful to have all my shell sessions restored with the current working directories as I left them. And as seen in the video, if there was a program running that tmux-resurrect deems safe to restart like htop or vim, then they come back to life too!

Resizing and Zooming Panes

Another thing I love about using tmux as my primary means of accessing the command line is its excellent support for resizing. I discussed this briefly while outlining the commands, but it’s worth mentioning again.

tmux resized alongside other windows.

In the above screenshot my main local terminal window now only takes up half of the screen, there’s two other terminals open in the other half, one logged into a server created with SpinupWP, and the other my ancient iMac.

Even with the bumped up font size I’ve used for your viewing pleasure 😉, tmux has smoothly resized its panes and kept all the ratios intact, and by switching to “horizontal” layout with Ctrl+a and Alt+2, my super long command prompts aren’t disturbed. 😄

If I want to see more of a pane while still keeping the window a little more cramped than normal, I can zoom the current pane with Ctrl+a and z.

tmux resized alongside other windows with zoomed pane.

I love that feature. It’s great for quickly reviewing log files, etc., with long lines that would normally wrap in a smaller terminal pane.

Vim Key Navigation

I’ve been using Vi and Vim for over 25 years now, so it’s how my hands do text editing. Apart from using Vim for general text editing, I generally use “vim mode” in everything I can, including in my IDE and the bash command line.

As such, it’s great that if I want to scroll back up or move around in the output of my current tmux pane, I can simply hit Ctrl+a and then use the usual Vim keys for navigation without leaving the keyboard.

Wrapping Up

Hopefully that’s enough of an overview of why I think tmux is the bee’s knees for not just remote command line work, but also on your local development machine.

If you haven’t tried tmux yet, what are you waiting for?! If you give tmux a go for the first time let us know how you get on in the comments, and if you’re already a daily tmux user why not share your tips in the comments too?

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Sfc scannow windows 10 dism
  • Как настроить микрофон на windows 10 от наушников на компьютере
  • Dns сервер не отвечает windows 2012
  • Соединение с телефоном windows 10
  • Canon lpb2900b драйвер windows 10