Skip to content

Instantly share code, notes, and snippets.

@DeanPDX
Last active October 12, 2024 13:54
Show Gist options
  • Save DeanPDX/acff533cff0cfbda2761d1e62e8cb1a7 to your computer and use it in GitHub Desktop.
Save DeanPDX/acff533cff0cfbda2761d1e62e8cb1a7 to your computer and use it in GitHub Desktop.

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"
@mohnasir-gh
Copy link

Gettting this error after adding following the steps
image

@DeanPDX
Copy link
Author

DeanPDX commented May 21, 2024

@mohnasir-gh did you copy both DLLs to C:/Git/bin/?

@nhanlun
Copy link

nhanlun commented May 22, 2024

Hi, this seems to not work for Windows Terminal. Does anyone suffer the same issue? After copying the msys-event and tmux file, normal git bash can start tmux but not windows Terminal

@akhilsahuji
Copy link

I have done all the steps according to the plan. but it is giving error open terminal failed: not a terminal .

Quoting from this answer:

It sounds like the terminal you're using doesn't support full tty emulation. Clients like mintty (comes with Cygwin---or should, anyway), putty, rxvt for Windows, &c. will handle that. CMD, ConEmu, and Cmder won't.

What terminal are you using?

it only works with git-bash.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment