Comments (9)
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.
What kind of work would this need to get it working under WSL?
from hyper-statusline.
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.
Yeah, status line is not working on wsl yet
from hyper-statusline.
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.
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.
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.
@rfgamaral : any updates on this thread/PR?
from hyper-statusline.
I'm no longer working on it, I couldn't find a reliable solution.
from hyper-statusline.
Related Issues (20)
- Nothing displayed on Windows with Cygwin HOT 3
- Feature Request: git dirty indicator for new but untracked files HOT 1
- Git indicators do not update unless one more command is issued (similar to the previous directory update bug)
- The plugin breaks window-snapping for Hyper on Windows 10 HOT 1
- Would love to contribute to this project but I'm confused by the PID usage HOT 4
- Git status not working
- Adjust opacity or contrast for current working directory HOT 2
- Not playing nice with other plugins
- Not Working With Tmux
- Can not install this plugin in Hyper 3.0.0-canary.8 (canary) HOT 1
- dir path not working with powershell on windows 10 HOT 1
- Git information not showing HOT 3
- Causes Hyper to hang when running ts-lint
- statusline not working with fish HOT 6
- japanese dir name is displayed unicode characters HOT 2
- Failed to load with hyperpower
- hyper-statusline causes significant lag in Hyper v3.1.0 HOT 3
- Allow controlling the text size and position of the status line
- Hi, just curious if this plugin has the ability to change the background color? Thanks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hyper-statusline.