I'm currently setting $TERM
to xterm-256color
:
if [[ -n "$EMACS" ]]; then
export TERM=xterm-256color
alias emacs="emacsclient --no-wait"
export EDITOR="emacsclient --no-wait"
export VISUAL="emacsclient"
fi
I used to have it set to eterm-color
, but the problem is that this terminal type is not available on most of the machines I log into via SSH.
The default .bashrc
in Ubuntu checks if the TERM
variable starts with xterm-
, in which case it tries to set the window title:
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
The problem is the \[\e]0;
bit. It should be parsed by xterm-compatible terminal emulators, but emacs (ansi-term) doesn't do that. The result of which is a terminal like this:
0;user@host: ~user@host:~$
It also breaks some applications using readline
, when the typed text is larger than the width of the terminal.
Because eterm-color
isn't available on some remote hosts (and I can't install it either), setting it to that value messes up things like less
.
Is there any trick I can use, such as another terminal type that ships with most distributions or a hack that makes ansi-term recognize the relevant escape codes and set the title, or just discard them?