Tmux support arrives for Bash on Ubuntu 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!

For those not familiar with it, Tmux is a terminal multiplexer - a popular (even essential) command-line tool that allows one to divide a console/terminal window into multiple "panes" and render the output of a shell and/or tool in each "pane", and to switch input between each pane.

Tmux relies on a *NIX feature called Pseudo Terminals (PTY) that are attached to a process running a shell/tool, and which virtualize the behaviors of a terminal. A physical terminal (TTY) can then be attached to any PTY ... or more than one in the case of Tmux: Tmux "attaches" each "pane" it contains to a separate PTY, allowing a single console/terminal to render the output of several *NIX tools in their own "pane" within the console.

To start, let's open Bash on Ubuntu on Windows and install Tmux using apt-get:

1-install

We start Tmux by running ... well ... tmux 🙂 This will clear your screen and add a (customizable) status bar to the bottom of the screen.

2-run

First, let's split the current pane vertically using [CTRL B] + [%]:

3-split-v

Now let's split this new pane horizontally using [CTRL B] + ["]

4-split-h

Cool! So, using [CTRL B] + [Arrow-key | P | N] we can navigate between panes. Let's return to the left-hand pane and open a file in vim (e.g. "vim hello.cpp" in this case):

5-vim

If we now navigate to the top-right pane again, and run "htop", we can see a textual process monitor:

6-htop

Move to the bottom-right pane and run "fortune | cowsay" (install using apt-get if they're missing), and you can see a cow read out the fortune cookie message of the day 🙂

7-cowsay

Three panes just aren't fancy enough, so let's split the left hand pane again: Navigate to the left pane using [CTRL B] + [Arrow-key] and hit [CTRL B] + ["] to split horizontally.

Now run "cacademo" (install using apt-get install caca-utils) and you'll see a selection of crazy swirling and dripping text-effects!:

8-split-cacademo

This is just a taste of what Tmux can do, but as you can imagine, its an amazingly powerful multi-paned terminals within a terminal tool that you can use to build dashboards of tools to suit many of your geeky needs!

Enjoy!

Comments (58)

  1. Michael says:

    AWESOME! One question: when is this going to be available for PowerShell? 🙂

    1. Bear with us – this potential future feature is on our backlog.

  2. Bart says:

    This is incredible! Can the team that implemented this please, please write “psmux” for the Win32 console so that we can do the same in PowerShell?

    1. Bear with us. This potential future feature is on our backlog.

  3. davidacoder says:

    This is cool. Now, it would be even better if there was something like that for normal powershell terminals. Just ANY way to simply open multiple powershell sessions in tabs or something would be great.

    1. Bear with us: This potential future feature is on our backlog.

    2. Mipa says:

      Install ConEmu and you’ll get tabs, splits and much more

      1. ConEmu is a great alternate terminal client, but sometimes, all you want/need are a few tiled console panes 🙂

  4. awesome_sauce says:

    this is awesome. thank you so much

  5. Stu says:

    Fantastic 🙂 Can X gui programmes work here, if using a Windows XServer ?

    1. While some do, we’re not supporting X GUI apps: We’re focusing on delivering a solid command-line tools experience in this first instance.

  6. Evan Rowley says:

    Exciting! Tmux is one of my favorite programs. I’m very interested to see how using it on WSL will differ from my experience on other operating systems.

  7. Wen says:

    AWESOME!

  8. Josh says:

    Aaaaaaand…. PCs just became viable dev machines for me. Thanks!!!

    1. Glad you like it 🙂

  9. kan says:

    Wow! My favorite xterm runs well.

    1. Great to hear 🙂 Thanks for sharing!

  10. n3wjack says:

    If you’re dying to have this kind of split window functionality right now on Windows using Powershell then you should check out ConEmu(http://conemu.github.io/).
    It has this feature for quite a while already, including tabbed consoles and a bunch of other really useful enhancements.

    1. Agreed! We’re fans of ConEmu and users who want a very flexible console client should definitely go take a look 🙂

  11. Kyle says:

    create a text file with the contents “tmux new-session -s test ls” – save as tmux.txt
    from an elevated windows command prompt run “bash tmux.txt”
    ls will execute inside tmux, but you cannot escape nor exit from tmux. Killing it through windows results in you not being able to use bash until after a restart. (if there is other magic that would not require a restart, please advise).

    1. Tried to repro your issue, but could not. in fact, when running “bash -c tmux new-session -s test ls”, for example, bash executes the required command and then exits back to the cmd shell.

  12. mobluse says:

    [CTRL B] + [Arrow-key] works, but not [CTRL B] + [P | N] or [CTRL B] + [p | n]. [CTRL B] + [o] works to toggle pane. Any idea why the commands to split a pane are called ‘%’ and ‘”‘?

    1. CTRL+B – [p|n] is something we’ll take a look at in the future.

      Tmux defaults to % and ” to split panes – that’s a default Tmux keymapping – you can customize this if you wish.

  13. Matt Freeman says:

    Is ZSH support on the roadmap? Preferably that can work with https://github.com/robbyrussell/oh-my-zsh?

    1. ZSH should work pretty well already. Let us know if you find problems.

  14. Chris says:

    Ctrl-b does not work for me. Does anyone else have this problem?

    1. You have to run tmux first … if you see the green status bar, you should be able to [CTRL] + [B] …

      1. Chris says:

        I am running the tmux command from the new bash terminal and the full tmux commands work fine, but the shortcuts do not.

        1. What happens when you CTRL + B and then hit [Shift] + [“]? You should see your console split in half horizontally.

          1. Blake says:

            Ctrl+b commands to split the window and panes aren’t working for me either… I was able to split the window vertically once by pressing Shift+% (I think) but otherwise I don’t get any response. Looks like I’m running tmux just fine however.

          2. Run TMux first, then hit [CTRL] + [B] … then release … then hit [Shift] + [‘] to split horizontally, or [Shift] + [%] for vertical split.

          3. Blake says:

            Thanks Rich, that works! Pretty nice to have a real terminal on here, like a lot of folks I had gotten used to ConEmu and was not enthused about having to open a ton of different bash shells on WSL. Very handy feature!

  15. Ben Grawi says:

    If I create a session and then detach from it and close bash, it normally would continue running in the background on Linux, but in WSL it says there are no active sessions when I restart bash. I assuming they were killed when bash was ended which should not happen.

    1. This version of Bash on Windows is only built to support developer scenarios, not server scenarios: To ensure that a Bash shell doesn’t end up running in the background consuming considerable resources, we shut down the Bash/WSL instance once the last console session ends.

      1. Kan Li says:

        I would love to see some option not to kill programs running inside tmux even if I close every window. Compared to the extra resource it is taking, and I am more cared about not to lose my work if I accidentally close my terminal window.

        1. We are looking into this scenario for a future release.

          1. hypothesis says:

            Really really thank you for supporting screen and tmux!
            Detached sessions is very common scenario for a developer, it’s not only for running server applications.
            Other scenarios are leaving some work half done in the editor, monitoring tools like top and htop, compiling or running some work at background.
            Please reconsider closing all processes that started in bash after last bash has been closed. x64 platform is powerful enough to provide memory and handles for linux processes to use.
            Feedback has been reported.

          2. Thanks for your feedback. We are looking at running background tasks and daemons etc. but are taking a very careful approach: The last thing we want is for some users to experience perf’ issues, for example, because there’s a Linux process running in the background consuming large amounts of IO, RAM and CPU which the user has forgotten-about or didn’t realize was running. Bear with us though – this is an important capability for us too 🙂

          3. Kyle Studd says:

            +1 for being able to maintain tmux sessions after closing Bash. Please stop trying to protect users from themselves, if we forget about something that should be our fault, not yours. I’m a “developer” and I really need this support, it’s the only reason I use tmux/screen. K thanks bye!

          4. Appreciate your feedback Kyle. When one’s customer base consists of 1.5Bn people from every walk of life, spanning the entire range of experience, one has to be a little careful. Since now allows us to run “foreign” applications atop a brand new runtime, it benefits everyone that we tread very carefully. Bear with us while we continue to improve our breadth and depth of implementation, and as we improve our manageability, and support for features like background tasks, daemons, etc. We’re keen to build these features, but need to do so responsibly in order to maintain our user’s trust.

  16. Mohammad says:

    Hey guys, I cant install this

    sudo apt-get install clicompanion
    E: Unable to locate package clicompanion

    1. As per the Ubuntu documentation on CLI Companion, you have to add a PPA in order to install via apt-get.

  17. Nicolas Carlier says:

    Does it planned to support screen ? Despite the fact screen is installed, creating /var/run/screen/ and changing the mode to 777, I m not able to use it.

  18. Derek says:

    This is terrific – curious about whether this pseudoterminal support extends to screen as well. I’ve been trying to get screen running without much success..

  19. Stelios says:

    Instead of Tmux, I would like to use “screen”, when it start its, i get the following message:

    [screen is terminating]

    Why? and How can i fix it?

  20. Bo says:

    This is just awesome!! One next feature which I think as necessary is multiple tabs. There are certain scenarios that multi-tabs is much more useful than multi-panels. Though, they are both excellent!

    1. Bo says:

      I have to take some of my words back. tmux support multi-tabs in another way: multi windows. That’s pretty close to what multi-tabs can do. So great work guys! I like it soooo much.

  21. Uma says:

    Awesome! How can we add our own .tmux.conf ?

    1. Eermmm … vim ~/.tmux.conf?

  22. YuriCuri says:

    Hello, thanks for tutorial, however CTRL+B+% or ” doesnt work for me. I can’t split the screen, its driving me nuts.
    Can you please help?

    1. YuriCuri says:

      nevermind, found the results above in the comments, sorry didn’t read all of them.

    2. Try hitting CTRL + B, then let go of both and then hit SHIFT + 5

  23. Oleksii says:

    Hi Rich,

    Thanks for a great tutorial!

    Did you know how to enable ‘alt’ key support in tmux on windows bash?

    I am trying to use my tmux config from ubuntu to windows bash and have found that tmux does not handle ‘alt’ keys (M- bindings)…

    1. I’ve not looked into that – if none of the online tutorials cover your needs, be sure to file issues here: http://github.com/microsoft/bashonwindows.

Skip to main content