kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.13k stars 971 forks source link

last_cmd_output include last prompt as well #7099

Closed 10b14224cc closed 8 months ago

10b14224cc commented 8 months ago

Describe the bug

Using starship, kitty @ get-text --extent=last_cmd_output returns the last prompt together with the last command output.

See also: https://github.com/mikesmithgh/kitty-scrollback.nvim/issues/179#issuecomment-1924045919

To Reproduce Steps to reproduce the behavior:

  1. Install starship
  2. issue some commands, like echo "hello" and echo "hi"
  3. Press kitty_mod+g
  4. kitty will page hi (output of last command) together with last prompt

Screenshots If applicable, add screenshots to help explain your problem.

image

Environment details

kitty 0.32.1 (2ab139a46e) created by Kovid Goyal
Linux HOSTNAME 6.7.3-arch1-2 #1 SMP PREEMPT_DYNAMIC Fri, 02 Feb 2024 17:03:55 +0000 x86_64
Arch Linux 6.7.3-arch1-2 (/dev/tty)

DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
Running under: Wayland
Frozen: False
Paths:
  kitty: /home/USERNAME/progetti_altrui/kitty/kitty/launcher/kitty
  base dir: /home/USERNAME/progetti_altrui/kitty
  extensions dir: /home/USERNAME/progetti_altrui/kitty/kitty
  system shell: /usr/bin/bash
Loaded config files:
  /home/USERNAME/.config/kitty/kitty.conf

Config options different from defaults:
active_tab_title_template {index}: {title[title.rfind('/')+1:]}
allow_remote_control      yes
background_opacity        0.75
confirm_os_window_close   0
enabled_layouts           ['tall:bias=50;full_size=1;mirrored=false']
font_family               FiraCode Nerd Font Mono
font_size                 18.0
listen_on                 unix:/tmp/kitty
tab_bar_style             powerline
tab_powerline_style       round
tab_title_template        {index}: {title[title.rfind('/')+1:]}
update_check_interval     0.0
Changed mouse actions:
    ctrl+shift+right press ungrabbed →  combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output
Added shortcuts:
    ctrl+enter →  send_text normal,application \x1b[13;5u
    kitty_mod+' →  change_font_size all -1.0
    kitty_mod+à →  move_tab_backward
    kitty_mod+è →  move_window_backward
    kitty_mod+ù →  move_tab_forward
    shift+enter →  send_text normal,application \x1b[13;2u
Changed shortcuts:
    kitty_mod++ →  move_window_forward
    kitty_mod+0 →  change_font_size all +1.0
    kitty_mod+enter →  new_window_with_cwd
    kitty_mod+f →  kitty_scrollback_nvim
    kitty_mod+h →  previous_tab
    kitty_mod+j →  previous_window
    kitty_mod+k →  next_window
    kitty_mod+l →  next_tab
    kitty_mod+o →  layout_action bias 90 80 70 60 50 40 30 20 10
    kitty_mod+p > f →  layout_action bias 10 20 30 40 50 60 70 80 90, kitten hints --type hyperlink, kitten hints --type linenum, kitten hints --type hash --program -, kitten hints --type word --program -, kitten hints --type line --program -, kitten hints --type path, kitten hints --type path --program -
    kitty_mod+r →  set_tab_title
    kitty_mod+t →  new_tab_with_cwd
Colors:
    active_border_color       #b7bdf8   
    active_tab_background     #c6a0f6   
    active_tab_foreground     #181926   
    background                #24273a   
    bell_border_color         #eed49f   
    color0                    #494d64   
    color1                    #ed8796   
    color10                   #a6da95   
    color11                   #eed49f   
    color12                   #8aadf4   
    color13                   #f5bde6   
    color14                   #8bd5ca   
    color15                   #a5adcb   
    color2                    #a6da95   
    color3                    #eed49f   
    color4                    #8aadf4   
    color5                    #f5bde6   
    color6                    #8bd5ca   
    color7                    #b8c0e0   
    color8                    #5b6078   
    color9                    #ed8796   
    cursor                    #f4dbd6   
    cursor_text_color         #24273a   
    foreground                #cad3f5   
    inactive_border_color     #6e738d   
    inactive_tab_background   #1e2030   
    inactive_tab_foreground   #cad3f5   
    mark1_background          #b7bdf8   
    mark1_foreground          #24273a   
    mark2_background          #c6a0f6   
    mark2_foreground          #24273a   
    mark3_background          #7dc4e4   
    mark3_foreground          #24273a   
    selection_background      #f4dbd6   
    selection_foreground      #24273a   
    tab_bar_background        #181926   
    url_color                 #f4dbd6   

Important environment variables seen by the kitty process:
    PATH                                /home/USERNAME/progetti_altrui/kitty/kitty/launcher:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/cuda/bin:/opt/cuda/nsight_compute:/opt/cuda/nsight_systems/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin
    LANG                                en_US.UTF-8
    SHELL                               /usr/bin/bash
    DISPLAY                             :0
    WAYLAND_DISPLAY                     wayland-1
    USER                                USERNAME
    XCURSOR_SIZE                        24
    XDG_BACKEND                         wayland
    XDG_SEAT                            seat0
    XDG_SESSION_TYPE                    wayland
    XDG_CURRENT_DESKTOP                 Hyprland
    XDG_SESSION_CLASS                   user
    XDG_VTNR                            1
    XDG_SESSION_ID                      3
    XDG_RUNTIME_DIR                     /run/user/1000
    LC_TIME                             en_DK.UTF-8
kovidgoyal commented 8 months ago

I'm afraid I dont have the time/interest to debug Starship's bash integration script. Last time I looked at it I found various issues. From your problem description I'd guess something is preventing the kitty shell integration script from output the escape code to indicate prompt extent and output start properly.

bash is the hardest shell to write robust scripts for, I suggest switching to zsh or fish instead, you are much less likely to encounter these kinds of issues.

If you wish to debug it yourself, kitty's script is in the file kitty.bash.

10b14224cc commented 8 months ago

If you wish to debug it yourself, kitty's script is in the file kitty.bash.

Do you mean kitty.bash in starship's repo?

So is this a starship bug?

kovidgoyal commented 8 months ago

Yes I would guess this is a starship bug, it is interfering with kitty's shell integration. And no kitty.bash is the kitty shell integration script. I dont remember what the starship bash integration file is called.

kovidgoyal commented 8 months ago

Actually I had 5 mins so I tried it and it doesnt repro for me with default kitty and starship configs.

10b14224cc commented 8 months ago

Actually I had 5 mins so I tried it and it doesnt repro for me with default kitty and starship configs.

I think is a ble.sh bug in interacting with starship.

It doesn't happen if I don't load ble.sh.

10b14224cc commented 8 months ago

Actually I had 5 mins so I tried it and it doesnt repro for me with default kitty and starship configs.

ble.sh's maintainer pinned it down: https://github.com/akinomyoga/ble.sh/issues/403#issuecomment-1935774146

akinomyoga commented 8 months ago

And #7107 is the fix.