Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an odd predicament. I want to detect on the remote end of an ssh connection if the client is running the terminal inside a screen session. I want to set my prompt based on this. So far I have tried using remotehost:~/.ssh/env[1] and the SendEnv option in my localhost:~/.ssh/config to send my $STY variable[2]; but both have failed.

So I was wondering if there is any other way to achieve this?

Footnotes:

[1] This doesn't work since it doesn't evaluate anything, I can't set things up dynamically.

[2] This requires AcceptEnv be allowed on the remote end. This is not possible because I'm not the admin on the remotehost and even if I were, the man sshd_config advises against it.

share|improve this question
    
On my system, screen sets the $TERM variable, and it is reflected on the remote host $TERM variable. –  artistoex Dec 4 '11 at 1:04
    
related: superuser.com/questions/174494/… –  lesmana Dec 4 '11 at 7:26
    
@artistoex Sorry I forgot to mention that I'm set term to xterm –  suvayu Dec 4 '11 at 9:45
    
@lesmana That seems to answer my question adequately. I should have searched more carefully. –  suvayu Dec 4 '11 at 9:46
add comment

1 Answer

Try this:

if [ "${TERM}" == "screen" ]
then
    # Set prompt to something special for screen.
fi

Here is the relevant quote from the screen manpage:

   term term

   In  each  window's  environment  screen opens, the $TERM variable is set to "screen" by default.  But when no description for "screen" is installed in the
   local termcap or terminfo data base, you set $TERM to - say - "vt100". This won't do much harm, as screen is VT100/ANSI compatible.  The use of the "term"
   command is discouraged for non-default purpose.  That is, one may want to specify special $TERM settings (e.g. vt100) for the next "screen rlogin otherma-
   chine" command. Use the command "screen -T vt100 rlogin othermachine" rather than setting and resetting the default.
share|improve this answer
    
As I mentioned in my comment, I already set TERM to something else to resolve other issues (e.g. scrolling). I did get my answer in the thread referred to by artistoex. –  suvayu Jan 7 '12 at 9:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.