Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't copy output of last command (via launch) from an overlaid shell program window #5392

Closed
akharrou opened this issue Aug 17, 2022 · 5 comments
Labels

Comments

@akharrou
Copy link

akharrou commented Aug 17, 2022

Describe the bug

Trying to copy the output of the last command from an overlay shell program window doesn't seem to work for me. What am I doing wrong ?

  • copying the output via: launch --stdin-source=@last_cmd_output --type=clipboard

To Reproduce

#: kitty.conf
env TERM_PROGRAM=kitty
shell /bin/zsh --login
allow_remote_control yes

#: copy output of last shell command
map super+y launch --stdin-source=@last_cmd_output --type=clipboard
#: launch new [zsh] shell overlay
map super+. launch --type=overlay --cwd=current zsh --login
  1. launch an overlay shell program window
  2. run a command
  3. try to copy its output
  4. paste the output
  5. realize it's not the output of the previously run command

Aug-17-2022 21-22-38

  • in this recording
    1. first a command is run and its output is copied from a non-overlay window
    2. then we get into an overlay window
    3. then we try to run a command and copy its output (but this fails)

Environment details

full kitty debug output (with full config thought)
kitty 0.25.2 created by Kovid Goyal
Darwin Mac.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64
ProductName:	macOS ProductVersion:	12.3.1 BuildVersion:	21E258
Frozen: True
Paths:
  kitty: /Applications/kitty.app/Contents/MacOS/kitty
  base dir: /Applications/kitty.app/Contents/Resources/kitty
  extensions dir: /Applications/kitty.app/Contents/Resources/Python/lib/kitty-extensions
  system shell: /bin/zsh
Loaded config files:
  /Users/akharrou/.config/kitty/kitty.conf

Config options different from defaults:
active_tab_title_template          {index}: {title}
adjust_baseline                    1
adjust_column_width                -1
adjust_line_height                 3
allow_remote_control               y
background_opacity                 0.96
clipboard_control                  ('write-clipboard', 'write-primary', 'read-clipboard', 'read-primary')
confirm_os_window_close            1
copy_on_select                     clipboard
cursor_beam_thickness              2.0
cursor_shape                       2
dynamic_background_opacity         True
editor                             /usr/local/bin/nvim
enable_audio_bell                  False
enabled_layouts                    ['splits:bias=100', 'grid', 'stack']
env:
{'TERM_PROGRAM': 'kitty'}
exe_search_path:
{'/usr/local/bin/': '/usr/local/bin/',
 '~/.local/bin': '~/.local/bin',
 '~/.local/etc/opt/kitty/scripts/': '~/.local/etc/opt/kitty/scripts/'}
font_family                        RobotoMono Nerd Font
font_features:
{'UnifontMedium': ('+isol', '-medi', '-fina', '-init')}
font_size                          14.5
hide_window_decorations            2
inactive_text_alpha                0.75
macos_hide_from_tasks              True
macos_quit_when_last_window_closed True
macos_thicken_font                 0.4
mouse_hide_wait                    3.0
pointer_shape_when_grabbed         beam
scrollback_lines                   4294967295
scrollback_pager                   ['bat']
scrollback_pager_history_size      4194304000
shell                              /bin/zsh --login
single_window_margin_width         FloatEdges(left=0.0, top=0.0, right=0.0, bottom=0.0)
startup_session                    /Users/akharrou/.config/kitty/session/ranger.conf
strip_trailing_spaces              smart
tab_bar_margin_height              TabBarMarginHeight(outer=8.0, inner=0)
tab_bar_margin_width               20.0
tab_bar_min_tabs                   1
tab_bar_style                      separator
tab_powerline_style                round
tab_separator                          
tab_title_template                 {index}: {title}
url_prefixes                       ('http', 'https', 'file', 'ftp', 'gemini', 'irc', 'gopher', 'mailto', 'news', 'git')
url_style                          2
window_border_width                (1.0, 'px')
window_padding_width               FloatEdges(left=10.0, top=10.0, right=10.0, bottom=10.0)
Added mouse actions:
	opt+left click ungrabbed → mouse_handle_click selection link prompt
	opt+left click grabbed → mouse_handle_click selection link prompt
	opt+left release ungrabbed → mouse_handle_click selection link prompt
	opt+left release grabbed → mouse_handle_click selection link prompt
	opt+left press ungrabbed → mouse_selection rectangle
	opt+left press grabbed → mouse_selection rectangle
	opt+left doublepress ungrabbed → mouse_selection word
	opt+left triplepress ungrabbed → mouse_selection line
	shift+opt+left doublepress ungrabbed → mouse_selection line_from_point
	cmd+left release ungrabbed → mouse_handle_click link
	cmd+left release grabbed → mouse_handle_click link
	cmd+right press ungrabbed → mouse_show_command_output
Removed mouse actions:
	shift+left click ungrabbed → mouse_handle_click selection link prompt
	shift+left click grabbed → mouse_handle_click selection link prompt
	shift+left press grabbed → mouse_selection normal
	shift+left doublepress grabbed → mouse_selection word
	shift+left triplepress ungrabbed → mouse_selection line
	shift+left triplepress grabbed → mouse_selection line
	ctrl+shift+left release ungrabbed → mouse_handle_click link
	ctrl+shift+left release grabbed → mouse_handle_click link
	ctrl+shift+left press grabbed → discard_event
	ctrl+opt+left press ungrabbed → mouse_selection rectangle
	ctrl+opt+left triplepress ungrabbed → mouse_selection line_from_point
	ctrl+shift+opt+left press ungrabbed → mouse_selection rectangle
	ctrl+shift+opt+left press grabbed → mouse_selection rectangle
	ctrl+shift+opt+left triplepress ungrabbed → mouse_selection line_from_point
	ctrl+shift+opt+left triplepress grabbed → mouse_selection line_from_point
	shift+right press ungrabbed → mouse_selection extend
	shift+right press grabbed → mouse_selection extend
	ctrl+shift+right press ungrabbed → mouse_show_command_output
	middle release ungrabbed → paste_from_selection
	shift+middle release ungrabbed → paste_selection
	shift+middle release grabbed → paste_selection
	shift+middle press grabbed → discard_event
Changed mouse actions:
	left click ungrabbed → mouse_handle_click prompt
	shift+left press ungrabbed → mouse_selection extend
	shift+left doublepress ungrabbed → mouse_selection line_from_point
	right press ungrabbed → mouse_select_command_output
Added shortcuts:
	opt+v → paste_selection_or_clipboard
	opt+w → close_os_window
	shift+opt+h → send_text all \x1b[1;3D
	shift+opt+j → send_text all \x1b[1;3C
	ctrl+m → create_marker
	ctrl+w → detach_window ask
	ctrl+up → scroll_page_up
	ctrl+down → scroll_page_down
	ctrl+shift+' → launch --type=overlay --stdin-source=@last_cmd_output /usr/local/bin/code -
	ctrl+shift+; → launch --type=overlay --stdin-source=@last_cmd_output nvim
	ctrl+shift+\ → next_layout
	ctrl+shift+d → debug_config
	ctrl+shift+i → launch --type=window --location=vsplit --stdin-source=@last_cmd_output sh -c '/usr/local/bin/jq -L ~/.config/jq/libjq "include \"libjq\"; . | schema" --color-output | /usr/local/bin/bat'
	ctrl+shift+m → toggle_marker iregex 1 "\b(INFO|DEBUG|TRACE|XTRACE)\b" 2 "\b(WARNING)\b" 3 "\b(ERROR|CRITICAL)\b"
	cmd+. → launch --type=overlay --cwd=current zsh --login
	cmd+/ → launch --type=overlay --cwd=current ~/.local/etc/opt/kitty/scripts/zsh.fzf.get_shell_module.zsh
	cmd+[ → scroll_to_prompt -1
	cmd+\ → scroll_to_prompt 0
	cmd+] → scroll_to_prompt 1
	cmd+b → launch --type=tab --location=neighbor --cwd=current zsh -c ranger
	cmd+d → launch --location=vsplit --cwd=current
	cmd+e → launch --type=window --location=vsplit nvim
	cmd+h → combine : previous_tab
	cmd+i → neighboring_window up
	cmd+j → neighboring_window left
	cmd+l → combine : next_tab
	cmd+m → neighboring_window down
	cmd+o > a → _hints --type=url --program=default
	cmd+o > h → _hints --multiple --add-trailing-space=never --multiple-joiner=space --type=hash --program=@
	cmd+o > l → _hints --type=line --program=@
	cmd+o > o → _hints --type=word --program=@
	cmd+o > p → _hints --multiple --add-trailing-space=never --multiple-joiner=newline --type=ip --program=@
	cmd+o > r → _hints --type=path --program=open
	cmd+o > shift+a → _hints --multiple --add-trailing-space=never --multiple-joiner=newline --type=url --program=default
	cmd+o > shift+l → _hints --multiple --add-trailing-space=never --multiple-joiner=newline --type=line --program=@
	cmd+o > shift+o → _hints --multiple --add-trailing-space=never --multiple-joiner=space --type=word --program=@
	cmd+o > cmd+a → _hints --type=url --program=default
	cmd+o > cmd+d → _hints --customize-processing scripts/word.search.google.definition.py
	cmd+o > cmd+e → _hints --type=hyperlink --linenum-action=self
	cmd+o > cmd+g → _hints --customize-processing scripts/phrase.search.google.py
	cmd+o > cmd+h → _hints --multiple --add-trailing-space=never --multiple-joiner=space --type=hash --program=@
	cmd+o > cmd+i → _hints --type=path --program='open -a /Applications/Visual\ Studio\ Code\ -\ Insiders.app'
	cmd+o > cmd+l → _hints --type=line --program=@
	cmd+o > cmd+o → _hints --type=word --program=@
	cmd+o > cmd+p → _hints --multiple --add-trailing-space=never --multiple-joiner=newline --type=ip --program=@
	cmd+o > cmd+r → _hints --type=path --program=open
	cmd+o > cmd+s → _hints --customize-processing scripts/line.search.stackoverflow.py
	cmd+o > shift+cmd+a → _hints --multiple --add-trailing-space=never --multiple-joiner=newline --type=url --program=default
	cmd+o > shift+cmd+l → _hints --multiple --add-trailing-space=never --multiple-joiner=newline --type=line --program=@
	cmd+o > shift+cmd+o → _hints --multiple --add-trailing-space=never --multiple-joiner=space --type=word --program=@
	cmd+q > q → quit
	cmd+q > cmd+q → quit
	cmd+s → launch --type=window --location=split sh -c 'command cd $( command mktemp -d "/tmp/dir.$( command date +%Y.%m.%dT%H.%M.%S ).XXXX" ); exec zsh --login'
	cmd+u > cmd+e → toggle_layout stack
	cmd+y → launch --stdin-source=@last_cmd_output --type=clipboard
	cmd+backspace → send_text all \x1bb
	shift+cmd+, → load_config_file
	shift+cmd+b → launch --type=tab --location=before --cwd=current zsh -c ranger
	shift+cmd+e → launch --type=overlay --cwd=current ranger
	shift+cmd+f → send_text all Ï
	shift+cmd+h → move_tab_backward
	shift+cmd+l → move_tab_forward
	shift+cmd+n → new_os_window_with_cwd
	shift+cmd+r → launch --type=window --location=before --cwd=current ranger
	shift+cmd+s → launch --type=window --location=hsplit sh -c 'command cd $( command mktemp -d "/tmp/dir.$( command date +%Y.%m.%dT%H.%M.%S ).XXXX" ); exec zsh --login'
	opt+cmd+i → move_window up
	opt+cmd+j → move_window left
	opt+cmd+k → move_window right
	opt+cmd+m → move_window down
	opt+cmd+enter → toggle_layout stack
	ctrl+shift+opt+cmd+i → scroll_home
	ctrl+shift+opt+cmd+m → scroll_end
Removed shortcuts:
	shift+insert → paste_from_selection
	ctrl+tab → next_tab
	ctrl+shift++ → change_font_size all +2.0
	ctrl+shift+, → move_tab_backward
	ctrl+shift+- → change_font_size all -2.0
	ctrl+shift+. → move_tab_forward
	ctrl+shift+0 → tenth_window
	ctrl+shift+1 → first_window
	ctrl+shift+2 → second_window
	ctrl+shift+3 → third_window
	ctrl+shift+4 → fourth_window
	ctrl+shift+5 → fifth_window
	ctrl+shift+6 → sixth_window
	ctrl+shift+7 → seventh_window
	ctrl+shift+8 → eighth_window
	ctrl+shift+9 → ninth_window
	ctrl+shift+= → change_font_size all +2.0
	ctrl+shift+[ → previous_window
	ctrl+shift+] → next_window
	ctrl+shift+` → move_window_to_top
	ctrl+shift+a > 1 → set_background_opacity 1
	ctrl+shift+a > d → set_background_opacity default
	ctrl+shift+a > l → set_background_opacity -0.1
	ctrl+shift+a > m → set_background_opacity +0.1
	ctrl+shift+c → copy_to_clipboard
	ctrl+shift+e → open_url_with_hints
	ctrl+shift+f → move_window_forward
	ctrl+shift+g → show_last_command_output
	ctrl+shift+p > f → kitten hints --type path --program -
	ctrl+shift+p > h → kitten hints --type hash --program -
	ctrl+shift+p > l → kitten hints --type line --program -
	ctrl+shift+p > n → kitten hints --type linenum
	ctrl+shift+p > w → kitten hints --type word --program -
	ctrl+shift+p > y → kitten hints --type hyperlink
	ctrl+shift+p > shift+f → kitten hints --type path
	ctrl+shift+q → close_tab
	ctrl+shift+s → paste_from_selection
	ctrl+shift+t → new_tab
	ctrl+shift+v → paste_from_clipboard
	ctrl+shift+x → scroll_to_prompt 1
	ctrl+shift+escape → kitty_shell window
	ctrl+shift+enter → new_window
	ctrl+shift+tab → previous_tab
	ctrl+shift+delete → clear_terminal reset active
	ctrl+shift+left → previous_tab
	ctrl+shift+right → next_tab
	ctrl+shift+up → scroll_line_up
	ctrl+shift+down → scroll_line_down
	ctrl+shift+page_up → scroll_page_up
	ctrl+shift+page_down → scroll_page_down
	ctrl+shift+home → scroll_home
	ctrl+shift+end → scroll_end
	ctrl+shift+f2 → edit_config_file
	ctrl+shift+f5 → load_config_file
	ctrl+shift+f6 → debug_config
	ctrl+shift+f7 → focus_visible_window
	ctrl+shift+f8 → swap_with_window
	ctrl+shift+f10 → toggle_maximized
	ctrl+shift+f11 → toggle_fullscreen
	ctrl+shift+kp_subtract → change_font_size all -2.0
	ctrl+shift+kp_add → change_font_size all +2.0
	ctrl+shift+opt+t → set_tab_title
	cmd++ → change_font_size all +2.0
	cmd+c → copy_to_clipboard
	cmd+v → paste_from_clipboard
	cmd+enter → new_window
	cmd+page_up → scroll_page_up
	cmd+page_down → scroll_page_down
	cmd+home → scroll_home
	cmd+end → scroll_end
	shift+cmd+/ → open_url https://sw.kovidgoyal.net/kitty/
	shift+cmd+[ → previous_tab
	shift+cmd+] → next_tab
	opt+cmd+, → debug_config
	opt+cmd+r → clear_terminal reset active
	opt+cmd+s → toggle_macos_secure_keyboard_entry
	opt+cmd+page_up → scroll_line_up
	opt+cmd+page_down → scroll_line_down
	ctrl+cmd+space → kitten unicode_input
	ctrl+cmd+, → load_config_file
	ctrl+cmd+f → toggle_fullscreen
Changed shortcuts:
	ctrl+shift+b → launch --type=background --stdin-source=@last_cmd_output sh -c 'tee $(mktemp).html && open $_'
	ctrl+shift+h → launch --type=tab --stdin-source=@screen_scrollback bat --language bash
	ctrl+shift+j → launch --type=overlay --stdin-source=@last_cmd_output sh -c '/usr/local/bin/jq --color-output | /usr/local/bin/bat'
	ctrl+shift+k → launch --type=overlay --stdin-source=@last_cmd_output sh -c '/usr/local/bin/jq -L ~/.local/lib/jq/ "include \"utils\"; . | schema" --color-output | /usr/local/bin/bat'
	ctrl+shift+l → launch --type=overlay --stdin-source=@last_cmd_output bat --language bash
	ctrl+shift+n → set_tab_title
	ctrl+shift+o → launch --type=window --stdin-source=@last_cmd_output bat --language bash
	ctrl+shift+r → layout_action rotate
	ctrl+shift+u → launch --type=window --location=hsplit --stdin-source=@last_cmd_output sh -c '/usr/local/bin/jq --color-output | /usr/local/bin/bat'
	ctrl+shift+w → detach_tab ask
	ctrl+shift+z → clear_terminal reset active
	cmd+- → change_font_size all -1.0
	cmd+0 → goto_tab 9999
	cmd+1 → goto_tab 1
	cmd+2 → goto_tab 2
	cmd+3 → goto_tab 3
	cmd+4 → goto_tab 4
	cmd+5 → goto_tab 5
	cmd+6 → goto_tab 6
	cmd+7 → goto_tab 7
	cmd+8 → goto_tab 8
	cmd+9 → goto_tab 9
	cmd+= → change_font_size all +1.0
	cmd+k → neighboring_window right
	cmd+n → launch --type=tab --location=neighbor --cwd=current zsh --login
	cmd+r → launch --type=window --cwd=current ranger
	cmd+t → launch --type=tab --location=neighbor sh -c 'command cd $( command mktemp -d "/tmp/dir.$( command date +%Y.%m.%dT%H.%M.%S ).XXXX" ); exec zsh --login'
	cmd+w → combine : close_window
	shift+cmd+- → resize_window shorter 1
	shift+cmd+= → resize_window taller 1
	shift+cmd+d → launch --location=hsplit --cwd=current
	shift+cmd+i → launch --allow-remote-control kitty +kitten broadcast
	shift+cmd+w → close_other_windows_in_tab
Colors:
	active_border_color                #424242   
	active_tab_background              #2b303b   
	active_tab_foreground              #c0c5ce   
	background                         #2b303b   
	color0                             #757575   
	color1                             #ef5350   
	color10                            #81c784   
	color11                            #ffd8a0   
	color12                            #7eb7ce   
	color13                            #c0a5c0   
	color14                            #86c1b9   
	color15                            #f8f8f8   
	color16                            #d08770   
	color17                            #ab7967   
	color18                            #343d46   
	color19                            #4f5b66   
	color2                             #83b580   
	color20                            #a7adba   
	color21                            #dfe1e8   
	color3                             #f7ca88   
	color4                             #71a5b9   
	color5                             #ac94ac   
	color6                             #86c1b9   
	color7                             #d8d8d8   
	color8                             #757575   
	color9                             #e57373   
	foreground                         #e4e4e4   
	inactive_border_color              #424242   
	inactive_tab_background            #2b303b   
	inactive_tab_foreground            #757575   
	mark1_background                   #43a047   
	mark1_foreground                   #ffffff   
	mark2_background                   #ff6f00   
	mark2_foreground                   #ffffff   
	mark3_background                   #d32f2f   
	mark3_foreground                   #ffffff   
	tab_bar_background                 #2b303b   
	url_color                          #2196f3   

Important environment variables seen by the kitty process:
	PATH                                /Applications/kitty.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin
	LANG                                en_US.UTF-8
	SHELL                               /bin/zsh
	USER                                akharrou
@akharrou akharrou added the bug label Aug 17, 2022
@akharrou akharrou changed the title Can't copy last command in overlay window Can't copy output of last command from an overlay window Aug 17, 2022
@akharrou akharrou changed the title Can't copy output of last command from an overlay window Can't copy output of last command from an overlaid shell program window Aug 17, 2022
@akharrou akharrou changed the title Can't copy output of last command from an overlaid shell program window Can't copy output of last command (via launch --stdin-source=@last_cmd_output ...) from an overlaid shell program window Aug 17, 2022
@akharrou akharrou changed the title Can't copy output of last command (via launch --stdin-source=@last_cmd_output ...) from an overlaid shell program window Can't copy output of last command (via launch) from an overlaid shell program window Aug 17, 2022
@akharrou akharrou changed the title Can't copy output of last command (via launch) from an overlaid shell program window Can't copy output of last command (via `launch) from an overlaid shell program window Aug 17, 2022
@akharrou akharrou changed the title Can't copy output of last command (via `launch) from an overlaid shell program window Can't copy output of last command (via launch) from an overlaid shell program window Aug 17, 2022
@page-down
Copy link
Contributor

I've seen some users use overlay window as a window-level stack layout.

However, currently the overlay window is ignored when launch gets the active window.
It seems that overlay is not designed to be used that way. Currently launch ignores overlay window when getting the active window.
The same applies to all new_*_with_cwd actions.

Maybe a new window-level stack layout could be added, instead of using overlay.


Also allowing values like clipboard in the launch --type option I think is strange, just to reuse the -stdin-* options.

... launch ... run arbitrary programs in new windows/tabs. ...

--type <TYPE>
Where to launch the child process, ...

I see several places in the code where values are checked to exclude clipboard,primary, just to make sure launch is doing its main job.
This should have been a separate action, listed under the copy/paste category.
https://sw.kovidgoyal.net/kitty/actions/#copy-paste

If there were such a separate copy action, then the logic for launch to get the active window would not need to be changed, thus not affecting the original design intent.

Otherwise one needs to add another check opts.type not in ('background', 'os-window', 'overlay', 'tab', 'window').

@kovidgoyal
Copy link
Owner

kovidgoyal commented Aug 18, 2022 via email

@akharrou
Copy link
Author

akharrou commented Aug 18, 2022

I just want to add an example use-case that I've found interesting for overlays:

  1. you launch a new os-window, or a new tab, or new window pane, with a file explorer (e.g. ranger, lf)
  2. then navigate to whatever folder you want, do whatever you do in the explorer
  3. then when you need a shell inside that folder, instead of replacing the file explorer with a shell program, or have it to the side or in a new tab, you create a shell program overlay window, preserving the file explorer "under it", with all the 'in-app-tabs' (e.g. ranger tabs), and things you have open and going on, and work in that overlay.
  4. when your done your intervention, you just close that overlay window, and your back in the file explorer with all things preserved as they were
  • i've also found it nice to quickly lookup documentation/manual pages, without adding more tabs, or windows to the sides, and while preserving what i'm doing in the current shell program

i've personally found this a useful and powerful workflow, and i'm sure there's more use-cases. aside from simple pop-ups, overlay windows, i think could, and do, add a dimension to window management that can be powerful !

@page-down
Copy link
Contributor

page-down commented Aug 18, 2022

I dont see how that would work ... Overlays are meant for ...
They are not meantto be used as long term primary windows. ...

Yes, unfortunately not all users are aware of this and not all features are supported on overlay.
And they really enjoy with overlay.

https://www.reddit.com/r/KittyTerminal/comments/vx33wj/

a new window-level stack layout

Not something I see the use case for. ...

I believe they use kitty as a tiling window manager for terminal windows. (Can these wm switch the windows in the layout, like stack?)

... launch is working as intended ...

Yes, I believe so, any operations should target the base window, not the overlay.

You are welcome to create such an action and send a PR.
We can deprecate the use of clipboard/primary in launch in favor of the new action.

That's a good way to go.

@kovidgoyal
Copy link
Owner

@akharrou FYI, I would be very surprised if your file manager doesnt have a key binding to suspend itself, like ctrl-z in vim then you can use the shell and simply run fg to return. There shouldnt be a need of overlay windows in this case.

@kovidgoyal kovidgoyal reopened this Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants