Getting 256 colors to work in tmux

  • I have 256 colors working just fine in konsole,. I thought I'd give tmux a try because, unlike screen, it seems to support vi mode. However I find that the colors of my prompt show up and this is most likely because I have a 256 color mode prompt. What do I need to do to get tmux to recognize all 256 colors?

    `tmux -2` I had to do this in *terminator* and I was somewhat surprised. The `-2` flag tells tmux to force the usage of 256 colors ... whether your terminal likes it or not ... dun dun dunnn :P

  • The Tmux FAQ explicitly advises against setting TERM to anything other than screen or screen-256color in your shell init file, so don't do it!

    Here's what I use:

    ~$ which tmux
    tmux: aliased to TERM=xterm-256color tmux
    

    and in in my .tmux.conf:

    set -g default-terminal "screen-256color"
    

    Aliasing tmux to "tmux -2" should also do the trick.

    I like the way to set it in the .tmux.conf best... using the shell to set it just doesn't seem right

    Weird. You don't need `tmux -2` on OSX but you need it with Gnome Terminal. Thanks for the info, added to my aliases!

    In Kubuntu 13.10 the .tmux.conf setting alone did not get me my 256 colors back (which took out highlighting in vim visual mode) but the alias worked. Would certainly prefer a .tmux.conf file only solution.

    ssh'd into an Ubuntu machine (from OS X Terminal), the .tmux.conf default-terminal was all I needed.

    Here is a relevant ticket: http://sourceforge.net/p/tmux/tickets/67/ ("tmux always sets TERM=screen"). There is an entry in `TODO` (source): "use screen-256color when started on 256 colour terminal?"

    for me it seems like all I need to do is `TERM=screen-256color tmux` without creating a `.tmux.conf` file. Am I missing something?

    Thank you for this :) I spent such a long time trying to figure this out.

    Thank you very much for this. I was going crazy because text of some applications was being rendered as black text on a black background.

    I lost color when I ssh'd into a different machine, this solves it!

    and don't forget to restart the tmux server! tmux kill-server && tmux. Thanks to @mast3r

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM