vitorbaptista / shellshare

Live terminal broadcasts
https://shellshare.net
Apache License 2.0
224 stars 23 forks source link

Initial version of MSYS2 and mintty support #63

Closed mikerenfro closed 4 years ago

mikerenfro commented 4 years ago

Thanks to @dpshelio 's bash script and some earlier attempts at supporting Windows, I think I've got something workable for people using Git Bash and mintty on Windows. Fixes include:

Tested with:

Once downloaded, ran python shellshare to start the subshell, and then ran nano, date ; sleep 5 ; date, winpty python, or winpty ipython to verify that Ctrl-C and other control characters were passed, and that tab completion worked.

I've had problems with my initial Windows test environment with winpty ipython, but at least two other testers haven't been able to reproduce my problem. I'll try to stand up a second environment to see if I can replicate my problem. I may also look at what it takes to adapt this to the regular Windows Command Prompt instead of mintty.

mikerenfro commented 4 years ago

@dpshelio @vitorbaptista I've reworked this to use urllib, and successfully ran this under Git Bash with:

If you see any other changes to be made, let me know

vitorbaptista commented 4 years ago

Hi @mikerenfro, thanks a lot for the PR and sorry for the delay, I lost access to my GitHub account for some time.

I'm a bit cautious with installing dependencies automatically. Maybe that could be part of the instructions instead? We could host busybox.exe directly on this repository, so people don't need to download a tar, extract and pick the correct file. it's already on https://get.shellshare.net/script.exe, for example.

If Windows has a CLI tool to download (like wget or curl) installed by default, we could write an one-liner to install script.exe. Otherwise we could simply add it to the FAQ.

What do you think?

mikerenfro commented 4 years ago

No problem. I've got so many outstanding PRs over the last month or so, and you're the first one to get back.

My original use case for shellshare is for Software Carpentry workshops taught remotely, where I'd have a lot of users using Git Bash for Windows, which is basically a small MINGW64 environment plus Git.

Having an extracted script.exe available at a predictable URL would simplify things considerably, in that it would remove a dependency on a working tar. It's a non-issue for my original MINGW64 environment, but it would be pretty important if I ever extend shellshare to support a PowerShell terminal window.

MINGW64 appears to have curl by default, but not wget. If and when I get to seeing if this can work in a regular Windows command prompt or in PowerShell, both wget and curl are aliases for Invoke-WebRequest, and don't appear to be 100% compatible in terms of command-like parameters. But if we do the downloading with Python's urllib like I've got now, that shouldn't be an issue in any Windows environment.

If we wanted to reduce the chance of modifying a MSYS2 user's environment unnecessarily, we could download your copy of script.exe to ~/.shellshare/script.exe instead of ~/.bin/shellshare.exe. And this PR already calls that copy of script.exe directly instead of modifying the user's PATH variable and having them log out and back in again, which was the method used in one of the earlier versions from @dpshelio . Especially for Software Carpentry workshop attendees, I'd rather reduce the amount of setup instructions as much as possible.

As it is currently, we've got a single working one-liner of curl -sLo shellshare https://get.shellshare.net && python shellshare that works on:

PowerShell would need a slightly different set of instructions, since curl doesn't work quite the same, and it only added support for the && operator as of version 7 in March 2020. But I'm more than willing to put off or abandon thoughts of PowerShell support if it deviates too far from the other environments.

But if all this works for now, the next place I'd work on is validating Git Bash for Windows for both MinTTY and the regular Windows Console.

mikerenfro commented 4 years ago

@vitorbaptista did you move script.exe somewhere else? Trying to get it from the URL you provided, and I get the shellshare Python script instead.

vitorbaptista commented 4 years ago

@mikerenfro The https://get.shellshare.net/script.exe doesn't exist yet, it's just an example of where we could put the necessary binaries, so it's easier to download shellshare's dependencies.

Could you:

Then we can merge this PR and release a new version (finally!) :tada:

mikerenfro commented 4 years ago

Checking back in with @vitorbaptista .

vitorbaptista commented 4 years ago

@mikerenfro Thanks a LOT for your work and patience. Your PR is merged and I deployed a new version 1.1.0. Could you try it out and confirm things are working as expected?

Also, I took the liberty to change your code a bit on https://github.com/vitorbaptista/shellshare/commit/7a7483050e05eb670b6c45b4e175462f27dd585d and https://github.com/vitorbaptista/shellshare/commit/4fc5328338b67abbea6a4808cdc3bbe05781a9a3. Let me know if you see any issues with these changes.