kovidgoyal / kitty

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

Bash and Zsh Vi-Mode Cursor Not Changing Properly #5393

Closed austinliuigi closed 2 years ago

austinliuigi commented 2 years ago

Describe the bug

Upon a new instance (opening a new tab or window of kitty) of bash or zsh, cursor types defined in .inputrc or .zshrc depending on vi mode acts incorrectly. However, if you start bash or zsh using bash or zsh, it works correctly.


To Reproduce

Steps to reproduce the behavior:

  1. Add lines to change cursor in vi-mode (located at the bottom of this post) in .inputrc or .zshrc
  2. Open kitty with bash or zsh as the default shell
  3. Play around in normal and insert mode
  4. See error


Screenshots

1. Using bash as default shell:

bash.webm

Note that I enter normal mode right before I move the cursor


2. Using zsh as default shell:

zsh.webm


We can also see that in both bash and zsh, the cursor changes work properly when using the GNOME Terminal that ships with Ubuntu.


Environment details

kitty 0.25.2 created by Kovid Goyal
Linux bigtoe 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64
Ubuntu 22.04.1 LTS bigtoe /dev/tty

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"
Running under: X11
Frozen: True
Paths:
  kitty: /home/austin/.local/kitty.app/bin/kitty
  base dir: /home/austin/.local/kitty.app/lib/kitty
  extensions dir: /home/austin/.local/kitty.app/lib/kitty-extensions
  system shell: /usr/bin/zsh
Loaded config files:
  /home/austin/.config/kitty/kitty.conf

Config options different from defaults:
background_opacity      0.92
bold_font               mononoki Nerd Font Mono Bold
bold_italic_font        mononoki Nerd Font Mono BoldItalic
enabled_layouts         ['grid']
font_family             mononoki Nerd Font Mono Regular
font_size               13.0
hide_window_decorations 2
initial_window_height   (1000, 'px')
initial_window_width    (1000, 'px')
italic_font             mononoki Nerd Font Mono Italic
macos_option_as_alt     3
tab_bar_edge            1
tab_bar_margin_height   TabBarMarginHeight(outer=0, inner=5.0)
tab_bar_style           powerline
tab_powerline_style     slanted
Added shortcuts:
    ctrl+shift+t > ctrl+shift+h → previous_tab
    ctrl+shift+t > ctrl+shift+l → next_tab
    ctrl+shift+t > ctrl+shift+n → new_tab_with_cwd
    ctrl+shift+w > ctrl+shift+h → neighboring_window left
    ctrl+shift+w > ctrl+shift+j → neighboring_window bottom
    ctrl+shift+w > ctrl+shift+k → neighboring_window top
    ctrl+shift+w > ctrl+shift+l → neighboring_window right
    ctrl+shift+w > ctrl+shift+n → new_window
Removed shortcuts:
    ctrl+shift+t → new_tab
    ctrl+shift+w → close_window
Colors:
    background              #2e3440   
    color0                  #3b4252   
    color1                  #bf616a   
    color10                 #a3be8c   
    color11                 #ebcb8b   
    color12                 #81a1c1   
    color13                 #b48ead   
    color14                 #8fbcbb   
    color15                 #eceff4   
    color2                  #a3be8c   
    color3                  #ebcb8b   
    color4                  #81a1c1   
    color5                  #b48ead   
    color6                  #88c0d0   
    color7                  #e5e9f0   
    color8                  #4c566a   
    color9                  #bf616a   
    cursor                  #81a1c1   
    foreground              #d8dee9   

Important environment variables seen by the kitty process:
    PATH                                /home/austin/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/austin/.local/bin/
    LANG                                en_US.UTF-8
    EDITOR                              vim
    SHELL                               /usr/bin/zsh
    DISPLAY                             :1
    USER                                austin
    XDG_SESSION_TYPE                    x11
    XDG_SESSION_CLASS                   user
    XDG_RUNTIME_DIR                     /run/user/1000
    XDG_MENU_PREFIX                     gnome-
    XDG_CURRENT_DESKTOP                 ubuntu:GNOME
    XDG_SESSION_DESKTOP                 ubuntu
    XDG_DATA_DIRS                       /usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
    XDG_CONFIG_DIRS                     /etc/xdg/xdg-ubuntu:/etc/xdg


Additional context

kovidgoyal commented 2 years ago

https://sw.kovidgoyal.net/kitty/shell-integration/#configuration

Or1g3n commented 2 months ago

would you mind explaining what info in the link provided resolves this issue? I am new to terminal configs in general and read that entire section but still have no idea what the path is to resolve the problem. Just as the OP described the vim cursor behavior works as expected in gnome terminal.

kovidgoyal commented 2 months ago

If you have issues with vim not changing your cursor, either use nvim which will, or configure vim to do it, as described in the kitty FAQ

Or1g3n commented 2 months ago

@kovidgoyal Thanks a lot Kovid for the quick response! I just realized what the root cause of the issue was. In order to get the cursor size to change depending on vim mode in bash, you have to update the .inputrc file (at least for the solution I found online). I just learned that kitty doesn't utilize the .inputrc file which explains why this solution led to a successful result in gnome terminal but not in kitty. At any rate, today I ended up switching to zsh as my shell and however zsh handles vim mode works perfectly in kitty (cursor size changes without problem depending on mode). Thanks again for the quick response, kitty has quickly become my favorite terminal emulator; the kitten theme configure feature is awesome!