-
-
Notifications
You must be signed in to change notification settings - Fork 990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRYer: Get hostname #5712
DRYer: Get hostname #5712
Conversation
On Sat, Nov 26, 2022 at 12:05:59AM -0800, page-down wrote:
The cached hostname cannot be used in `open_url` as it may have been changed.
---
About launching with current cwd, I found an issue.
```shell
kitty --config=NONE -d=/tmp -o 'shell zsh' -o 'map f1 new_window_with_cwd'
ssh ksi-enabled-remote
# Ctrl+D
# F1
```
After ssh disconnects, create a new window with the current cwd, which will then use the remote cwd.
The remote path probably does not exist locally and the shell starts at `/`, which is annoying.
I dont see how that's possible unless you have disabled shell
integration. After ssh exits, the local shell will draw a new prompt and
that prompt will report its cwd. SO the last reported cwd will be
correct.
|
Currently the new cwd is only reported when the cwd changes, at least for zsh and fish (the official fish one and the one that comes with kitty), which I think is good practice. shell-integration/zsh/kitty-integration chpwd_functions=(${chpwd_functions[@]} "_ksi_report_pwd") shell-integration/bash/kitty.bash # unfortunately bash provides no hooks to detect cwd changes
# in particular this means cwd reporting will not happen for a
# command like cd /test && cat. Since the cwd is not changed after exiting ssh, the problem I mentioned will occur. |
Then the way to do it is to store last_reported_local_cwd (when Then, use the one that matches the current value of is_remote. |
The downside to that is it will only work for ssh it wont work for instance if you another program that reports cwd. The only robust fix is to report on every prompt draw. |
I have changed the zsh integration to report cwd at every new prompt draw. So now bash and zsh both do that. Could you do the same for fish please, as it will take me a lot of time to figure out the best way to do it for fish. |
To answer my own question: No, for example when connecting from one "localhost" to another "localhost" via IP, this will not work.
Need to check this every time CWD is received. This will be expensive.
Unfortunately, there doesn't seem to be a better way to get acceptable improvements at minimal cost.
I will implement it in another PR. This does not apply to normal users, as a list of programs needs to be maintained. |
The cached hostname cannot be used in
open_url
as it may have been changed.About launching with current cwd, I found an issue.
After ssh disconnects, create a new window with the current cwd, which will then use the remote cwd.
The remote path probably does not exist locally and the shell starts at
/
, which is annoying.I can think of a few ways to improve this user experience.
Check if the hostname matches the local hostname before
return reported_cwd
.Provide more information when reporting cwd in shell integration. For example:
Store to
last_reported_local_cwd
when the reported kitty-pid is the same as the current one when processing cwd notifications.When
window.child_is_remote
is False and the last reported cwd explicitly haskitty-ssh-kitten
or nokitty-pid
, it falls back to the last recordedlast_reported_local_cwd
.Outputting the current cwd in prompt would be more accurate, but repeated output of the same cwd is too wasteful of resources and not really worth it for me.
Do you have a better idea?