Skip to content

Instantly share code, notes, and snippets.

@shawnbot
Last active March 22, 2024 16:26
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • 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. :)

@madsmith
Copy link

Something worth noting is that bash will hash the path that commands resolve to. You can see this when running type screen. If you just installed screen you may need to run hash -d screen to clear screen from bashes path resolution hash. Alternatively, close your session and open a new bash instance.

@sangheonhan
Copy link

Thank you.

@pabo
Copy link

pabo commented Dec 12, 2014

Thanks. I also needed to rehash ( I used hash -r ) to get the proper command in my path.

@miratus
Copy link

miratus commented Jan 2, 2015

Many thanks: worked as advertised. I tried to get screen-for-OSX to work but ran into a number of issues. This just worked right off the bat, so many thanks: vertical split was my actual goal and now I have it!

@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