Skip to content

Instantly share code, notes, and snippets.

@shawnbot
Last active March 22, 2024 16:26
Show Gist options
  • Save shawnbot/3277580 to your computer and use it in GitHub Desktop.
Save shawnbot/3277580 to your computer and use it in GitHub Desktop.
Make OS X Terminal respect 256 colors in screen

1. Ensure that Terminal declares itself as "xterm-256color"

Under Terminal > Preferences... > (Profile) > Advanced, "Declare terminal as:" should be set to xterm-256color.

2. Build a version of screen that supports 256 colors

This is easy with homebrew:

brew install screen

When this finishes you'll have a new binary in /usr/local/bin/screen.

3. Add the new screen binary to your path

Add /usr/local/bin to the front of your $PATH so that your shell uses this binary, and not the one in /usr/bin (you can confirm that it's using the correct one with which screen). If you're using the bash, this goes into your .bash_profile:

PATH="/usr/local/bin:$PATH"

If you're using another shell, then you probably already know where this goes. :)

@wilgoszpl
Copy link

I couldn't achive this goal. I run everything as you mentioned, but my terminal still shows only 16 colours. It declares xterm-256 screen is tapped and installed via homebrew, and which screen shows /usr/local/bin/screen. Also the path is set with /usr/local/bin at beginning. hash -r and hash -d screen has no effect. What have I missed?

I used default mac terminal and it probably doesn't support this color range

@symbiat
Copy link

symbiat commented Apr 12, 2016

BTW, the terminal type should be xterm-256color. Also IIRC, Terminal does indeed support 256 colors - you can test it yourself by copying and pasting the Perl script here into Terminal (if it works outside of screen but not inside it then you know its not Terminal).

@funkjunky
Copy link

Thanks a million!
If anyone is confused why, ATM, screen -v reports 4.0.3, when brew reports 4.3.0, don't worry about it, everything is fine.
[I thought the install wasn't working... but then after using ls -l on the bin file and seeing the sym link to cellar, I tried screen and the colours were working. [No more squinting at blue! Hurray!]]

@xkdcc
Copy link

xkdcc commented Dec 3, 2016

This is useful 👍
I was using 4.00.03 screen on Mac 10.11.
Even I set "export TERM=xterm-256color", the color looks a bit weird.
After using the one from homebrew, now it looks great!

@ddanieltan
Copy link

Super useful, following these instructions allowed me to have screen + vim in 256 colors.

Copy link

ghost commented Apr 2, 2018

"Error: homebrew/dupes was deprecated. This tap is now empty as all its formulae were migrated." :(

@shawnbot
Copy link
Author

Thanks, @mattietea. I've updated the instructions to suggest brew install screen now that homebrew/dupes is gone.

@buncis
Copy link

buncis commented Dec 20, 2020

is it still need to be done on big sur?

I have following it but it still not showing 256 colors on my terminal vim

@DryLabRebel
Copy link

@buncis I also had to ensure screen ran an interactive login shell. Put this in my.screenrc:

shell -$SHELL

Also $TERM may still be run as screen. So I put export TERM="xterm-256color" in my .bash_profile, so that when screen (or any login shell) is run, it explicitly sets 256 colors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment