cyd01 / KiTTY

:computer: KiTTY, a free telnet/ssh client for Windows
https://www.9bis.com/kitty
Other
1.6k stars 136 forks source link

klink cannot load config file if Starting Directory is not app root. #397

Open anonymous1184 opened 2 years ago

anonymous1184 commented 2 years ago

If klink (perhaps all of the utilities?) are invoked with an starting directory other than the utility's root the configuration file is not loaded.

I was using git and the sshCommand option is klink with a private key. Since the configuration file wasn't loaded the option to automatically store the server SSH key wasn't in effect putting git in the limbo as I couldn't interact. The workaround was to put a kitti.ini with a fixed configdir in the directory where I was about to clone, git dir and the repo dir (as I needed to clone, edit and commit/push).

cyd01 commented 2 years ago

Try to put kitty.ini configuration file in %APPDATA%\KiTTY\kitty.ini directory.
Another solution is to set en environment variable KITTY_INI_FILE that contains the full path to your kitty.ini configuration file.

anonymous1184 commented 2 years ago

Sorry for the delayed response.

Both options work great, however both trump the whole portable operation. Is there plan to look for the .ini in the same folder as the executables?

cyd01 commented 2 years ago

If you want to use it in portable mode of course you can put the kitty.ini file directly in the same directory where executables are. See the documentation.

anonymous1184 commented 2 years ago

That's the issue., the .ini file is not read unless starting the application in the same directory as the file.

When doing git operations that is not possible and I have many different configurations as I manage quite a few of repositories; some of them have a git local config with a key, some make use of the GIT_SSH env var and some default to pageant.

Here how to replicate.

The archive kitty-bin-0.76.0.10.zip was extracted in D:\Apps\KiTTY and a a file kitty.ini was created with the following contents:

[KiTTY]
savemode=dir
autostoresshkey=yes

Now if I'm on the root of the D:\ (or any folder but the path of the executables) the configuration is not loaded (as seen on the image asking to store the key), but as soon as I change to the directory everything works.

20220708030657

I also tried renaming the files as their original counterparts and with my original setup which is hardlinks to so I can easily update KiTTY and keep other configurations as they are. BTW both work fine having the config file in %AppData% or setting user/system env vars.

maffe commented 1 year ago

As a workaround, I tried using scripts (both .cmd and .sh for Git Bash) which change the working directory before running klink.exe, but with that approach Ctrl+C stops the script, cancelling the SSH session (even when running exec klink.exe). For now I set the KITTY_INI_FILE variable, but this is not really portable and portability was the reason to use KiTTY instead of PuTTY in the first place.

anonymous1184 commented 1 year ago

In cmd, use start so the subprocess is created detached (same as CreateProcess() with DETACHED_PROCESS as dwCreationFlags)

maffe commented 1 year ago

In cmd, use start so the subprocess is created detached (same as CreateProcess() with DETACHED_PROCESS as dwCreationFlags)

I also tried doing that, but then the SSH session opens in a new window (instead of using the current PowerShell tab), uses different font settings and doesn’t handle color codes (instead it displays them as text and makes beeping noises).