-
-
Notifications
You must be signed in to change notification settings - Fork 992
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
Minor refactoring for fish clone-in-kitty and allow use without env -0 #4967
Minor refactoring for fish clone-in-kitty and allow use without env -0 #4967
Conversation
The builtin option from the latest version of fish is not used for now. clone-in-kitty has been tested with fish 3.2.x. BusyBox env does not support the -0 option.
On Thu, Apr 14, 2022 at 06:57:33AM -0700, page-down wrote:
The builtin option from the latest version of fish is not used for now. clone-in-kitty has been tested with fish 3.2.x.
BusyBox env does not support the -0 option. Implemented with fish.
Builtins are heavily used in the scripts that come with fish, and any environment that overrides these builtin, I believe fish will not work properly. No need to guard with `builtin`, simplify the code for future maintenance.
If we use `command`, then `base64` or other commands that is not in the path, e.g. alias or function, will not work.
If builtin or commands don't work, I think `clone-in-kitty` is the last thing to worry about, leaving the user to work it out on their own, rather than rejecting the functions from the normal users.
Remove quotation marks and the trailing `# "`, `# ‘` by escaping special characters in the string.
Remove `echo $data_len`.
Please review, thanks.
---
I found that environment variables containing newlines, the `\n` are lost after cloning. This is reproduced in zsh/fish. (I believe the base64-encoded environment variables are correct in fish.)
I need help on this.
The culprit will probably be serialize_env() one needs to serialize
newlines specially there.
Also the zsh and bash versions of clone-in-kitty do not work in environments that do not support env -0.
Yes, I know. I dont see a good solution for these. Env vars can have
newlines so env without -0 is pretty pointless.
---
I personally don't like to copy all environment variables, because the shell is not only environment variables, but also many internal variables (and funtions) that are not exported. This feature only copies `half of them`, and my environment is broken and missing something (that I know) after cloning. I prefer to explicitly configure the ones that need to be copied.
Trying to serialize and restore complete shell state is pretty hairy,
but feel free to attempt it, the mechanism is present, it can work by
setting an env var with the serialized state which th eshell integration
script can read and try to restore.
Or, maybe it's time to increase the robustness of my environment.
Yes, clone isnt currently meant to be a full clone just to work for simple use
cases.
|
Actually I did the following test as expected under zsh. Did you mean over ssh? |
I tested again and confirmed that local and ssh, zsh clone-in-kitty are working fine. However, the newline in the environment variable is normal after using local fish clone-in-kitty, but missing with ssh, and the cause has not been found yet. Also my local zsh clone-in-kitty is throwing an error. (when the macOS user's shell is zsh)
|
I noticed that after using zsh clone-in-kitty, it displays a percentage sign with a white background and black text. Where is this coming from? Is it some kind of "partial line"? |
I remembered how I tested zsh (with ssh) before. export DEBUG=$(printf "abc\ndef")
env
after zsh clone-in-kitty with ssh:
|
yes, with ssh its probably not going to work because of the serialize_env problem |
I removed # quote_pat = re.compile('([\\`"\n])')
quote_pat = re.compile('([\\`"])') As for kitty/child.py if is_macos and exe == shell_path:
argv[0] = (f'-{exe.split("/")[-1]}') kitty/macos_process_info.c Does it require special case handling? Or should we get process information in some other way? |
kitty/macos_process_info.c `cmdline_of_process`
Does it require special case handling? Or should we get process information in some other way?
|
On Thu, Apr 14, 2022 at 10:48:48PM -0700, page-down wrote:
I noticed that after using zsh clone-in-kitty, it displays a percentage sign with a white background and black text. Where is this coming from? Is it some kind of "partial line"?
I dont see this, that is the zsh no newline at end of output marker.
Where are you seeing it?
|
This percent sign appears when clone-in-kitty is run again in a zsh or fish session after clone-in-kitty. zshrc is cleared. In the recent commit there is a mention of a change related to macOS, I tried it and still got |
I tried running clone-in-kitty, then clone-in-kitty again in the cloned window and saw no %. Also with empty .zshrc I dont have access to my macos machine to test at the moment, but it should be easy to verify whats going on. See line 590 in launch.py |
I specifically tried it in a Linux environment and
It is, only some minor changes are needed.
|
On Fri, Apr 15, 2022 at 02:46:17AM -0700, page-down wrote:
> ... saw no %. Also with empty .zshrc
I specifically tried it in a Linux environment and `kitty -o shell=/bin/zsh` ran clone-in-kitty (first time) and the percent sign came up. I don't know the root cause yet until I dig deeper.
Ah I think I know what this is. You are presumably using a layout that
causes windows to be resized when a new window is created. That resize
occurs during clone-in-kitty execution, which causes the cursor to move,
which breaks whatever heuristic zsh uses to determine if there has been
command output. Use the stacked layout or --type=tab and you wont see
the %
> ... it should be easy to verify whats going on ...
It is, only some minor changes are needed.
`kitty --config=NONE`
```text
cmdline: ['-zsh']
window.child.argv[0]: /bin/zsh
window.child.final_exe: /bin/zsh
```
|
The builtin option from the latest version of fish is not used for now. clone-in-kitty has been tested with fish 3.2.x.
BusyBox env does not support the -0 option. Implemented with fish.
Builtins are heavily used in the scripts that come with fish, and any environment that overrides these builtin, I believe fish will not work properly. No need to guard with
builtin
, simplify the code for future maintenance.If we use
command
, thenbase64
or other commands that is not in the path, e.g. alias or function, will not work.If builtin or commands don't work, I think
clone-in-kitty
is the last thing to worry about, leaving the user to work it out on their own, rather than rejecting the functions from the normal users.Remove quotation marks and the trailing
# "
,# ‘
by escaping special characters in the string.Remove
echo $data_len
.Please review, thanks.
I found that environment variables containing newlines, the
\n
are lost after cloning. This is reproduced in zsh/fish. (I believe the base64-encoded environment variables are correct in fish.)I need help on this.
Also the zsh and bash versions of clone-in-kitty do not work in environments that do not support env -0.
I personally don't like to copy all environment variables, because the shell is not only environment variables, but also many internal variables (and funtions) that are not exported. This feature only copies
half of them
, and my environment is broken and missing something (that I know) after cloning. I prefer to explicitly configure the ones that need to be copied.Or, maybe it's time to increase the robustness of my environment.