You are not logged in.

#1 2023-12-24 02:03:14

benibilme
Member
Registered: 2020-06-03
Posts: 41

How to disable Ctrl-M in bash.

Hello,

I am using tmux/nvim heavily on alacritty terminal. 

I am using non latin1 keyboard and instead of h,j,k,l keys, I need to use t,k,m,l keys.

When I map m to in place of k terminal in tmux, the alacritty terminal  becomes unusable since I can not use enter and execute a command. Following is the setting that I am using. I realized that in bash Ctrl-M is synonym for enter. I do not know if the problem is in tmux or in bash or in alacritty side? 

I appreciate any insight. This is a section of tmux.conf file.

# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator

# decide whether we're in a Vim process
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

bind-key -n 'C-t' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-m' if-shell "$is_vim" 'send-keys C-k' '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 -n 'C-Space' if-shell "$is_vim" 'send-keys C-Space' 'select-pane -t:.+'

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-key -T copy-mode-vi 'C-Space' select-pane -t:.+

Offline

#2 2023-12-24 08:50:16

seth
Member
Registered: 2012-09-03
Posts: 58,655

Re: How to disable Ctrl-M in bash.

You can't fix that in bash, the terminal emulator generates the same events for enter and ctrl+m but you can configure many of them to not to.

~/.config/alacritty/alacritty.yml

- { key: M,   mods: Control,   chars: "\v" }

Online

Board footer

Powered by FluxBB