hharnisc / hypercwd

Opens new tabs with the same directory as the current tab in Hyper
MIT License
384 stars 39 forks source link

Support bash on Windows 10 #46

Closed N0xFF closed 2 years ago

N0xFF commented 6 years ago

shell: 'C:\\Windows\\System32\\bash.exe' in settings

When I open a new tab I got the exception:

Uncaught Exception:
Error: Unable to start terminal process: CreateProcess failed
    at new WindowsPtyAgent (C:\Users\n0xff\AppData\Local\hyper\app-2.1.0-canary1\resources\app.asar\node_modules\node-pty\lib\windowsPtyAgent.js:25:24)
    at new WindowsTerminal (C:\Users\n0xff\AppData\Local\hyper\app-2.1.0-canary1\resources\app.asar\node_modules\node-pty\lib\windowsTerminal.js:45:24)
    at spawn (C:\Users\n0xff\AppData\Local\hyper\app-2.1.0-canary1\resources\app.asar\node_modules\node-pty\lib\index.js:27:12)
    at Session (C:\Users\n0xff\AppData\Local\hyper\app-2.1.0-canary1\resources\app.asar\session.js:53:18)
    at initSession (C:\Users\n0xff\AppData\Local\hyper\app-2.1.0-canary1\resources\app.asar\ui\window.js:102:24)
    at Server.Window.rpc.on.options (C:\Users\n0xff\AppData\Local\hyper\app-2.1.0-canary1\resources\app.asar\ui\window.js:105:7)
    at emitOne (events.js:115:13)
    at Server.emit (events.js:210:7)
    at Server.ipcListener (C:\Users\n0xff\AppData\Local\hyper\app-2.1.0-canary1\resources\app.asar\rpc.js:33:11)
    at emitTwo (events.js:125:13)

In bash action.data return:

"]0;virtual@MAIN-PC: /mnt/cvirtual@MAIN-PC:/mnt/c/Users/n0xff$"

After parsing this data the cwd variable value is C: /mnt/c. So Hyper can't start a new session with wrong cwd.

If we want open bash.exe with our folder we need use cmd arguments bash.exe -c "cd /mnt/" or change current folder before opening bash.exe (and he open bash in current folder). I don't know can we send additional arguments to Hyper or not, but we can change current folder in right way.

I extend regexp and add transform from Linux path in Windows. So above data now will return correct folder path C:/Users/n0xff.

Was tested in default cmd.exe and bash.exe shell.

N0xFF commented 6 years ago

Should completely fix https://github.com/hharnisc/hypercwd/issues/32

N0xFF commented 6 years ago

Oh, I found another problem.

I can't open new tab when rails server is running because action.data is:

"Read fragment views/application/_footer:82b6729ab2e01c94a01e63c6949ca9d9/ru/footer (0.2ms)[?25l
  CACHE Category Load (0.0ms)  SELECT  "categories".* FROM "categories" WHERE "categories"."id" = $1 ORDER BY "categories"."position" ASC LIMIT $2  [["id", 2], ["LIMIT", 1]]
  ↳ app/routes/friendly_items_route.rb:46
  CACHE Category Load (0.0ms)  SELECT  "categories".* FROM "categories" WHERE "categories"."id" = $1 ORDER BY "categories"."position" ASC LIMIT $2  [["id", 2], ["LIMIT", 1]]
  ↳ app/routes/friendly_items_route.rb:46
[?25h"

And default or my regexp parse it in cwd: 'r:82b6729ab2e01c94a01e63c6949ca9d9/ru/footer (0.2ms)'

MarcelloTheArcane commented 4 years ago

Any update on when this will be merged?