I have zsh shell in a Linux server, and connect to the server from screen sessions in different computers. I'm trying to get control keys, such as home and end, to function correctly.Because zsh doesn't use the GNU Readline library, I need to take care of mapping the terminal sequences to zsh commands. First I use zkbd to find out the sequences sent by each key stroke, and then I map them to the correct commands. This is what I have in .zshrc:autoload zkbd[ ! -f ${ZDOTDIR:-$HOME}/.zkbd/$TERM-${DISPLAY:-$VENDOR-$OSTYPE} ] && zkbdsource ${ZDOTDIR:-$HOME}/.zkbd/$TERM-${DISPLAY:-$VENDOR-$OSTYPE}[ -n ${key[Backspace]} ] && bindkey ${key[Backspace]} backward-delete-char[ -n ${key[Home]} ] && bindkey ${key[Home]} beginning-of-line...Now I have two problems:Usually when I connect to the server, the sequence number in $DISPLAY environment variable gets a new value. Consequently, zkbd gets run, and I have to go through pressing all the control keys. Is it necessary to have the key sequences dependent on $DISPLAY?When I connect to the server from a screen session, $TERM environment variable will be set to screen. Still, depending on which computer I'm connecting from, the sequences of some keys differ (e.g. F1 is either ^[[11~ or ^[OP). How should I name the zkbd files in order to distinguish between the different mappings?
How to setup zkbd (zsh keyboard bindings) in a server?
zsh;keyboard;gnu screen;keyboard layout
Rather than simply use TERM=screen, the screen program has a feature which you could use to set different values of TERM.  This assumes that you've installed a complete ncurses terminal database, and use a TERM outside screen that corresponds to the actual terminal.For a given TERM, if there is a corresponding screen.$TERM entry in the terminal database, then screen will use that.  The ncurses terminal database has several of these, to match the actual behavior of terminals that set TERM=xterm, e.g.,screen.Eterm,screen.gnome,screen.konsole,screen.konsole-256color,screen.linux,screen.mlterm,screen.mlterm-256color,screen.mrxvt,screen.putty,screen.putty-256color,screen.rxvt,screen.teraterm,screen.vte,screen.vte-256color,screen.xterm-256color,screen.xterm-new,screen.xterm-r6,screen.xterm-xfree86.Once you've setup things to use the terminal database, there's no need for special/magic configuration files of your own.  Besides, how would you tell the server which file to use?  The real information is on your client, where you know which terminal emulator you are actually using.zsh lets you use this information directly with the $terminfo array.Further reading:Why not just use TERM set to xterm?Keybindings (see discussion of $terminfo[])