From 78056c659cb491d9b912e988ec3113d79626fd9a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 30 Aug 2022 19:27:55 +0530 Subject: [PATCH] Another place we cant use readline on macOS --- kittens/remote_file/main.py | 4 ++-- kittens/tui/path_completer.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/kittens/remote_file/main.py b/kittens/remote_file/main.py index df1410308..b6d14805d 100644 --- a/kittens/remote_file/main.py +++ b/kittens/remote_file/main.py @@ -273,9 +273,9 @@ def save_as(conn_data: SSHConnectionData, remote_path: str, cli_opts: RemoteFile ) print('Relative paths will be resolved from:', styled(os.getcwd(), fg_intense=True, bold=True)) print() - from ..tui.path_completer import PathCompleter + from ..tui.path_completer import get_path try: - dest = PathCompleter().input() + dest = get_path() except (KeyboardInterrupt, EOFError): return if dest: diff --git a/kittens/tui/path_completer.py b/kittens/tui/path_completer.py index 970cb025f..c78e09372 100644 --- a/kittens/tui/path_completer.py +++ b/kittens/tui/path_completer.py @@ -3,6 +3,7 @@ import os +import sys from typing import Any, Callable, Dict, Generator, Optional, Sequence, Tuple from kitty.fast_data_types import wcswidth @@ -147,5 +148,12 @@ class PathCompleter: return '' +def get_path(prompt: str = '> ') -> str: + rd = getattr(sys, 'kitty_run_data') + if 'prewarmed' in rd and 'launched_by_launch_services' in rd: + return input(prompt) + return PathCompleter(prompt).input() + + def develop() -> None: PathCompleter().input()