henrikruscon / hyper-statusline

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

Nothing displayed on Windows with Cygwin #74

Open codehearts opened 6 years ago

codehearts commented 6 years ago

I'm on 64bit Windows 7 with cygwin32, Git Bash, and Hyper 1.4.8. The statusline shows nothing until I run a command like git status with unstaged changes, then it shows the first path in the output as my cwd with no Git info.

I actually found a workaround for this, by replacing the logic for win32 in setCwd with the following

if (process.platform == 'win32') {
    // lsof isn't present, but /proc/${pid}/cwd is
    exec(`readlink -e /proc/${pid}/cwd`, (err, stdout) => {
      // Convert Cygwin path to Windows path for Git Bash
      exec(`cygpath -w ${stdout}`, (err, stdout) => {
        cwd = stdout.trim();
        setGit(cwd);
      })
    });
}

While this works for cygwin with Git Bash installed separately, I'm not sure if this works for Cygwin using Cygwin's Git, or if it would work for Git Bash/MinGW. I'm also not sure how you could detect Cygwin or other setups from the plugin.

pevecyan commented 6 years ago

An option is to have fallback, which triggers if previous method does not return correct path. For example, default is as is now and if that fails your code gets executed.

codehearts commented 6 years ago

If the last command prints a path name (git status), then the existing code thinks that path is the cwd and the fallback won't run. Otherwise that would work.

On top of that, cygpath needs to be run if using Git for Windows, but not if Git was installed through Cygwin :weary: You can at least tell if it's Git for Windows by checking if git --version contains "windows" (git version 2.16.1.windows.1)

I can try to get a PR together that checks these conditions, the code in my original post is too specific to my setup.

jerriclynsjohn commented 4 years ago

This works only problem is that when I cd out of the repository the statusline still shows the same branch with the all the git numbers from the previous repo, even if you cd into another repo,

This works if you directly open hyper from the respective repo, Is there anyone who has solved this.