alexherbo2 / kakoune.cr

A command-line tool for Kakoune
https://kakoune.org
The Unlicense
54 stars 11 forks source link

connect terminal doesn't retain working directory like connect.kak #17

Closed EpocSquadron closed 3 years ago

EpocSquadron commented 3 years ago

With :new, I can open a split in my terminal (wezterm), and it has the same working directory as the terminal with Kakoune in it (meaning the directory the shell was in when I started up kakoune). I've also configured wezterm such that splits opened with it's own shortcuts also retain the working directory of the pane that was active when the shortcut was executed.

I recently was using connect.kak and :> would open a split and retain the working directly the same as the other two methods. A couple days ago I switched to kakoune.cr. Now when I use :>, the resulting split starts in my home directory instead. This affects things like running lf or skim from kakoune.cr, which I expect to run in the directory of the project I'm working on. What am I doing wrong?

alexherbo2 commented 3 years ago

I cannot reproduce with Alacritty.

Try with terminal sh then pwd.

(You seem to confuse the server’s working directory and the terminal working directory. It’s natural in a client to be in the server’s working directory.)

It is possible your working directory is not honored but you don’t see it as you immediately attach a client.

Try with new then echo %val{client_env_PWD}.

EpocSquadron commented 3 years ago

@alexherbo2 sorry about the imprecision. You were right about :new not being relevant here. I was able to reproduce with :terminal sh and :repl-new. I'm not sure how those are supposed to work, but looking at connect.kak versus the init/kakoune.kak in this repo, the former sent cd %sh{pwd} (after passing that through args anyway), which likely masked this issue. In this repo's version of the connect command, only session and client are passed. I assume : terminal is doing something to set the working directory in usual circumstances, but since I'm running wezterm I set the termcmd for it's wezterm cli split-pane command. I imagine I could send additional arguments in the termcmd to pass the working directory, but would that pick up changes to the session's working directory from things like :cd? Is there a more canonical approach?

EpocSquadron commented 3 years ago

Turned out this was a bug in wezterm that has now been fixed. https://github.com/wez/wezterm/issues/766#event-4711093520