lanoxx / tilda

A Gtk based drop down terminal for Linux and Unix
GNU General Public License v2.0
1.28k stars 161 forks source link

256 colors in powerline and tmux #170

Closed sryze closed 9 years ago

sryze commented 9 years ago

I can't seem to get bash powerline to work in 256-color mode.

When I run tmux from within tilda, i.e. from a bash shell, everything works as expected. However, if tmux is started by tilda itself, i.e. as a custom shell, powershell runs with a reduced color palette (I guess it's 16 colors) and looks kind of ugly.

Initially I thought that tmux might not be getting the TERM variable that I set in .basrc when it gets run by tilda so I put it in /etc/environment - that didn't help. So ended up moving the /usr/bin/tmux binary somewhere else and calling it from a shell script replacing it. That seems to work fine but I didn't like it much and was kind of wondering:

Is there a more proper way to accomplish this with tilda?

lanoxx commented 9 years ago

The VTE Terminal automatically replaces the TERM environment variable with xterm, so setting it to something else before starting tilda does not have any effect, you can try the following things to see how environment setup works in tilda:

#execute tilda with FOO set to 'bar'
FOO='bar' tilda
#from inside tilda run
echo $FOO
#this should print 'bar'

The above is same whether you start a custom command or the default shell.

#execute tilda with TERM set to 'xterm+color256'
TERM='xterm+256color' tilda
#from inside tilda run
 echo $TERM
#notice its still set to TERM

The setting of TERM may behave differently whether you start a custom command or the default shell. When you start with the default shell (for example bash) then first VTE will override your TERM setting, but bash will set it again if you have configured it in ~/.bashrc or some other file that gets read during start (.profile or what ever).

When you run a custom command on the other hand then VTE will also replace TERM with xterm, but no shell is started, so your ~/.bashrc and similar files are not read and so TERM will not be set.

You can try the following custom command to work around this:

bash -c "export TERM='xterm+256color'; ipython"

This will explicitly use bash and export the correct TERM variable AFTER VTE has set TERM to xterm.

I am not really sure this is something that should be fixed in tilda. If you like you can take a look at src/tilda_terminal.c around line 450 this is where custom commands get started, if you want to suggest a modification I will be happy to try it.

There is also a function in vte: vte_terminal_set_emulation but I checked about gnome-terminal and it does not make use of this function either, so I assume that its not the correct way to do it.

Also I read: https://bbs.archlinux.org/viewtopic.php?id=175581 and it suggests not to mess with TERM in the terminal.

lanoxx commented 9 years ago

I also just found this: https://bugzilla.redhat.com/show_bug.cgi?id=1166428

Seems that VTE might have fixed it. You can try to build from the latest git master and enable VTE 2.91 if you system has it: --enable-vte-2.91.

lanoxx commented 9 years ago

Ok, I just tried this myself and I can confirm that VTE when used with the libvte-2.91 API now advertises xterm-256color for TERM. So I am closing this bug now.