Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Windows 10 Blank Status Line #75

Open
jrock2004 opened this issue Apr 18, 2018 · 9 comments
Open

Windows 10 Blank Status Line #75

jrock2004 opened this issue Apr 18, 2018 · 9 comments

Comments

@jrock2004
Copy link

I am using hyper with WSL on Windows 10. All I see an empty status bar

image

// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.

module.exports = {
  config: {
    // choose either `'stable'` for receiving highly polished,
    // or `'canary'` for less polished but more frequent updates
    updateChannel: 'stable',

    // default font size in pixels for all tabs
    fontSize: 16,

    // font family with optional fallbacks
    //fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
    fontFamily: '"Roboto Mono", monospace',

    // default font weight: 'normal' or 'bold'
    fontWeight: 'normal',

    // font weight for bold characters: 'normal' or 'bold'
    fontWeightBold: 'bold',

    // terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
    cursorColor: 'rgba(248,28,229,0.8)',

    // terminal text color under BLOCK cursor
    cursorAccentColor: '#000',

    // `'BEAM'` for |, `'UNDERLINE'` for _, `'BLOCK'` for █
    cursorShape: 'BLOCK',

    // set to `true` (without backticks and without quotes) for blinking cursor
    cursorBlink: false,

    // color of the text
    foregroundColor: '#fff',

    // terminal background color
    // opacity is only supported on macOS
    backgroundColor: '#000',

    // terminal selection color
    selectionColor: 'rgba(248,28,229,0.3)',

    // border color (window, tabs)
    borderColor: '#333',

    // custom CSS to embed in the main window
    css: '',

    // custom CSS to embed in the terminal window
    termCSS: '',

    // if you're using a Linux setup which show native menus, set to false
    // default: `true` on Linux, `true` on Windows, ignored on macOS
    showHamburgerMenu: '',

    // set to `false` (without backticks and without quotes) if you want to hide the minimize, maximize and close buttons
    // additionally, set to `'left'` if you want them on the left, like in Ubuntu
    // default: `true` (without backticks and without quotes) on Windows and Linux, ignored on macOS
    showWindowControls: '',

    // custom padding (CSS format, i.e.: `top right bottom left`)
    padding: '12px 14px',

    // the full list. if you're going to provide the full color palette,
    // including the 6 x 6 color cubes and the grayscale map, just provide
    // an array here instead of a color map object
    colors: {
      black: '#000000',
      red: '#C51E14',
      green: '#1DC121',
      yellow: '#C7C329',
      blue: '#0A2FC4',
      magenta: '#C839C5',
      cyan: '#20C5C6',
      white: '#C7C7C7',
      lightBlack: '#686868',
      lightRed: '#FD6F6B',
      lightGreen: '#67F86F',
      lightYellow: '#FFFA72',
      lightBlue: '#6A76FB',
      lightMagenta: '#FD7CFC',
      lightCyan: '#68FDFE',
      lightWhite: '#FFFFFF',
    },

    // the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
    // if left empty, your system's login shell will be used by default
    //
    // Windows
    // - Make sure to use a full path if the binary name doesn't work
    // - Remove `--login` in shellArgs
    //
    // Bash on Windows
    // - Example: `C:\\Windows\\System32\\bash.exe`
    //
    // PowerShell on Windows
    // - Example: `C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`
    shell: 'C:\\Windows\\System32\\wsl.exe',

    // for setting shell arguments (i.e. for using interactive shellArgs: `['-i']`)
    // by default `['--login']` will be used
    shellArgs: ['~'],

    // for environment variables
    env: {},

    // set to `false` for no bell
    bell: 'SOUND',

    // if `true` (without backticks and without quotes), selected text will automatically be copied to the clipboard
    copyOnSelect: false,

    // if `true` (without backticks and without quotes), hyper will be set as the default protocol client for SSH
    defaultSSHApp: true,

    // if `true` (without backticks and without quotes), on right click selected text will be copied or pasted if no
    // selection is present (`true` by default on Windows and disables the context menu feature)
    // quickEdit: true,

    // URL to custom bell
    // bellSoundURL: 'http://example.com/bell.mp3',

    // for advanced config flags please refer to https://hyper.is/#cfg
  },

  // a list of plugins to fetch and install from npm
  // format: [@org/]project[#version]
  // examples:
  //   `hyperpower`
  //   `@company/project`
  //   `project#1.0.1`
  plugins: ['hyperterm-chesterish', 'hyper-statusline'],

  // in development, you can create a directory under
  // `~/.hyper_plugins/local/` and include it here
  // to load it and avoid it being `npm install`ed
  localPlugins: [],

  keymaps: {
    // Example
    // 'window:devtools': 'cmd+alt+o',
  },
};

@pevecyan
Copy link
Contributor

Yeah, status line is not working on wsl yet

@rfgamaral
Copy link

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

@rfgamaral
Copy link

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.

@rfgamaral
Copy link

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...

@rfgamaral
Copy link

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 :/

@darkdreamingdan
Copy link

darkdreamingdan commented Jan 12, 2019

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.

@falconmick
Copy link

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?

@machinshin
Copy link

@rfgamaral : any updates on this thread/PR?

@rfgamaral
Copy link

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

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

No branches or pull requests

6 participants