How to run Tmux in GIT Bash on Windows

Tmux running under Git Bash default terminal with two shell processes

I know everyone uses Cmder, but it didn’t work for me. It hung a few times, it has way too many options, it has issues sending signal to kill a process. I gave up on using it. I work with carefully configured default Windows console and believe it or not, it serves the purpose. I also know you can use Windows Subsystem For Linux under Windows 10, which is truly amazing, but I am just talking about the cases where you need standard Git for Windows installation.

When I worked with Unix I liked GNU Screen, which is terminal multiplexer. It gives you a bunch of keyboard shortcuts to create separate shell processes under the same terminal window. The problem is, it is not available under GIT Bash. But it turns out, its alternative — Tmux is.

I did a little research and have found that GIT Bash uses MINGW compilation of GNU tools. It uses only selected ones. You can install the whole distribution of the tools from https://www.msys2.org/ and run a command to install Tmux. And then copy some files to installation folder of Git. This is what you do:

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

And you are ready to go. Please note, that I do this on 64-bit installations of Git and MSYS . Now when you run Git Bash enter tmux. My most frequently used commands are:

  • CTRL+B, (release and then) C — create new shell within existing terminal window
  • CTRL+B, N — switch between shells
  • CTRL+B, a digit — switch to chosen shell by corresponding number
  • CTRL+B, " — split current window horizontally into panels (panels are inside windows)
  • CTRL+B, o — switch between panels in current window
  • CTRL+B, x — close panel

This is everything you need to know to start using it. Simple. There are many other options which you can explore yourself, for example here http://hyperpolyglot.org/multiplexers.

Update 1: Users in comments are reporting the method not always works. If you have any experiences with this method please feel free to comment, so that we can figure out what are the circumstances under which it works

Update2: I managed to run this on Windows 7, Windows 2012 R2 and Windows 10. My Git installation is set up to use MinTTy console and tmux works only when run from this console, not from default Windows command line console. Still haven’t figured out what are precise requirements for this trick

5 comments

  1. bokwoon says:

    Thanks for this! However I was unable to get tmux to work by simply copying tmux.exe and msys-event-2-1-4.dll over. Unsure of what else I was missing, I ended up brute force copying my entire mysys64\usr\bin into PortableGit\usr\bin and it worked. It’s not pretty, I’m still wondering which packages I was missing :/

  2. ddo says:

    hi @pjsen and @bokwoon, still not working tried both of you methods. I’m not missing something (sad face)

    • pjsen says:

      That’s interesting why it doesn’t work. I did some extra tests, I clean-installed newest version of Git for Windows 64-bit under VM and copied those two files. It works. You probably are getting messages about missing files. What are those messages? What is your bitness of MSYS installation and Git installation?

      • Micc says:

        Hi, I’ve meet the same problem.
        I’ve installed MSYS2, upgrade packages by ‘pacman -Syu’ and ‘pacman -Su’, then finally get tmux installed.(I can use it in MSYS terminal).
        But after I copy those files(tmux.exe and msys-event-2-1-6.dll) into git folder(C:\Program Files\Git\usr\bin), I tried tmux in git bash but nothing happened(no console, only switch to a new line).
        Btw, I’m using win10 and Git bash 2.19.0-64-bit.
        Thanks for your sharing!

        • pjsen says:

          I’ve done my tests under Windows Server 2012 R2 and Windows 7. I’ll do also on Windows 10 and then update the post accordingly. But still, in my opinion, there is no point using this trick under Windows 10, where you can work with native Linux binaries of Git and whatever console multiplexer you want.

Leave a Reply

Your email address will not be published. Required fields are marked *

Protection against spam * Time limit is exhausted. Please reload CAPTCHA.