Skip to content

Instantly share code, notes, and snippets.

@tkon99
Last active December 20, 2023 14:06
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tkon99/7ea5202819ef026d66e484bcc2469d2b to your computer and use it in GitHub Desktop.
Save tkon99/7ea5202819ef026d66e484bcc2469d2b to your computer and use it in GitHub Desktop.
Use Mosh on Windows from the Command Prompt

Hi all. After wanting true color support in Mosh (to use Brow.sh), I also wanted to integrate it more tightly with Windows. Since I reckon more people will be wanting to accomplish this, here is a guide.

  1. Install Linux Subsystem for Windows if you haven't already (https://docs.microsoft.com/en-us/windows/wsl/install-win10) (I use Ubuntu)
  2. Make sure you can execute bash from a CMD prompt.
  3. Go into the bash environment by executing bash ~ in CMD prompt
  4. Install Mosh-dev (for up-to-date version) from https://launchpad.net/~keithw/+archive/ubuntu/mosh-dev by doing sudo add-apt-repository ppa:keithw/mosh-dev then sudo apt-get update
  5. Create a new mosh.bat file on your Desktop with the following contents
@echo off
bash ~ -c "mosh %*"

This launches a Linux bash and passes all the arguments you passed to the batch file on to the mosh program there.

  1. Place the mosh.bat file somewhere in your Path (I ended up making a C:\bin\ directory, putting it there and adding that to my path)

You should now be able to just open a CMD window and type mosh your.server.com and it should appear in the same window, as if it was running on Windows directly.

@eksiscloud
Copy link

Is it easier just do wsl mosh user@server?

@serokellcao
Copy link

@eksiscloud,

In my experience, wsl doesn't play too well with terminal emulators I use.

Even for local development I ssh localhost rather than wsl.

@iAmG-r00t
Copy link

I found this method abit off , so check this out

@lifei
Copy link

lifei commented May 10, 2023

No need.

  1. Go to project fluent terminal, and just clone it to local disk. you will find a file named mosh-client.exe.
  2. Install mosh on a linux machine. copy the file with path /usr/bin/mosh. it's a perl script.
  3. put them in your PATH, you would use mosh on Windows natively.

@tkon99
Copy link
Author

tkon99 commented May 10, 2023

@lifei have you confirmed that this works with true color?

@lifei
Copy link

lifei commented May 10, 2023

you should do some small fix. edit the mosh perl script, find $colors = 0, makes them to $colors = 256

@lifei
Copy link

lifei commented May 10, 2023

that's because mosh-client -c print nothing.

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