Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Bash on the Windows Subsystem for Linux? #16

Open
JacobDB opened this issue Mar 30, 2017 · 16 comments
Open

Support for Bash on the Windows Subsystem for Linux? #16

JacobDB opened this issue Mar 30, 2017 · 16 comments

Comments

@JacobDB
Copy link

JacobDB commented Mar 30, 2017

Running Hyper with Bash on WSL as the specified shell in .hyper.js, this extension doesn't work properly. It just opens in the user directory as usual.

Would you be able to add support for Bash on WSL?

@danieltanfh95
Copy link

danieltanfh95 commented Mar 31, 2017

I did some hacking yesterday to see if the command could be changed to use the windows toolchain instead. I noticed that the pid passed into https://github.com/hharnisc/hypercwd/blob/master/index.js is not the process id of hyper itself, so it can't be used to identify the session, unless there is a way to map that into a process id.

Also note that since hyper is launched from windows, the node module hypercwd is also launched from windows.

I probably need to look into the hyper code to know what id are they passing around.

I'm just using echo $PWD | clip on git-bash then <c-t>cd<c-v> as a work around instead. (I'm also using https://github.com/xilun/cbwin)

@hharnisc
Copy link
Owner

hharnisc commented Sep 3, 2017

Hey @JacobDB and @shadowys I added support for Windows recently, could you try this pluggin again - not sure if it gracefully handles Bash on the Windows Subsystem 😄

@JacobDB
Copy link
Author

JacobDB commented Sep 5, 2017

@hharnisc just had a chance to test today, doesn't appear to work with bash. I even tried re-installing all modules, no dice.

@hharnisc
Copy link
Owner

hharnisc commented Sep 5, 2017

Thank you for trying this out @JacobDB - I wonder did it complain about lsof not being a command on the console? If it didn't that must mean that the detected environment is win32 🤔

@JacobDB
Copy link
Author

JacobDB commented Sep 6, 2017

I don't see any errors like that, but this morning I am seeing this error when trying to open a new tab; not sure if it's related.

image

Seems to be weirdly intermittent, can't get it to happen after re-opening Hyper. Will update if I figure out what causes it.

@danicatalan
Copy link

danicatalan commented Sep 27, 2017

@hharnisc @JacobDB

I also installed hypercwd with hpm inside WSL and it opens the HOME path, not the current working directory.

Opening a new tab is not throwing any JS error here (still not opening the cwd), but I will report in case it happens to me.

@danicatalan
Copy link

I'm starting to get the same alert while trying to split:

screenshot 11

@JacobDB
Copy link
Author

JacobDB commented Sep 27, 2017

Yea, it seems fairly intermittent. It happens most often when gulp watch is running on one of my projects.

@hharnisc
Copy link
Owner

hharnisc commented Oct 4, 2017

Sharing some context here about how the working directory is detected, on OS X it uses the lsof command and on Windows it uses a regex on the I/O. (since under standard windows shell it outputs that after each command)

Windows Regex: https://github.com/hharnisc/hypercwd/blob/master/index.js#L13

My guess what is happening here is that hypercwd is detecting windows but then doesn't detect the working directory because bash doesn't output that after each command.

@danicatalan
Copy link

danicatalan commented Oct 4, 2017

Thanks for the feedback @hharnisc. I can't really help here fixing this issue because of my limited background, but I will share some information about how I'm using cwd now hoping this has some value for you to keep working on this.

As my shell is zsh and I'm using oh-my-zsh, I can use a plugin called last-working-directory that stores the last path in cache (I think it writes the path on a file everytime I cd on my term).

This plugin implements the $ lwd command to cd the path stored in that cache file.

So, with that command available, I setup my shell to manually $ lwd every time I start a new session (no matter if I just opened Hyper, a new tab or splited). It smells but it works as expected.

@enwin
Copy link

enwin commented Nov 14, 2017

Hi everyone,

I just switched to Windows and WSL and I'm facing the same issue.

In hyper I'm running zsh with the following .hyper.js config:

  shell: 'C:\\Windows\\System32\\bash.exe',
  shellArgs: ['-c', 'zsh']

I did some digging into hyper and hypercwd and yes hypercwd is detecting windows because hyper is running on windows. We could use exec() but unfortunately nodejs' child_process is bound to cmd instead of the running shell. I'm able to exec() into bash but of course it spawns a new instance instead of the running one.

If hyper was able to give access to session.pty on SESSION_ADD in addition to session.pty.pid as we can see in window.js it would be possible to find the current session and access the running shell (its pty) to exec() some pwd command to use in the new tab.

I might fork hyper to test this but wouldn't mind some feedback beforehand.

Cheers

@JacobDB
Copy link
Author

JacobDB commented Feb 7, 2018

Any progress on getting this working?

@hharnisc
Copy link
Owner

hharnisc commented Feb 7, 2018

Hey @JacobDB 👋 I've added a help wanted badge on this one. I don't have enough time to fully implement this, but would accept a patch from the community. Probably better someone else do this since I'm not a daily user of this setup 😄

@Stanzilla
Copy link

@hharnisc this might help? henrikruscon/hyper-statusline#73

@pevecyan
Copy link

@Stanzilla I don't think that will help, I am just ignoring commands in wsl bash

@rfgamaral
Copy link

rfgamaral commented May 9, 2018

@enwin Have you tried what you said earlier?

If hyper was able to give access to session.pty on SESSION_ADD in addition to session.pty.pid as we can see in window.js it would be possible to find the current session and access the running shell (its pty) to exec() some pwd command to use in the new tab.

I forked hyper to share session.pty and I now have access to that object but I'm not sure exactly what do with it. How do you exec something like pwd with that pty object? I'm a bit clueless.

However, everything is supposed to be private (judging by the _ prefixes):

image

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

No branches or pull requests

8 participants