mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 17:52:02 +02:00
Add a shortcut to easily browse the output of the last command run in the shell
This commit is contained in:
@@ -914,6 +914,11 @@ class Window:
|
||||
) -> str:
|
||||
return as_text(self.screen, as_ansi, add_history, add_wrap_markers, alternate_screen, add_cursor)
|
||||
|
||||
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)
|
||||
|
||||
@property
|
||||
def cwd_of_child(self) -> Optional[str]:
|
||||
return self.child.foreground_cwd or self.child.current_cwd
|
||||
@@ -942,6 +947,15 @@ class Window:
|
||||
data = self.pipe_data(text, has_wrap_markers=True)
|
||||
get_boss().display_scrollback(self, data['text'], data['input_line_number'])
|
||||
|
||||
def show_last_command_output(self) -> None:
|
||||
'''
|
||||
@ac:cp: Show output from the last shell command in a pager like less
|
||||
|
||||
Requires :ref:`shell_integration` to work
|
||||
'''
|
||||
text = self.last_cmd_output(as_ansi=True, add_wrap_markers=True)
|
||||
get_boss().display_scrollback(self, text, title='Last command output')
|
||||
|
||||
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