Provide shell ssh integration for nushell
Closes #7877.
Small disclaimer: First Ghostty PR and Zig PR, but looking forward to contributing to the project.
This PR supports shell-integration-features ssh-env and ssh-terminfo as per other shells, but not the rest as this is what the issue states.
That being said, with this PR, then you would see this:
-
warning(io_exec): shell could not be detected, no automatic shell integration will be injected, but given that the default mode isdetectit will pick up the executable and if ssh features are enabled it will integrate it. This might be confusing for users. -
I decided to not add
nutopub const Shellbecause if we do so, then from what I understand from the code, then the code flow would imply that "shell integration will be injected" but it will only do so if thosessh-*features are enabled, which may be misleading. But on the other hand, providingsshshell integration but returningnullfor?!ShellIntegrationdoes not seem very correct either. -
I dont like that I added
featuresargument tosetupshell, just to check them ifnuwas used. The reasoning is because the way Nushell works, if we autoload thenushelldirectory (bysetupXdgDatadirs()) even if nosshfeatures were present, it will wrap thesshfunction and I think that is not desirable, even if we end up just forwarding the arguments.
Sorry for the long wall of text, but I think it was worth to add some of the doubts I have had myself, plus the ones that you folks may add. I am very happy to iterate on this, even if its a very "Easy" one, so I much welcome the feedback.
[!NOTE]
Used
GPTfor helping with nushell variable naming verification/improvement UsedGeminifor helping with understanding theZshssh integration so that I could replicate the logic with nushell. Just because I findzshlanguage very difficult to understand in detail.
Hi @pluiedev thanks for the feedback. I did test it before hand, maybe it was using a cache build? If I do a zig build from main, and checkout my branch and do zig build run its not registered. I have to do first zig build from my branch, and then zig build run, and then its registered in the zig-out/share/.... Did you also enable the ssh features?
Regarding the "strangeness", I ran initially run-external, and forgot about the caret notation, so i stuck with run-external everywhere. Additionally, I tried to follow the zsh approach for the integration, so maybe that plays a part in the "strangeness" that you mention, but thanks, I have addressed your changes!
@rhodes-b correct, I did not know that, I updated the readme to reflect it.
@jparise thanks for super good feedback. I have addressed the changes requested and replied to one of your questions which am also very curious about the best solution.
@jparise I addressed the changes mentioned above, and on top gave it an initial shot on actually checking the features in nushell, and letting zig just set the xdgDataDirs unconditionally. This works now by :
/autoload/vendor/bootstrap-integration.nu -> checks the $env.GHOSTTY_SHELL_FEATURES which decides whether the `ghostty-ssh-integration.nu` file will be sourced or not
/autoload/vendor/source-integration.nu -> sources `ghostty-ssh-integration.nu` if a particular file is present
ghostty-ssh-integration -> Not on autoload anymore, and will only be sourced given conditions above.
There is still a TODO(how to update the ghostty-ssh-integration.nu file on a new release), but wanted first to get the idea out to see what you guys think about it.
For the reasons why we need multiple files and do it this way, is due to how nushell deals with sourcing files and use files. More details on the last commit itself and Parse Constant Time Evaluation