curusarn / resh

RESH ❯❯ Contextual shell history for zsh and bash
MIT License
1.01k stars 19 forks source link

Windows Support (MSYS2/git bash) #178

Open ciarancourtney opened 2 years ago

ciarancourtney commented 2 years ago

If the prerequisites are 'Standard stuff: bash(4.3+), curl, tar, ..' the MSYS2 Bash shell, or the minimal one that comes with Git for Windows, should satisfy these requirements.

curusarn commented 1 year ago

Hi, RESH works in WSL on Windows.

My guess is that MSYS2 Bash and shell in Git for Windows is not actual bash so it won't likely have all the bash features RESH needs.

If you want to, you can clone the repo and try to build and install RESH from source in MSYS2 or Git Bash. (git clone, cd into the directory, and make install) If you see that it works then we can add windows to the installation and build.

ciarancourtney commented 1 year ago

Thanks @curusarn I started a branch on my fork will minimal changes to allow install on windows, and noted the following:

  1. On init, the following errors are output to terminal
resh PANIC unrecognized OS
resh-session-init ERROR: 2022/12/19 11:54:59 Flag Parsing error (rt sess boot):strconv.ParseFloat: parsing "": invalid syntax
  1. The TUI works as expected, but its very slow, and slows down all terminal commands significantly.
  2. The parsing error above is written on startup and shutdown of resh, on shutdown the PS1 is bare until you hit ctrl+c again.

In summary I think the biggest hurdle is the perf impact, do you think the bottleneck is in shell or go?

curusarn commented 1 year ago
  1. resh-session-init ERROR: 2022/12/19 11:54:59 Flag Parsing error (rt sess boot):strconv.ParseFloat: parsing "": invalid syntax

This error looks like the way Resh gets current time fails. Is date command available in MSYS2 bash? What does executing date +%s print?

The TUI gets a little slow when the searched history is very large (e.g. very large preexisting bash history). Could this be the case? How many lines in your bash history?

What do you mean by ... and slows down all terminal commands significantly.? How does the TUI slow don all terminal commands?

Resh does add some "invisible commands" to PS1 to be able to record history with directory, time, status, etc. I'm wondering if it the history recording works at all if the prompt gets broken. Can you check that commands are being recorded to Resh history?

This is how you can test it:

You should see the echo "we want to see this in resh history" in the output.

In summary I think the biggest hurdle is the perf impact, do you think the bottleneck is in shell or go?

Go should work the same on all platforms so the it shouldn't be slower on Windows than it is in WSL, on Linux or macOS. So based on that I would suspect shell to be the cause of the slowdown. There can be differences how the shell behaves between platforms.

ciarancourtney commented 1 year ago

This error looks like the way Resh gets current time fails. Is date command available in MSYS2 bash? What does executing date +%s print?

Yes, its the proper GNU date, so it prints the same seconds as on Linux.

What do you mean by ... and slows down all terminal commands significantly.? How does the TUI slow don all terminal commands?

I'm pretty sure its the PS1 manipulation thats causing the slowdown. My bash history is 5000 lines for reference.

curusarn commented 1 year ago

Hi @ciarancourtney,

I have released RESH beta version: https://github.com/curusarn/resh/releases/tag/v3.0.0-rc2 In v3.0.0-rc2, I have eliminated some dependencies which might fix the date parsing errors. It also has prebuilt binaries for Windows.

The install script and shell files still don't recognize Windows so you will need some patches but the binaries are there.

Let me know if this helps.