henrikruscon / hyper-statusline

Status Line Plugin for Hyper
MIT License
386 stars 79 forks source link

Fixes issue getting win32 current working directory #53

Closed dougd closed 6 years ago

dougd commented 7 years ago

Resubmitted PR due to issues with previous one and tabs. Refactored to try to get windows current working directory using regex as lsof not available in win32. Not 100% accurate, but better than no support at all. Needs tested on mac and linux.

Stanzilla commented 7 years ago

Nice!

haustraliaer commented 7 years ago

This is working great for me on windows 10 v1607 - thanks @dougd!

henrikruscon commented 7 years ago

This is neat! I'm gonna try this out later today. Thanks for your contribution and sorry for the massive delay ✌️

Stanzilla commented 7 years ago

I noticed this only starts working after you sent your first command to the terminal, before that the statusbar stays blank

haustraliaer commented 7 years ago

Ah true - I see this as well @Stanzilla - didn't notice because I'd usually cd into somewhere first.

Now I'm using hypercwd (windows PR) I see it on a new tab though.

Stanzilla commented 7 years ago

You're talking about this one here, right? https://github.com/hharnisc/hypercwd/pull/21 Looks like a similar approach to the one by @dougd

haustraliaer commented 7 years ago

Yep - that's what I'm using as a local plugin.

Stanzilla commented 6 years ago

@dougd are you on win10 btw?

dougd commented 6 years ago

On Win7. Does it not work on Win10?

Cheers, Doug

On Sep 26, 2017 at 2:22 pm, <Benjamin Staneck (mailto:notifications@github.com)> wrote:

@dougd (https://github.com/dougd) are you on win10 btw?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub (https://github.com/henrikdahl/hyper-statusline/pull/53#issuecomment-332196175), or mute the thread (https://github.com/notifications/unsubscribe-auth/AB6dsVEzsNu3bvPhelxD5NY7-0cQezFIks5smPp9gaJpZM4Nqxed).

Stanzilla commented 6 years ago

No I just thought about the fact that Win10 has the Linux Subsystem and you could use that instead of a regex. I just started playing around with it and

const setCwd = (pid) => {
    exec(`bash.exe -c lsof -p ${pid} | awk '$4=="cwd"' | tr -s ' ' | cut -d ' ' -f9-`, (err, stdout) => {
        cwd = stdout.trim();
        setGit(cwd);
    });
};

resulted in https://i.imgur.com/h2L6aE0.png 😄

dougd commented 6 years ago

Ah I see 👍 would we want different code path for win7 and win10? I suppose we already have windows, mac and linux :-)

Cheers, Doug

On Sep 26, 2017 at 2:29 pm, <Benjamin Staneck (mailto:notifications@github.com)> wrote:

No I just thought about the fact that Win10 has the Linux Subsystem and you could use that instead of a regex. I just started playing around with it and

const setCwd = (pid) => { exec(bash.exe -c lsof -p ${pid} | awk '$4=="cwd"' | tr -s ' ' | cut -d ' ' -f9-, (err, stdout) => { cwd = stdout.trim(); setGit(cwd); }); };

resulted in https://i.imgur.com/h2L6aE0.png 😄

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub (https://github.com/henrikdahl/hyper-statusline/pull/53#issuecomment-332198199), or mute the thread (https://github.com/notifications/unsubscribe-auth/AB6dsYK8gIlYSZmtSHzfIQpQsTCak0rNks5smPw4gaJpZM4Nqxed).

Stanzilla commented 6 years ago

Depends on performance and if I get it working, I guess. If your solution is faster than going to bash on Windows then it's not worth it to make a special path.

dougd commented 6 years ago

Your solution if it flies would yield more reliable results....

Cheers, Doug

On Sep 26, 2017 at 2:34 pm, <Benjamin Staneck (mailto:notifications@github.com)> wrote:

Depends on performance and if I get it working, I guess. If your solution is faster than going to bash on Windows then it's not worth it to make a special path.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub (https://github.com/henrikdahl/hyper-statusline/pull/53#issuecomment-332199559), or mute the thread (https://github.com/notifications/unsubscribe-auth/AB6dsVOz-fakJw8SZRzctW-7tW7jcenOks5smP1RgaJpZM4Nqxed).

dougd commented 6 years ago

Looks like the plugin as moved on since I did this work, closing and there is another pending PR to address this.