hypercwd
hypercwd copied to clipboard
Open new tab take lots of time on Hyper 2.1.0-canary.3
Hi,
Its take lots of time to open a new tab or split with the last canary version of Hyper. No specific console log.
Any ideas ?
This might be related to https://github.com/zeit/hyper/issues/2838
Note sure. Everything was ok on canary 2 and if I disable hypercwd, I have no issue anymore
Still the same with 2.1.0 stable for me.
The problem is located in the setCwd
function which contains an exec
call to get the current working directory. In the current code it is assumed that exec
returns a single string value but it actually returns 3 (error, stdout and stderr). The trim()
called on the returned object therefore has no effect and fails to do so.
In the snippet below, promiseExec
returns an object, so newCwd.trim()
should actually be newCwd.stdout.trim()
.
const newCwd = await promiseExec(
`lsof -p ${tab.pid} | grep cwd | tr -s ' ' | cut -d ' ' -f9-`);
const cwd = newCwd.trim();
It doesn't seem like this repository is being actively maintained, so I decided to write a quick replacement plugin. It's located here hyper-samewd. Install with hyper i hyper-samewd
@LeanderFS Thanks! I also changed the plugin to hypersamewd !
The same thing happened. I'd tried to use hyper-samewd, but it had not worked. However, by rewriting the code of setCwd.js as following, somehow it worked well.
const newCwd = await promiseExec( // Specify LANG and not resolving domains
`LANG=en_US.utf-8 lsof -n -p ${
tab.pid
} | grep cwd | tr -s ' ' | cut -d ' ' -f9-`
);
But it has not tested in various environments. My environment is macOS 10.14.2, Hyper 2.1.1, Japanese. Could you please test with other systems or languages? (Maybe my english is not good because I'm Japanese, sorry.)