perder colorscheme vim en modo tmux


Estoy ejecutando iterm2 y cuando estoy en modo tmux el esquema de color que he establecido en vim no aparece. Sólo el esquema de color que he establecido en iterm. Si corro vim desde el shell el esquema de color aparece correctamente - es solo cuando estoy en modo tmux.

He intentado configurar :colorscheme molokai cuando está en vim (imagen siguiente) y no cambia: de nuevo, el esquema de color predeterminado para iterm2 permanece.

Me falta alguna configuración para iterm o tmux.conf? Mis dotfles están en Github.

Author: Blaszard, 2012-04-15

16 answers

Yo tenía el mismo problema. La única diferencia era que estoy usando solarize en lugar de molokai.

Para solucionar el problema, he configurado un alias en ~/.bashrc:

alias tmux="TERM=screen-256color-bce tmux"

Y configura la opción default-terminal en ~/.tmux.conf:

set -g default-terminal "xterm"

Por último, haga $ source ~/.bashrc para cargar un nuevo alias.

 230
Author: Seyeong Jeong,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-04-22 01:23:12

Como @ romainl menciona anteriormente, necesitaba forzar a tmux a usar 256 colores agregando la bandera -2:

$ tmux -2

Agregué alias tmux='tmux -2' a mi bash_profile, así que no me olvido:)

 66
Author: tristen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-06-23 02:00:10

Probé todas las soluciones anteriores y lo que finalmente funcionó para mí es poner las siguientes líneas en .tmux.conf:

set -g default-terminal "xterm-256color"
 55
Author: ElefEnt,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-14 13:53:37

Acabo de descubrir por qué estaba teniendo mucha confusión. Yo, como otros aquí, estaba teniendo dificultades para conseguir que la configuración de terminal predeterminada entrara en vigor. Recordé que tenía una sesión de tmux en el fondo. Reenganché mi sesión, cerré mis procesos y cerré TODOS los procesos de tmux. La próxima vez que reinicié tmux la configuración de terminal por defecto en .tmux.conf comenzó a surtir efecto. No se si otros están haciendo esto también, pero recomiendo cerrar todos los procesos de tmux antes modificando el archivo .tmux.conf.

Conseguí que mi configuración funcionara en mi máquina local (OSX 10.9.5 con iTerm2) sin ninguna modificación a .bashrc o .bash_profile. Todo lo que hice fue agregar la línea set -g default-terminal "xterm-256color" a ~/.tmux.conf y reiniciar todos los procesos de tmux.

Conseguí que mi configuración remota (ssh a Ubuntu 14.04) funcionara exactamente de la misma manera sin ninguna modificación a .bashrc. Simplemente agregué set -g default-terminal "xterm-256color" a ~/.tmux.conf en mi máquina remota y reinicié todos los procesos remotos de tmux.

Puedes probar lo que Vim está viendo haciendo echo $TERM desde una sesión de tmux. Seguía diciendo screen como el valor hasta que reinicié todos los procesos de tmux, momento en el que reflejaba xterm-256color como se esperaba.

Espero que eso ayude.

 23
Author: Chev,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-09-19 18:18:35

Así que esto es un poco obsoleto, pero vale la pena mencionar que usar screen a menudo romperá las teclas Home y End. Usando

export TERM="xterm-256color"

In debe mantener la funcionalidad de estos y permitir que el esquema de color (o powerline) funcione bien.

 19
Author: Jpatrick,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-06-10 20:36:22

Necesitaba que vim se mostrara correctamente con tmux en terminal en ubuntu y cygwin/mintty en windows. Conseguí que funcionara combinando respuestas como esta.

In .bashrc:

alias tmux="tmux -2"

In .vimrc:

" use 256 colors in terminal
if !has("gui_running")
    set t_Co=256
    set term=screen-256color
endif

" fix cursor display in cygwin
if has("win32unix")
    let &t_ti.="\e[1 q"
    let &t_SI.="\e[5 q"
    let &t_EI.="\e[1 q"
    let &t_te.="\e[0 q"
endif

Basado en las respuestas de esta pregunta, esta página wiki de Vim y esta pregunta de cursor de bloque

 12
Author: Andrew Johnston,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-20 10:04:24

He probado todas las instrucciones anteriores, y descubrí que lo más importante es que tengo que agregar explícitamente la siguiente línea en mi .archivo bashrc.

export TERM=screen-256color

No se porque alias tmux="TERM=screen-256color-bce tmux" no funciona. Uso Sierra 10.12.1.

 9
Author: Lion Lai,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-01-13 02:16:21

En caso de que alguien necesite soporte de color de 24 bits:

Tmux soporta color de 24 bits a partir de la versión 2.2. Si su terminal admite color de 24 bits, agregue su terminal a la configuración terminal-overrides. Por ejemplo,

set -ga terminal-overrides ",xterm-256color:Tc"

Mi lista de verificación de entorno:

  • macOS Sierra 10.12.3
  • iTerm2 3.0.14 (El tipo de terminal de informe es xterm-256color)
  • neovim 0.1.7 (Habilita el color de 24 bits agregando: xterm-256color a .vimrc)
  • tmux 2.3 (Añadir set -ga terminal-overrides ",xterm-256color:Tc" a .tmux.conf)

Nada de lo contrario necesito agregar .bashrc o .zshrc.

Espero que esto pueda ayudar.

 8
Author: Yanzhe Chen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-02-26 03:48:43

Añadiendo la siguiente línea.tmux.conf trabajó para mí con macOS Sierra 10.12.6,

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

 4
Author: Zack Zhu,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-28 19:17:54

Si utiliza tmuxinator o mux, tendrá que agregar estos en .bashrc o .zshrc:

alias tmux='TERM=screen-256color tmux -2'
alias tmuxinator='TERM=screen-256color tmuxinator'
alias mux='TERM=screen-256color mux'

Estas fuerzas para utilizar 256-color en terminal.

Entonces tmux, tmuxinator y el comando mux funcionará.

 3
Author: qingxp9,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-12-23 03:53:25

Para configurar el color correcto y deshacerse del problema de renderizado tanto en Ubuntu como en Mac:

Compruebe esto

 1
Author: Munish,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-20 10:18:14

Desde la página man de tmux, añadiendo flag como sigue:

tmux -2

Esta bandera -2 obliga a tmux a ejecutarse en modo de 256 colores.

Esto funciona para mí

 1
Author: RyanLiu,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-14 14:13:34

Si te encuentras en la misma situación que yo, que ninguna de las anteriores funcionó.. prueba esto:

En .tmux.conf:

set -g default-terminal "xterm"

En la configuración de bash (tal vez .bashrc o .bash_profile):

alias tmux="tmux -2"

Y luego ejecutar:

killall tmux

Y luego relanzar tmux

 1
Author: eliasbagley,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-14 14:16:57

No tuve mucha suerte al intentar exportar un TERM diferente o establecer default-terminal en mi .tmux.conf.

Mi solución para arreglar colores vim dentro de tmux fue agregar esta línea a .tmux.conf:

set -g terminal-overrides 'xterm:colors=88'

No estoy seguro de por qué se necesitaba esta anulación dado que mi TERM=xterm y yo tenemos iTerm establecido en xterm también, pero parece funcionar.

 1
Author: Patrick Lewis,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-14 16:05:37

Ya que este es el primer resultado en Google y ya que ninguno de los anteriores ayudó..quería publicar esto para que alguien pudiera encontrarlo útil

En .vimrc:

set background=dark
set t_Co=256

HTH

 1
Author: HK_,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-02-23 04:28:54

Solo tuve que lidiar con este problema, y aunque todas las respuestas publicadas anteriormente fueron útiles, no resolvieron el problema en mi caso.

Mi problema se solucionó eliminando la siguiente línea en mi .vimrc:

set termguicolors

Que era redondante con otra instrucción de todos modos.

Ahora, con la siguiente línea encontrada en anwsers anteriores en mi .tmux.conf:

export TERM="screen-256color"

Todo es bonito y colorido.

 0
Author: Nitlev,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-01 21:26:09