christoomey / vim-tmux-navigator

Seamless navigation between tmux panes and vim splits
MIT License
5.07k stars 319 forks source link

shell in tmux does not execute commands, enter does not work. #362

Closed benibilme closed 10 months ago

benibilme commented 10 months ago

Hello,

OS: manjaro 5.10.192-1-MANJARO
bash: 5.1.16(1) tmux: 3.3_a.7

I have following tmux configuration. In the provided configuration, the section marked between ===, has been directly copied and pasted from vim-tmux-navigator installation manual. I have only adjusted the keys according to my non latin1 keyboard for left, down, up, right movements which are respectively t,k,m,l in my system. I did not use provided plugin since I did not know how to change default keys to my custom keys in the plugin which is not mentioned in the documentation, so I had to copy and paste the configuration sniplet.

The modified configuration breaks enter command. The behavior can be repeated with following simple case. Open a terminal, start tmux, type any command in tmux, press Enter. Enter is not recognized.

However, original configuration, without my key modifications work. I kindly appreciate any insight why my re-mappings cause the problem.

Thanks in advance.

# activate mouse support
set -g mouse on

# start window index at 1 instead of 0
set -g base-index 1

setw -g pane-base-index 1

# highlight window when it has new activity
setw -g monitor-activity on
set  -g visual-activity  on

# re-number windows when one is closed
set -g renumber-windows on

#==============================================================

# 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|l?n?vim?x?)(diff)?$'"
bind-key -n 'C-t' if-shell "$is_vim" 'send-keys C-t'  'select-pane -L'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k'  'select-pane -D'
bind-key -n 'C-m' if-shell "$is_vim" 'send-keys C-m'  'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l'  'select-pane -R'

tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\'  'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\'  'select-pane -l'"

bind-key -T copy-mode-vi 'C-t' select-pane -L
bind-key -T copy-mode-vi 'C-k' select-pane -D
bind-key -T copy-mode-vi 'C-m' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l

#=============================================================

bind 'v' split-window -h -c '#{pane_current_path}'  # Split panes horizontal
bind 'h' split-window -v -c '#{pane_current_path}'  # Split panes vertically
bind 'c' new-window -c '#{pane_current_path}' # Create new window'"'

# Easier and faster switching between next/prev window
bind-key -n C-S-t swap-window -t -1\; select-window -t -1
bind-key -n C-S-l swap-window -t +1\; select-window -t +1

setenv -g TMUX_PLUGIN_MANAGER_PATH "$HOME/.config/tmux/plugins/"

# List of plugins
set -g @plugin 'tmux-plugins/tpm'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.config/tmux/plugins/tpm/tpm'
christoomey commented 10 months ago

'C-m' is interpreted as enter. You can test this with tmux bind-key -n 'C-m' display-message 'hello world'. I'm going to close this now as this isn't an issue with the plugin, but hopefully that helps point you in the right direction.

benibilme commented 10 months ago

Hello,

Thank you for the reply. Unfortunately I am totally dumb tmux user and clueless in its internal workings. Now can I solve this issue? Is possible to assign something else to enter?

christoomey commented 9 months ago

I'm not super familiar with this space myself, but I believe the issue is that the terminal interprets C-m as enter and I don't believe you can change this. Definitely possible that I'm wrong here, but that's my understanding.