Git Product home page Git Product logo

Comments (9)

rfgamaral avatar rfgamaral commented on May 28, 2024 4

Made two small improvements and fixed a new found issue at the same time:

Forced WSL bash commands to run in non-interactive mode, speeding up all commands a bit.

Instead of passing the current working directory to exec, pass it to Git instead. This is faster since we no longer have to use wsl wslpath to convert between WSL/Windows paths and at the same time allows the plugin to keep working for every path (previous implementation wouldn't work if you had a Git repository on a path other than /mnt/<drive>/*.

This is still too slow because for every command typed into the Hyper terminal, a lot of bash -c "<cmd>"s are executed and Windows/WSL interoperability is still a bit slow. Not sure how can this be improved from the plugin side :/

from hyper-statusline.

rfgamaral avatar rfgamaral commented on May 28, 2024 1

What kind of work would this need to get it working under WSL?

from hyper-statusline.

darkdreamingdan avatar darkdreamingdan commented on May 28, 2024 1

I think perhaps we should run a helper inside of WSL that broadcasts on an e.g. Unix Socket. Windows can read the Unix Socket file to get the latest information and then draw it that way.

from hyper-statusline.

pevecyan avatar pevecyan commented on May 28, 2024

Yeah, status line is not working on wsl yet

from hyper-statusline.

rfgamaral avatar rfgamaral commented on May 28, 2024

I've been trying to get this plugin working with WSL and it's not as easy as I though. Let me walk you through my thought process, what I've achieved already and the problems with my approach.

For all this to work there's a bunch of things that need to happen only if the active shell is a WSL. My approach to know that is simple, as long as vercel/hyper#3046 is merged. We start with this:

Now, for WSL we cannot rely on Node's exec because that will run cmd.exe on Windows and that doesn't help us at all, we need to run bash.exe -ic "{cmd}" instead. My approach for that:

And that's our first problem, Interop between Windows and WSL, which is a bit slow. We're spwaning a new command with exec, which is WSL's bash, which in turn will run a command inside WSL.

Given the change above we are now going to run all our commands inside WSL, meaning the PID used by lsof commands needs to be the correct one:

Here I have to run lsof as soon as SESSION_ADD event is fired to read the active shell bash PID and store it for future reference, associated to the active shell UID. After this change you'll notice that the status line already shows the current path and if you cd to a different path, you'll see it change, albeit a bit slow because of the whole exec » bash » lsof thing.

Now we need to handle all the Git commands that are executed through the whole plugin. The problem with those when running WSL is that although they still run with exec » bash » git, exec still runs under Windows and the cwd optional parameter is getting WSL paths. We need to convert those:

So, before running exec » bash » git we need to run exec » cmd » wsl wslpath to get the proper Windows path to pass down to the other command. After this point, and if you wait a while, you'll notice the status line will now include Git related information (if you are on a path with a Git repository that is).

However, it's quite slow because for each cd change, or even each command typed into the Hyper terminal, there's a lot of exec » bash » git and exec » cmd » wsl wslpath going around. Hyper even starts to break once you star to type on your terminal all sorts of commands because there's a lot of background processing with all those commands.

Even if this was fast enough, the work to get hyper-statusline to support WSL is not yet done. You might have noticed that paths in the status line have the wrong path separator, this is due to:

tildify is a package that converts an absolute path to tilde path and uses path.sep to get the correct separator for the OS where it's running the problem is that we are running Windows, but we want the Linux path separator because this is WSL.

There's also a problem with the home folder, which should be replaced with ~ but again, the home folder detected by tildify (which uses os-homedir for this) is the Windows one and not the WSL one.

The last thing that I remember that is missing to fix all WSL issues is opening Windows Explorer in the correct path when clicking the status line path element.

Everyone feel free to pitch with suggestions and improvements so we can get WSL support into hyper-statusline.

from hyper-statusline.

rfgamaral avatar rfgamaral commented on May 28, 2024

I've made a small improvement to the implementation above:

Instead of getting converting a WSL path to a Windows path multiple times (per each Git command invocation, basically), now it's converted only once before invoking the setGit function.

This improves performance a bit but not enough...

This can easily be tested by launching Hyper and as soon as WSL is ready, just press Return a bunch of times in succession. Look at the task manager and you'll see the Electron process eating all the CPU with too many Microsfot Bash Launcher, Microsoft Windows Subsystem for Linux Background Host and Windows Command Processor running.

Oh, well...

from hyper-statusline.

falconmick avatar falconmick commented on May 28, 2024

It looks like it half works now. its dumping errors to the status bar line, but not git info. Is this being actively looked into or has it been determined to be too difficult?

from hyper-statusline.

machinshin avatar machinshin commented on May 28, 2024

@rfgamaral : any updates on this thread/PR?

from hyper-statusline.

rfgamaral avatar rfgamaral commented on May 28, 2024

I'm no longer working on it, I couldn't find a reliable solution.

from hyper-statusline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.