At the time the sshd process on the remote computer forks to run /usr/bin/xterm there are very few environment variable set. In fact the LANG variable is not set. Hence the xterm process does not know that it should display characters in UTF-8. It falls back to xterms defaults. Whatever that might be.
However, the subshell running inside the xterm runs all setup scripts and alike.
Including setting the LANG environment variable.
One needs to understand the difference between the remote xterm process and the shell process running inside of xterm.
The solution is to run the remote xterm process like this:
/usr/bin/env LANG=en_US.UTF-8 /usr/bin/xterm
env(1) is a utility to run a program in a modified environment.
Setting LANG will make the remote xterm display UTF-8 characters properly.
Eskil...
:-)
P.s: Reading the xterm manual page I also found an easier way to achieve this:
xterm -en en_US.UTF-8
P.P.s: I do not think setting resources in ~/.Xresources will take effect unless you merge them in with xrdb. The xterm process on the Linux computer will query the X server running on your windows computer. At the time where xterm starts it is very unlikely that your X-Win32 server has the xterm* resources set. But you might be able to set resources in X-Win32 if it supports that.
If using bash
, the following should do the trick:
TOLASTLINE=$(tput cup "$LINES")
PS1="\[$TOLASTLINE\]$PS1"
Or (less efficient as it runs one tput
command before each prompt, but works after the terminal window has been resized):
PS1='\[$(tput cup "$LINES")\]'$PS1
To prevent tput
from changing the exit code, you can explicitly save and reset it:
PS1='\[$(retval=$?;tput cup "$LINES";exit $retval)\]'$PS1
Note that the variable retval
is local; it doesn't affect any retval
variable you might have defined otherwise in the shell.
Since most terminals cup
capability is the same \e[y;xH
, you could also hardcode it:
PS1='\[\e[$LINES;1H\]'$PS1
If you want it to be safe against later resetting of PS1, you can also utilize the PROMPT_COMMAND
variable. If set, it is run as command before the prompt is output. So the effect can also be achieved by
PROMPT_COMMAND='(retval=$?;tput cup "$LINES";exit $retval)'
Of course, while resetting PS1
won't affect this, some other software might also change PROMPT_COMMAND
.
Best Answer
That's usually done by changing the instance name, which by default is the name of the program which is run, but can be overridden using the
-name
option. (If you make a symbolic link to a program and run that link, that's a quick way of renaming a program as well).If you have a resource file with settings like
the instance is the
xterm
at the beginning of the line.You can also change the class name (which you commonly see as
XTerm
, also at the beginning of the resource lines). Theuxterm
script uses the-class
option to override this to change settings to makexterm
work consistently in UTF-8 mode.If you have different class names, then you can use the app-defaults search mechanism to support different resource files. I set the environment variable
XAPPLRESDIR
to my own directory, and have locally-customized resource files (each named for a class). That is documented in X(7):