mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-15 13:04:38 +02:00
Get the first command output on screen and the last scrolled one
This commit is contained in:
@@ -1041,11 +1041,21 @@ class Window:
|
||||
) -> str:
|
||||
return as_text(self.screen, as_ansi, add_history, add_wrap_markers, alternate_screen, add_cursor)
|
||||
|
||||
def first_cmd_output_on_screen(self, as_ansi: bool = False, add_wrap_markers: bool = False) -> str:
|
||||
lines: List[str] = []
|
||||
self.screen.first_cmd_output_on_screen(lines.append, as_ansi, add_wrap_markers)
|
||||
return ''.join(lines)
|
||||
|
||||
def last_cmd_output(self, as_ansi: bool = False, add_wrap_markers: bool = False) -> str:
|
||||
lines: List[str] = []
|
||||
self.screen.last_cmd_output(lines.append, as_ansi, add_wrap_markers)
|
||||
return ''.join(lines)
|
||||
|
||||
def last_visited_cmd_output(self, as_ansi: bool = False, add_wrap_markers: bool = False) -> str:
|
||||
lines: List[str] = []
|
||||
self.screen.last_visited_cmd_output(lines.append, as_ansi, add_wrap_markers)
|
||||
return ''.join(lines)
|
||||
|
||||
@property
|
||||
def cwd_of_child(self) -> Optional[str]:
|
||||
return self.child.foreground_cwd or self.child.current_cwd
|
||||
@@ -1075,6 +1085,16 @@ class Window:
|
||||
cursor_on_screen = self.screen.scrolled_by < self.screen.lines - self.screen.cursor.y
|
||||
get_boss().display_scrollback(self, data['text'], data['input_line_number'], report_cursor=cursor_on_screen)
|
||||
|
||||
@ac('cp', '''
|
||||
Show output from the first shell command on screen in a pager like less
|
||||
|
||||
Requires :ref:`shell_integration` to work
|
||||
''')
|
||||
def show_first_command_output_on_screen(self) -> None:
|
||||
text = self.first_cmd_output_on_screen(as_ansi=True, add_wrap_markers=True)
|
||||
text = text.replace('\r\n', '\n').replace('\r', '\n')
|
||||
get_boss().display_scrollback(self, text, title='First command output on screen', report_cursor=False)
|
||||
|
||||
@ac('cp', '''
|
||||
Show output from the last shell command in a pager like less
|
||||
|
||||
@@ -1085,6 +1105,16 @@ class Window:
|
||||
text = text.replace('\r\n', '\n').replace('\r', '\n')
|
||||
get_boss().display_scrollback(self, text, title='Last command output', report_cursor=False)
|
||||
|
||||
@ac('cp', '''
|
||||
Show the first output below the last scrolled position via scroll_to_prompt in a pager like less
|
||||
|
||||
Requires :ref:`shell_integration` to work
|
||||
''')
|
||||
def show_last_visited_command_output(self) -> None:
|
||||
text = self.last_visited_cmd_output(as_ansi=True, add_wrap_markers=True)
|
||||
text = text.replace('\r\n', '\n').replace('\r', '\n')
|
||||
get_boss().display_scrollback(self, text, title='Last visited command output', report_cursor=False)
|
||||
|
||||
def paste_bytes(self, text: Union[str, bytes]) -> None:
|
||||
# paste raw bytes without any processing
|
||||
if isinstance(text, str):
|
||||
|
||||
Reference in New Issue
Block a user