I'm using zsh and tmux with powerline. When I launch tmux from my zsh shell it breaks the zsh powerline prompt.
I've stripped down both the .zshrc and the .tmux.conf files to the bare minimum to ensure that this problem is not being caused by something else:
cat .zshrc
> source /usr/local/lib/python2.7/dist-packages/powerline/bindings/zsh/powerline.zsh
cat .tmux.conf
> set-option -g default-terminal "screen-256color"
> source /usr/local/lib/python2.7/dist-packages/powerline/bindings/tmux/powerline.conf
I've attached a screenshot:

Any ideas?
What is your terminal?
terminator.
Same issue with me, but with different colors on Guake compared to Terminator.


Without tmux (shown in Terminator):

Could this possibly be (due to|solved by) this third comment by Nicholas Marriott? Re: color escape codes from tmux to the underlying terminal.
Edit:
Issue is somewhat affected by setting additional_escapes to tmux in config.json. Setting term_truecolor to true didn't help (the docs state Gnome Terminal isn't 24bit anyway - and it uses the same virtual terminal engine as Guake and Terminator, python-vte). Neither did setting additional_escapes to screen.
As you can see the shell prompt itself renders okay at times.. but once the tmux pane or tmux window is switched, the colors for the prompt vanish. One then needs to switch back to prompt and hit enter to get a fresh one with color. Vim colors still broken.

In addition setting additional_escapes to tmux in config.json really screws with the prompt when outside of tmux. I think it's probably to be set with a command-line argument or environment variable, but as I found in #849 , I haven't found a way for env variables to work in zsh.
I'm not sure if the escape codes are the problem - while the colorization is an obvious issue when running zsh in tmux - the zsh prompt segments defined in the zsh prompt are not present either - the hostname segment is not populated, nor is the timestamp segment I defined in ~/.config/powerline/themes/shell/config.json.
@nfarrar My hostname segment isn't being populated either (with or without tmux), but my timestamp is just fine. Are you sure you have the right configuration? Here's mine for timestamp in ~/.config/powerline/themes/shell/default.json:
{
...
"segments": {
...
"right": [
...
{
"name": "date",
"args": {
"format": "%H:%M:%S",
"istime": true
}
}
]
}
}
@appleYaks I'm not positive I have the correct configuration. I haven't fully dug into the powerline source code yet. I know that my modifications populate the segments in zsh and it seems to work correctly except when running tmux.
I have also tested this with the default configuration and when launching tmux from zsh the hostname is still not populated (so I believe it's an issue with powerline and not my configuration).
My full configuration is located here: https://github.com/nfarrar/dotfiles-powerline/tree/master/.config/powerline
I didn't modify the root config.json, I added my zsh modifications to ~/.config/powerline/themes/shell/default.json:
{
"default_module": "powerline.segments.common",
"segment_data": {
"hostname": {
"before": "î‚¢ ",
"args": {
"only_if_ssh": false
}
},
"virtualenv": {
"before": "â“” "
},
"branch": {
"before": "î‚ "
},
"date": {
"args": {
"format": "%H:%M:%S %Y-%m-%d"
}
}
},
"segments": {
"left": [
{
"name": "hostname"
},
{
"name": "user"
},
{
"name": "virtualenv"
},
{
"name": "cwd",
"args": {
"dir_limit_depth": 3
}
},
{
"module": "powerline.segments.shell",
"name": "jobnum"
}
],
"right": [
{
"module": "powerline.segments.shell",
"name": "last_pipe_status"
},
{
"name": "branch"
},
{
"name": "date"
}
]
}
}
@nfarrar Not sure how shell segment config relates to tmux in the source, but try my config snippet as a workaround for now and see if it works. I'm not a powerline developer -- just trynna' help. :)
I think this problem is fixed by running tmux with the -2 argument to tell it the terminal supports 256 colors. Tmux color gradients for battery always show as red for 100% though, which I fixed by creating a new color gradient that's the reverse of the old one.
$ tmux -2 -f .tmux.conf
@appleYaks This does appear to fix the issue - thank you :)
@nfarrar no problemo. glad it's fixed for ya! :)
Most helpful comment
I think this problem is fixed by running tmux with the
-2argument to tell it the terminal supports 256 colors. Tmux color gradients for battery always show as red for 100% though, which I fixed by creating a new color gradient that's the reverse of the old one.