Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Depending on how I run screen, it either does or does not have the right TERMCAP info. The symptom of this is that colors don't always show up in my terminal correctly (eg: ls, vim syntax highlighting, etc).

This works fine:

$ echo $TERMCAP
  <empty output>
$ screen -S foo
$ screen -r foo
  <now I'm inside a screen session>
$ echo $TERMCAP
  <long output>
$ ls
  <nice pretty colors>

This has problems:

$ echo $TERMCAP
  <empty output>
$ screen -d -m -S foo
$ screen -r foo
  <now I'm inside a screen session>
$ echo $TERMCAP
  <long output, but different than before>
$ ls
  <no colors ):>

Now, I can work around this. I can fiddle with my TERMCAP manually, etc.

But I'd really like to understand what's going on. I'd like to find a 'clean' solution, if possible.

Does anybody know what's going on here? What difference should it make if I use -d -m when running screen?

This is on FreeBSD, if that matters.

share|improve this question
Does ls --color=auto work? Could make an alias for it. – frostschutz Mar 11 '13 at 20:20
@frostschutz: No such option on FreeBSD's ls. I doubt it would make a difference though. I have LSCOLORS set up. – jwd Mar 13 '13 at 22:11
up vote 0 down vote accepted

Well, I got something not too gross to fix the issue:

In my script where I am creating screen sessions, I have near the top:

# This runs the commands:
# TERM=screen
# TERMCAP='...'
# with values appropriate for a 'screen' terminal
eval "$(tset - -s screen | tail -n+2)"

# Set up the SCREENCAP variable, which 'screen' will use for new sessions

# ...

screen -d -m -S my-session

Now, when I connect to my-session, terminal colors work.

Not entirely satisfactory, but works well enough.

share|improve this answer

Your Answer


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.