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
macOS "Open With kitty.app" #4460
Comments
Note (if easy enough to develop): It would also be great if custom file icons could be applied (such as the Chrome icon on the .html file) by users. |
This is very much macOS specific, on Linux you can just create a wrapper It's only Apple that makes this difficult. As such I am not very That said, one probably can detect files passed to kitty via launch services on |
(Reply before the latest changes.) It looks like the code is already there. kitty/child-monitor.c process_cocoa_pending_actions(void) {
// ...
if (cocoa_pending_actions_data.open_files_count) {
// ... While this feature looks great, I also think the potentially inconsistent behavior will cause confusion. For example, for a .sh file, should kitty execute it directly, or open it in a text editor? For different types of files, should kitty open them as configured in open-actions? For now open the .sh file and kitty will execute it in a new window. I found an issue where (Tested before the latest commit.) Also, to get kitty.app to appear in the "Open With" list, it also requires registration of various file types in macOS for kitty. |
I tested the latest commit, which resulted in not being able to run the .sh file with kitty. <key>CFBundleDisplayName</key>
<string>kitty</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>command</string>
<string>sh</string>
<string>zsh</string>
<string>bash</string>
<string>fish</string>
<string>tool</string>
</array> |
see the next commit |
I tested the latest commit and .sh is executed with zsh. #!/usr/bin/env bash
echo "${BASH_VERSION}" Some open source projects have
Also for file type registration, I don't know how to register all file types yet. Since the file types are not registered, it is not possible to drag a text file to the kitty Dock icon to open it. And of course it doesn't appear in the "open with" list yet. Also do you think it's worth checking the executable permissions of the file? Then execute it or open it with a text editor. |
Executable permissions are already checked. And shell scripts are launched with the default shell unless they have a defined file extension such as .zsh, .bash or .fish. |
Strange, currently I am trying to open a .sh file with no execute permissions and it will be executed directly. |
Yes, like I said, script files will be opened with the default shell, |
Oh, it's pretty clearly that I missed the beginning of the Do you have any good ideas for files like
For example, is it possible to prefer user-configured open-actions. open-actions.conf
EDIT: Not really, since this is actually dedicated to hyperlinks, where the GUI program will be configured to open the file. |
On Fri, Jan 07, 2022 at 01:31:44AM -0800, page-down wrote:
Oh, it's pretty clearly that I missed the beginning of the `open_file()`. Thanks for the reminder.
Do you have any good ideas for files like `Makefile`, `LICENSE`, `setup.cfg`, `shell.nix`, etc.? Currently these files cannot be opened.
Any file that has a mimetype of text/ will be edited. You can add mime
types in the mime.types file in the kitty config directory.
|
I forgot about this feature.
I tried it and the nix file opens fine, but the Makefile still doesn't work. Is there a good way to handle this? |
Also are there any security issues?
I did not test the above. To be honest, I'm really not sure I like this approach. : / |
On Fri, Jan 07, 2022 at 03:46:57AM -0800, page-down wrote:
Also are there any security issues?
- Name a file `cat.jpg` with the actual contents as an executable binary or script. Offer it to the victim for download.
- Guide the victim to save to a special file system location, to make this file with executable permissions. (For example, some macOS shared volumes are mounted with file permissions of `777` and cannot be modified.)
- The victim opens it with kitty, at this point the payload is successfully executed.
I dont follow, the victim can double click the file to execute it if its
executable. Or run it in a shell. Or a hundred different ways to execute
it. Once you mark a file executable it means you intend to execute it. I
dont see how its the job of kitty to prevent you from executing a file
you have marked executable.
By that token I can make a shell script and name it image.jpg and have it
executed by kitty after marking it executable, even before this feature was
implemented. Since before, kitty would unconditionally try to execute
anything passed to it.
|
Previously kitty was not registered as an image viewer and was not so easily used. If the user explicitly opens with kitty at the command line, then this is his own problem. I can think of one more scenario.
At this point kitty has two identities at the same time, a picture viewer that does not execute code, or a terminal with full privileges. Hopefully, the user will understand what he is doing. Maybe I am overthinking it, if you are not worried then I have no problem with it. |
well, I dont actually mind not having the open_file() function execute |
Thank you very much for the quick fix! I really appreciate kitty, and this makes it a lot better for me. |
Thank you. I tested the latest changes and all the issues I mentioned have been resolved. Perhaps the last one: Not a big deal, but it would be nice if |
On Fri, Jan 07, 2022 at 09:18:31AM -0800, page-down wrote:
Thank you. I tested the latest changes and all the issues I mentioned have been resolved.
Perhaps the last one:
I tested after uninstalling imagemagick and the error message flashed (window closed), the user may not know what went wrong and how to fix it.
I dont follow, can you explain.
Not a big deal, but it would be nice if `--hold` (and perhaps all places where hold is used) could be configured to hold only when exiting with a non-zero. This allows to use `launch --hold` even when running icat, and does not conflict with icat's hold.
The meaning of hold is to hold, regardless of exit code. If you want
a hold dependent on exit code that would need to be a separate option.
Once can use launch --hold even when running with icat already. Since in
the icat case you want an unconditional hold
|
When imagemagick is not installed, kitten icat exits after outputting an error message and the OS window is closed immediately. Here is what I see with
Yes, it makes perfect sense. |
@kovidgoyal thanks for this feature. I have a question & a problem. Question:Do I need to add all extensions/files I want to be opened to Problem:I have this inside my
And my |
I also have
And have ImageMagic installed, yet it errors out saying
|
If it is already recognized in the system, then no special configuration is needed.
Note that this feature is not related to https://github.com/kovidgoyal/kitty/blob/v0.24.2/kitty/open_actions.py#L222-L245
Where did you configure it? What you need to configure is kitty's environment variables, and configuring them in shell rc is of course invalid. Because at this point neovim will be executed directly by kitty and has nothing to do with the shell. debug kitty's env vars:
It is not easy to configure environment variables for GUI software under macOS. You can add the paths of your other plugins to $PATH by using https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.exe_search_path This should solve all your program execution problems. |
Not sure that this is correct, all examples in the docs are mentioning
Thanks, it's a bit unfortunate though because this means extra work to keep everything in sync (shell rc & kitty config). |
The one you gave is for configuring the behavior of clicking on links within kitty. However, this post is about a new feature in 0.24.2 to open files with kitty under macOS via open with. This feature is configured using launch-actions.conf . |
Ok, I have been playing with different options for the last hour with no results.
Example using GNU |
This is working as expected.
Please see the documentation. These are not for kitty.
In macOS, kitty is executed by launchd, and the shell rc environment variable is not known unless kitty invokes the shell every time, but does not do so. In the actions profile, all programs will be run directly by kitty and have nothing to do with shell rc. My guess is that you need the following configuration.
or
|
Is your feature request related to a problem? Please describe.
This feature request is not related to a problem.
Describe the solution you'd like
I would like to be able to set kitty as the default opener for certain file types (like
*.txt
files). Once kitty has "opened" the document, it would pass the filename(s) off to a program of the user's choice (like their$EDITOR
).For example:
1. A user opens Finder on MacOS
2. The user "double clicks" a text file
3. kitty would then launch
vim %s
in a new window or tab, substituting the pathThis feature likely be useful for Linux as well, although I am only a macOS user.
Describe alternatives you've considered
I have tried bundling my own custom
*.app
s that will launch kitty themselves, but they are very cumbersome to use and require XCode. In addition, they meet Gatekeeper issues with launching external executables. I believe that this feature would be a good addition to kitty, rather than using eternal tools.Example Screenshot:
The text was updated successfully, but these errors were encountered: