diff --git a/kitty/boss.py b/kitty/boss.py index d0015f509..113497585 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -755,7 +755,7 @@ class Boss: window: Optional[Window] = None, custom_callback: Optional[Callable] = None, action_on_removal: Optional[Callable] = None - ) -> Optional[Window]: + ) -> Any: orig_args, args = list(args), list(args) from kittens.runner import create_kitten_handler end_kitten = create_kitten_handler(kitten, orig_args) @@ -766,8 +766,7 @@ class Boss: w = window tab = w.tabref() if w else None if end_kitten.no_ui: - end_kitten(None, getattr(w, 'id', None), self) - return None + return end_kitten(None, getattr(w, 'id', None), self) if w is not None and tab is not None and w.overlay_for is None: args[0:0] = [config_dir, kitten] diff --git a/kitty/rc/kitten.py b/kitty/rc/kitten.py index 48f4001bb..468cd98a4 100644 --- a/kitty/rc/kitten.py +++ b/kitty/rc/kitten.py @@ -26,7 +26,9 @@ class Kitten(RemoteCommand): 'Run a kitten over the specified window (active window by default).' ' The :italic:`kitten_name` can be either the name of a builtin kitten' ' or the path to a python file containing a custom kitten. If a relative path' - ' is used it is searched for in the kitty config directory.' + ' is used it is searched for in the kitty config directory. If the kitten is a' + ' no_ui kitten and its handle response method returns a string or boolean, this' + ' is printed out to stdout.' ) options_spec = MATCH_WINDOW_OPTION argspec = 'kitten_name' @@ -43,10 +45,13 @@ class Kitten(RemoteCommand): windows = list(boss.match_windows(match)) if not windows: raise MatchError(match) + retval = None for window in windows: if window: - boss._run_kitten(payload_get('kitten'), args=tuple(payload_get('args') or ()), window=window) + retval = boss._run_kitten(payload_get('kitten'), args=tuple(payload_get('args') or ()), window=window) break + if isinstance(retval, (str, bool)): + return retval kitten = Kitten()