The first problem is that your terminfo entry for screen
does not define a kDC3
capability; this is probably typical. You can either add this capability to your own custom screen
entry, or you can “hard code” the sequences in your bindkey
commands.
Adding the capabilities may help other programs know about the keys, but it decentralizes your configuration (it would be easy to forget about this customization when you manually replicate your configuration to a new machine or user account). You can extract the appropriate entries with infocmp
and build a new entry with tic
:
{ infocmp -xT screen ; infocmp -x1T xterm | grep -E '^\tkDC[3-8]?=' ; } >/tmp/s
tic -x /tmp/s
If you run tic as a user that has write access to your terminfo directory (e.g. /usr/share/terminfo
), then the new entry will be placed there (probably overwriting the original entry); otherwise, it will be placed under ~/.terminfo
(or TERMINFO, if you have that environment variable set).
For completeness, you may want to use (UP|DN|RIT|LFT|PRV|NXT|HOM|END|IC|DC)
instead of DC
in the grep pattern to capture the modified versions of Up, Down, Right, Left, PageUp, PageDown, Home, End, Insert, and Delete.
If you dislike the configuration decentralization caused by customizing your terminfo entry, then you can “hard code” the value instead. To make it a bit better, you can check for kDC3
first:
bindkey -e ${$(tput kDC3 2>/dev/null):-'\e[3;3~'} kill-word
To restrict this “hard coding” to just screen
-based TERM values:
altdel=$(tput kDC3 2>/dev/null)
[[ -z $altdel && $TERM == screen(|-*) ]] && altdel='\e[3;3~'
[[ -n $altdel ]] && bindkey -e $altdel kill-word
unset altdel
This will work as long as your terminal emulator (stack) ends up generating the xterm-style sequence for the modified key.
Once to have a binding, you will still need to turn on the xterm-keys
option in tmux so that it will generate the xterm-style sequences for keys passed into its panes. E.g. in your ~/.tmux.conf
:
set-option -wg xterm-keys on