7

I have searched around and the closes thing I could find to my issue is this:

https://stackoverflow.com/questions/23848061/cannot-get-delete-key-to-work-with-tmux-and-osx

I am running multiple versions of OSX and macOS and I am using iTerm2.

When I go into a tmux session my delete key does not work. I also try to use Ctrl+H and Ctrl+?, which those are not doing anything for me.

In iTerm preferences->keys, I have delete sent to ^H. In preferences->profiles->keys, I also have the box checked, Delete key send ^H.

Vim is able to delete in tmux but from the command line I can not.

.tmux.conf

# Set default term
set -g default-terminal "xterm"

# remap prefix to Control + a
set -g prefix C-a
unbind C-b
bind C-a send-prefix

# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf

# Start number at 1
set -g base-index 1

# UTF-8
set-option -g status-utf8 on

# supposedly fixes pausing in vim
set -s escape-time 1

# set default terminal
set -g default-terminal "xterm-color256"

# Vi copypaste mode
set-window-option -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
bind p paste-buffer

unbind %
unbind '"'
unbind [
bind | split-window -h
bind - split-window -v
bind ^C-s copy-mode
set-option -g default-shell /bin/zsh
setw -g history-limit 10000

#quick pane cycling
unbind ^A
bind ^A select-pane -t :.+

# Clear pane
bind C-l send-keys -R \; clear-history

# add airline to tmux status bar
if shell "test -f ~/.tmuxlinesnapshot" "source ~/.tmuxlinesnapshot"

Any help would be much appreciated!

4 Answers 4

9

To fix backspace on Apple M1 Pro OSX 12.4, tmux 3.3a I had to do the following

brew install ncurses
$(brew --prefix)/opt/ncurses/bin/infocmp tmux-256color > ~/tmux-256color.info
tic -xe tmux-256color ~/tmux-256color.info

https://github.com/tmux/tmux/issues/1257#issuecomment-581378716 https://gist.github.com/bbqtd/a4ac060d6f6b9ea6fe3aabe735aa9d95

3
  • This answer by @rado confirmed working on M1 Mac Mini running Monterey.
    – Rad
    Commented Jun 20, 2022 at 16:22
  • Are you both saying that the stty erase is not enough alone or this replaces that entirely?
    – bmike
    Commented Jun 20, 2022 at 16:25
  • Also, listing the version of iTerm or confirming other terminal apps are affected will help people pick the appropriate answer for their setup.
    – bmike
    Commented Jun 20, 2022 at 16:33
4

Tmux uses ^? for delete. stty was not sending ^?.

I changed that using stty erase '^?' and then changed my preferences in iTerm2 for delete to send ^?

https://github.com/tmux/tmux/issues/335

2
  • 1
    this isn't working for me Commented Jul 20, 2021 at 4:47
  • agree, not working
    – nisc
    Commented Aug 12, 2021 at 5:21
0

rado’s solution works, but puts a dot-dir into the home directory (~/.terminfo). Wanting to avoid cluttering my home directory, I tried setting the TERMINFO environment variable, using various combinations.

Unfortunately getting this right is finicky so here’s a step by step breakdown:

  1. Install ncurses (e.g. using Homebrew or Macports)

  2. From that ncurses installation, generate the terminfo source file:

    infocmp -x tmux-256color >tmux-256color.info
    
  3. Using the system ncurses, compile the terminfo:

    /usr/bin/tic -xe tmux-256color tmux-256color.info
    

    (At this point you can delete the tmux-256color.info file.)

  4. Move the generated ~/.terminfo folder to a sensible location:

    mv ~/.terminfo ~/Library/Application\ Support/terminfo
    
  5. Configure your shell to find that path (in .bashrc or .zshrc …):

    export TERMINFO_DIRS=${TERMINFO_DIRS+$TERMINFO_DIRS:}$HOME/Library/Application\ Support/terminfo
    

Done.

0

set -g default-terminal "xterm" in .tmux.conf seems to cause this problem.

Quick and simple solution: change "xterm" to "screen" (this is the default as of tmux 2.1) or "screen-256color".

The downside is that screen terminal description uses the italics escape sequence incorrectly, so italics will not be displayed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .