Kitty: strange selection behaviour inside tmux

Created on 11 Mar 2018  Â·  6Comments  Â·  Source: kovidgoyal/kitty

When I do text selection when inside tmux (check example https://imgur.com/a/6P8Pi) :

  1. While touchpad is pressed down nothing is highlited as a selection
  2. After releasing the touchpad selection is highlighted and includes all text from the top until text which I have selected.
  3. After selection is shown, selection disapears almost instantly leaving me no ability to copy text using ctl+shit+c

System info:

  • Arch Linux
  • Gnome 3.26
  • kitty 0.8.0
  • tmux 2.6

~/.config/kitty/kitty.conf

font_family      Fira Code
italic_font      auto
bold_font        auto
bold_italic_font auto
font_size        12.0

cursor_shape          block
cursor_blink_interval 0

enable_audio_bell no

remember_window_size   no
initial_window_width   1640
initial_window_height  840

#
# --- Solorized dark color scheme
#

# base02  (black)
color0    #073642

# base03  (black bright)
color8    #002b36

# red     (red)
color1    #dc322f

# orange  (red bright)
color9    #cb4b16

# green   (green)
color2    #859900

# base01  (green bright)
color10   #586e75

# yellow  (yellow)
color3    #b58900

# base00  (yellow bright)
color11   #657b83

# blue    (blue)
color4    #268bd2

# base0   (blue bright)
color12   #839496

# magenta (magenta)
color5    #d33682

# violet  (magenta bright)
color13   #6c71c4

# cyan    (cyan)
color6    #2aa198

# base1   (cyan bright)
color14   #93a1a1

# base0   (white)
color7    #839496

# base3   (white bright)
color15   #fdf6e3

#
# --- Misc
#

foreground              #839495
background              #073642

selection_foreground    #073642
selection_background    #eee8d5

cursor                  #839496
focus_follows_mouse     yes

active_border_color     #00ff00
inactive_border_color   #cccccc

active_tab_foreground   #000
active_tab_background   #eee

inactive_tab_foreground #444
inactive_tab_background #999

~/.tmux.conf

UptoTmux21="[ $(echo \"`tmux -V | cut -d\" \" -f2` <  2.1\" | bc) = 1 ]"
FromTmux21="[ $(echo \"`tmux -V | cut -d\" \" -f2` >= 2.1\" | bc) = 1 ]"
UptoTmux24="[ $(echo \"`tmux -V | cut -d\" \" -f2` <  2.4\" | bc) = 1 ]"
FromTmux24="[ $(echo \"`tmux -V | cut -d\" \" -f2` >= 2.4\" | bc) = 1 ]"
OnMacOS="[ \"$(uname)\" == \"Darwin\" ]"

set   -g base-index 1               # enumerate windows starting from 1
setw  -g pane-base-index 1          # enumerate panes starting from 1
set  -sg escape-time 1              # set no delay for escape key press

# set terminal window title to be a name of tmux window
set-option -g set-titles on
set-option -g set-titles-string "#S / #W"

if-shell "$OnMacOS" 'set -g default-shell $SHELL'
if-shell "$OnMacOS" 'set -g default-command "reattach-to-user-namespace -l ${SHELL}"'

# diasble mouse (see also toggle mouse):

if-shell "$UptoTmux21" 'set -g mode-mouse off'
if-shell "$UptoTmux21" 'set -g mouse-resize-pane off'
if-shell "$UptoTmux21" 'set -g mouse-select-pane off'
if-shell "$UptoTmux21" 'set -g mouse-select-window off'

if-shell "$FromTmux21" 'set -g mouse on ; set -g mouse off'

# save current path when open new panes

bind-key c   new-window   -c "#{pane_current_path}"
bind-key %   split-window -h -c "#{pane_current_path}"
bind-key '"' split-window -v -c "#{pane_current_path}"

# vim keybindings for panes traversal

unbind Left
unbind Down
unbind Up
unbind Right

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# use vim keys for traversal in selection and copy mode
# (note: not copy and paste from system clipboard)

setw -g mode-keys vi

if-shell "$UptoTmux24" 'unbind -t vi-copy Space'
if-shell "$UptoTmux24" 'unbind -t vi-copy Enter'
if-shell "$UptoTmux24" 'bind -t vi-copy v begin-selection'
if-shell "$UptoTmux24" 'bind -t vi-copy y copy-selection'
if-shell "$UptoTmux24" 'bind -t vi-copy Escape cancel'

if-shell "$FromTmux24" 'unbind -Tcopy-mode-vi Space'
if-shell "$FromTmux24" 'unbind -Tcopy-mode-vi Enter'
if-shell "$FromTmux24" 'bind -Tcopy-mode-vi v send -X begin-selection'
if-shell "$FromTmux24" 'bind -Tcopy-mode-vi y send -X copy-selection'
if-shell "$FromTmux24" 'bind -Tcopy-mode-vi Escape send -X cancel'

# Toggle activity monitor (see also status-right)

set -g monitor-activity off

bind M-a \
  set -w monitor-activity on \;\
  display "Monitor Activity ON"

bind C-a \
  set -w monitor-activity off \;\
  display "Monitor Activity OFF"

# reload tmux config file

bind M-r \
  source-file ~/.tmux.conf \;\
  display-message "reLoad ~/.tmux.conf"

# reassign windows numbers

bind M-w \
  move-window -r \;\
  display-message "reEnumerating windows..."

# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n M-h if-shell "$is_vim" "send-keys M-h"  "select-pane -L"
bind-key -n M-j if-shell "$is_vim" "send-keys M-j"  "select-pane -D"
bind-key -n M-k if-shell "$is_vim" "send-keys M-k"  "select-pane -U"
bind-key -n M-l if-shell "$is_vim" "send-keys M-l"  "select-pane -R"
bind-key -T copy-mode-vi M-h select-pane -L
bind-key -T copy-mode-vi M-j select-pane -D
bind-key -T copy-mode-vi M-k select-pane -U
bind-key -T copy-mode-vi M-l select-pane -R


# toggle mouse (see also status-right):

if-shell "$UptoTmux24" 'bind M-m set -g mode-mouse on \; set -g mouse-resize-pane \; set -g mouse-select-pane \; set -g mouse-select-window \; display "Mouse ON"'
if-shell "$UptoTmux24" 'bind C-m set -g mode-mouse off \; set -g mouse-resize-pane \; set -g mouse-select-pane \; set -g mouse-select-window \; display "Mouse OFF"'

if-shell "$FromTmux21" 'bind M-m set -g mouse on \; display "Mouse ON"'
if-shell "$FromTmux21" 'bind C-m set -g mouse off \; display "Mouse OFF"'


# Statusline
set -g status-interval 1

# status left

set -g status-left "#[fg=colour2]â–‰#[fg=colour4]â–‰#[fg=colour5]â–‰#[fg=colour10] #[bold]#H:#[fg=colour14]#S "
set -g status-left-length 48

# status right

set -g status-right "#(tmux show -w monitor-activity) "

if-shell "$UptoTmux21" 'set -ga status-right "mouse #(tmux show -gv mode-mouse) "'
if-shell "$FromTmux21" 'set -ga status-right "mouse #(tmux show -gv mouse) "'

set -ga status-right "%a-%d-%b %T #[fg=colour5]â–‰#[fg=colour4]â–‰#[fg=colour2]â–‰"
set -g status-right-length 56
set -g status-justify left

# WINDOWS
set -w -g window-status-current-format " #[bold]#I:#W#F "
set -w -g window-status-format " #I:#W#F "
set -w -g alternate-screen on

# COLORS
set -g default-terminal "screen-256color"
########################################################################################
#                                                                                      #
# base03  colour8      These colors match solarized my gnome-terminal palette          #
# base02  colour0                                                                      #
# base01  colour10                                                                     #
# base00  colour11     solarized:                                                      #
# base0   colour12     http://ethanschoonover.com/solarized                            #
# base1   colour14                                                                     #
# base2   colour7      solarized for gnome-terminal:                                   #
# base3   colour15     https://github.com/sigurdga/gnome-terminal-colors-solarized     #
# yelow   colour3                                                                      #
# orange  colour9      solarized colors for directories(ls):                           #
# red     colour1      https://github.com/seebi/dircolors-solarized                    #
# magenta colour5                                                                      #
# violet  colour13                                                                     #
# blue    colour4                                                                      #
# cyan    colour6                                                                      #
# green   colour2                                                                      #
#                                                                                      #
########################################################################################
set -g status-bg colour0                        # Base02
set -g status-fg colour3                        # Yellow
set -g message-bg colour0                       # Base02
set -g message-fg colour3                       # Yellow
set -w -g window-status-bg colour0              # Base02
set -w -g window-status-fg colour14             # Base3
set -w -g window-status-current-bg colour3      # Yellow
set -w -g window-status-current-fg colour0      # Base02
set -w -g window-status-current-attr bold
set -w -g window-style 'bg=colour0'             # bg color of active pane
set -w -g window-active-style 'bg=colour8'      # bg color of active pane
set -g pane-border-fg colour10                  # Base01
set -g pane-border-bg colour0                   # Base03
set -g pane-active-border-fg colour3            # Yellow
set -g display-panes-active-colour colour3      # Blue
set -g display-panes-colour colour4             # Yellow
set -w -g clock-mode-colour colour2             # Green

Most helpful comment

Just press ctrl+shift+h and make your selections in peace. Press esc when done.

All 6 comments

selection works normally for me on Arch with tmux 2.6. It's likely caused by something in your tmux config. I'm not a tmux user so I can't guess what that might be, but on general principles it is likely something to do with mouse mode.

I get a similar issue to this with weechat, I assume do to the clock I have which has seconds, so I'm assuming that causes redraws or something, this also interferes with clicking links. Is there a way in kitty to do like a "Screen grab" that would just take a static grab of the current contents so I could select/click links?

See the hints mode or browsing the scrollabck buffer in a separate program in the readme.

@raku-cat I have the same issue, my tmux clock has seconds, and every time the second changes, any selection made (using the shift modifier, which means this is not tmux handling the selection) is discarded. Hints mode is not that much of a help because I usually want to select arbitrary bits of text, not necessarily a URL, a path or even a whole line - also, kitty's square selection tool is/would be very useful in that regard.

I tested in vte-based terminals and this behavior does not occur; when the second changes, the current selection isn't affected. Could vte's behavior be ported to kitty?

Just press ctrl+shift+h and make your selections in peace. Press esc when done.

Worked with ctrl+shft+h but ... what is this key combination supposed to do? :-)

Was this page helpful?
0 / 5 - 0 ratings