*: Since =condor_nsenter= does not run as a child of the =sshd=, but as a child of the =starter=, it can not pass on the =DISPLAY= environment variable to the user session.
 *: In many cases, when containers are used, the actual users may not have a home directory on the execute node, or might not have it mounted inside the container. However, we cannot override the location to store the =.Xauthority= file with the environment variable =XAUTHORITY= since =sshd= prunes that.
 
+Another related issue is that the =TERM= environment variable is not inherited from the =condor_ssh_to_job= command, which may lead to strange behaviour of special key escape sequences (e.g. =HOME= or =END= keys).
+
 {subsubsection:A possible workaround}
-To solve both issues at once, we can make use of the fact that =sshd= is spawned and configured by HTCondor via the =condor_ssh_to_job_sshd_config_template=. The location of this template can be set via the knob =SSH_TO_JOB_SSHD_CONFIG_TEMPLATE=.
+To solve all these issues at once, we can make use of the fact that =sshd= is spawned and configured by HTCondor via the =condor_ssh_to_job_sshd_config_template=. The location of this template can be set via the knob =SSH_TO_JOB_SSHD_CONFIG_TEMPLATE=.
 We can patch the file shipped with HTCondor and add the line:
   XAuthLocation /usr/local/bin/condor_xauth_wrapper
 Subsequently, we can create the wrapper script (make sure it is executable) with the following content:
@@ -72,14 +74,15 @@
 # This does NOT work, since env.sh is sourced as forced command, too early.
 #echo "export DISPLAY=${DISPLAY}" >> ${SSH_TO_JOB_DIR}/env.sh
 
-# Ugly hack needed with HTCondor 8.8.10 which does not yet pass through DISPLAY.
+# Ugly hack needed with HTCondor 8.8.10 which does not yet pass through DISPLAY or TERM.
 echo "export DISPLAY=${DISPLAY}" > ${JOB_WORKING_DIR}/.display
+echo "export TERM=${TERM}" >> ${JOB_WORKING_DIR}/.display
 
 export XAUTHORITY=${JOB_WORKING_DIR}/.Xauthority
 /usr/bin/xauth "$@" </dev/stdin
 {endverbatim}
 ----
-Please note that this script is pretty verbose, and handles very unlikely errors not observed in practice (yet). Most of the code is just there to find out which directory is used as the execute directory for the job, then place the =DISPLAY= environment variable inside a file =.display= in there, and finally adjust the environment variable =XAUTHORITY= to place the =.Xauthority= file there.
+Please note that this script is pretty verbose, and handles very unlikely errors not observed in practice (yet). Most of the code is just there to find out which directory is used as the execute directory for the job, then place the =DISPLAY= environment variable and the =TERM= environment variable inside a file =.display= in there, and finally adjust the environment variable =XAUTHORITY= to place the =.Xauthority= file there.
 
 This script works combined with two environment hack inside the container:
 *: The container needs to use the execute directory as =HOME= directory. You can for example do that by setting =SINGULARITY_HOME= in the =STARTER_JOB_ENVIRONMENT= knob, which you may likely touch anyways to set =SINGULARITY_NOHOME=true= if you run without the users' home directories on the execute node.
@@ -104,8 +107,9 @@
 {verbatim}
 #!/bin/bash
 
-# Ugly hack needed with HTCondor 8.8.10 which does not yet pass through DISPLAY.
+# Ugly hack needed with HTCondor 8.8.10 which does not yet pass through DISPLAY or TERM.
 echo "export DISPLAY=${DISPLAY}" > ${JOB_WORKING_DIR}/.display
+echo "export TERM=${TERM}" >> ${JOB_WORKING_DIR}/.display
 
 export XAUTHORITY=${JOB_WORKING_DIR}/.Xauthority