mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-11-13 12:09:35 +03:00
macOS: Add Open with kitty Service
There are still some file types that cannot be matched. Add a standalone Open With service. Users can configure shortcut for this service in System Preferences.
This commit is contained in:
parent
9989edbe42
commit
007e9697c4
@ -520,6 +520,19 @@ cocoa_send_notification(PyObject *self UNUSED, PyObject *args) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)openFileURLs:(NSPasteboard*)pasteboard
|
||||
userData:(NSString *) UNUSED userData error:(NSError **) UNUSED error {
|
||||
NSDictionary *options = @{ NSPasteboardURLReadingFileURLsOnlyKey: @YES };
|
||||
NSArray *urlArray = [pasteboard readObjectsForClasses:[NSArray arrayWithObject:[NSURL class]] options:options];
|
||||
for (NSURL *url in urlArray) {
|
||||
NSString *path = [url path];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
|
||||
set_cocoa_pending_action(LAUNCH_URL, [[[NSURL fileURLWithPath:path] absoluteString] UTF8String]);
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// global menu {{{
|
||||
|
6
setup.py
6
setup.py
@ -1090,6 +1090,12 @@ def macos_info_plist() -> bytes:
|
||||
'NSRequiredContext': {'NSTextContent': 'FilePath'},
|
||||
'NSSendTypes': ['NSFilenamesPboardType', 'public.plain-text'],
|
||||
},
|
||||
{
|
||||
'NSMenuItem': {'default': f'Open with {appname}'},
|
||||
'NSMessage': 'openFileURLs',
|
||||
'NSRequiredContext': {'NSTextContent': 'FilePath'},
|
||||
'NSSendTypes': ['NSFilenamesPboardType', 'public.plain-text'],
|
||||
},
|
||||
]
|
||||
|
||||
pl = dict(
|
||||
|
Loading…
Reference in New Issue
Block a user