arl / tmux-gitbar

Git in your tmux status bar
GNU General Public License v3.0
170 stars 16 forks source link

'bad colour' error written to terminal after every command #23

Closed ghost closed 8 years ago

ghost commented 8 years ago

With the default settings, and I see the declarations in the tmux-gitbar.conf, this gets written to my terminal.

bad colour: fg=white,bg=black

Ubuntu Wily gnome-terminal

arl commented 8 years ago

Which version of tmux and tmux-gitbar do you use? A quite similar issue was already reported and fixed, see #13

In case you are using a version pre 1.0.0, you should update it, just be aware of the very light breaking change , described in the README

Thanks for reporting.

ghost commented 8 years ago

I just pulled from master today after discovering the project. Which is awesome by the way.

I am running tmux 2.0

ghost commented 8 years ago

It does only happen outside of git working directories as mentioned in #13

arl commented 8 years ago

Ok so in this case I confirm the issue and will investigate. Could you please attach here you tmux.conf or copy paste it please.? For the rest, you have the default settings right, default tmux-gitbar.conf?

ghost commented 8 years ago

yes default tmux-gitbar.conf

Below is my tmux.conf. Pretty simple, I have kinda just used the same configuration with minor tweaks that I made a year ago when I first discovered tmux. Don't make fun of any stupidities lol.

unbind C-b
unbind [
unbind p
unbind o
unbind l
unbind u
unbind o
unbind i
unbind j
unbind k
unbind l
set -g prefix C-a
bind C-a send-prefix
set -sg escape-time 1
set -sg base-index 1
set -g default-terminal "screen-256color"
setw -g mode-keys vi
setw -g pane-base-index 1
bind = split-window -h
bind - split-window -v
bind R source-file ~/.tmux.conf \; display "Reloaded!"
bind Escape copy-mode
bind p paste-buffer
bind o choose-buffer
bind -t vi-copy 's' begin-selection
bind -t vi-copy 'c' copy-selection
bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
bind l pipe-pane -o "cat >>~/Desktop/tmux_log.txt" \; display "Toggled logging to Desktop"
bind -r j resize-pane -L 10
bind -r l resize-pane -R 10
bind -r u resize-pane -U 10
bind -r o resize-pane -D 10
bind i swap-pane -U
bind k swap-pane -D
source-file "$HOME/.tmux-gitbar/tmux-gitbar.tmux"

EDIT: Aha! Thanks for pointing out the triple tick.

arl commented 8 years ago

When inside tmux, could you please show me the output of:

echo $TERM
ghost commented 8 years ago
~$ echo $TERM
screen-256color
bad colour: fg=white,bg=black
bad colour: fg=white,bg=black
~$ 
arl commented 8 years ago

Thanks for your help in resolving this issue. Still when inside tmux, you have the default green status bar, right? And if you run this, what happens:

tmux set -g status-bg black
ghost commented 8 years ago

I have the default green.

When running

tmux set -g status-bg black

The status bar changes to grey but the bad colour output continues.

arl commented 8 years ago

The status bar changes to grey but the bad colour output continues.

Yes but it should change to black, not grey. I suspect a color configuration problem of your tmux.conf, your terminal configuration, or environment variables (through .bashrc). I also have this line in my tmux.conf, I'm on Ubuntu with gnome-terminal, guake works fine also, as other terminals I tried:

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

Maybe this could help?

Now I remember having problems myself to set the tmux color configuration myself. I have this line in my .bashrc though:

export TERM=xterm-256color

Sorry to not be clearer about that but I found the correct setting after some trial and errors and don't remember which one finally worked!

arl commented 8 years ago

Sorry but the tmux-gitbar status bar is displayed correctly when inside a working tree?

ghost commented 8 years ago

Yes it works correctly inside a working tree.

I added

export TERM=xterm-256color

to my .bashrc. Something I had before but not on my new installation. I have also tried suggestions in those posts, but the issue persists. Perhaps I'll keep poking around.

ghost commented 8 years ago

I've tried other terminals, but I still get the error.

I tried removing

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

but it still didn't work.

Is it worth mentioning that the first time the error is thrown it actually reads:

bad colour: fg=white,bg=black,bright
bad colour: fg=white,bg=black,bright

And then all subsequent errors are just

bad colour: fg=white,bg=black
bad colour: fg=white,bg=black
arl commented 8 years ago

Ok. Update me if you find anything so that I can fix or update the README. I'll keep looking as well for a way to reproduce. Le 9 mars 2016 19:05, "aizimmer" notifications@github.com a écrit :

I've tried other terminals, but I still get the error.

I tried removing

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

but it still didn't work.

Is it worth mentioning that the first time the error is thrown it actually reads:

bad colour: fg=white,bg=black,bright bad colour: fg=white,bg=black,bright

And then all subsequent errors are just

bad colour: fg=white,bg=black bad colour: fg=white,bg=black

— Reply to this email directly or view it on GitHub https://github.com/aurelien-rainone/tmux-gitbar/issues/23#issuecomment-194427757 .

ghost commented 8 years ago

Ha okay so I was cruising around different ways of specifying colors in tmux, and landed on trying colorXXX notation.

So for example in my tmux-gitbar.conf I set

readonly TMGB_BG_COLOR='color232'
readonly TMGB_FG_COLOR='color255'

What happened is the inverse of the bug. The functionality of your script isn't changed and I still get live updates to the working tree. But now outside of a working tree the errors go away, except inside a working directory I get

bad colour: color255
bad colour: color232

And then when leaving the working directory I get the one time

bad colour: bright
bad colour: bright

I think you were right before in that this is a versioning issue. What version of tmux do you run?

ghost commented 8 years ago

Further information.

Using hex notation in my .tmux.conf produces correct colors (i.e. "#000000" for black). But then the bad colour error becomes

bad colour: fg=colour231,bg=colour16
bad colour: fg=colour231,bg=colour16

OUTSIDE of working trees.

I believe tmux dropped the English spelling "colour" in 1.9 for the American spelling "color". Though using hex is backwards compatible.

EDIT: This is with hex notation in both .tmux.conf and tmux-gitbar.conf. Changing tmux-gitbar.conf back to defaults produces the original error.

ghost commented 8 years ago

Ok I found something...the issue is with the save_statusbar amd reset_statusbar functions, and it might be out of your control.

Maybe I'm just being too lazy to find it but where do you set that "TMGB_STATUS_LOCATION" variable. Because I see you are also explicitly following it with 'fg' or 'bg'

arl commented 8 years ago

Interesting It's tested on tmux 2.1 built from source and 1.9 from ubuntu standard apt repo. I'll look into that Don't think I've time tonight tough Thanks for the update Le 9 mars 2016 20:42, "aizimmer" notifications@github.com a écrit :

Ha okay so I was cruising around different ways of specifying colors in tmux, and landed on trying colorXXX notation.

So for example in my tmux-gitbar.conf I set

readonly TMGB_BG_COLOR='color232' readonly TMGB_FG_COLOR='color255'

What happened is the inverse of the bug. The functionality of your script isn't changed and I still get live updates to the working tree. But now outside of a working tree the errors go away, except inside a working directory I get

bad colour: color255 bad colour: color232

And then when leaving the working directory I get the one time

bad colour: bright bad colour: bright

I think you were right before in that this is a versioning issue. What version of tmux do you run?

— Reply to this email directly or view it on GitHub https://github.com/aurelien-rainone/tmux-gitbar/issues/23#issuecomment-194472910 .

arl commented 8 years ago

TMGB_STATUS_LOCATION is set in tmux-gitbar.conf

Le 9 mars 2016 21:36, "Aurelien RAINONE" aurelien.rainone@gmail.com a écrit :

Interesting It's tested on tmux 2.1 built from source and 1.9 from ubuntu standard apt repo. I'll look into that Don't think I've time tonight tough Thanks for the update

Le 9 mars 2016 20:42, "aizimmer" notifications@github.com a écrit :

Ha okay so I was cruising around different ways of specifying colors in tmux, and landed on trying colorXXX notation.

So for example in my tmux-gitbar.conf I set

readonly TMGB_BG_COLOR='color232' readonly TMGB_FG_COLOR='color255'

What happened is the inverse of the bug. The functionality of your script isn't changed and I still get live updates to the working tree. But now outside of a working tree the errors go away, except inside a working directory I get

bad colour: color255 bad colour: color232

And then when leaving the working directory I get the one time

bad colour: bright bad colour: bright

I think you were right before in that this is a versioning issue. What version of tmux do you run?

— Reply to this email directly or view it on GitHub.

ghost commented 8 years ago

TMGB_STATUS_LOCATION is set in tmux-gitbar.conf

Oh duh, ha.

Well the issue appears to be reset_statusbar getting bad data from save_statusbar. I am able to work around the issue by switching off readonly on TMGB_OUTREPO_FG_COLOR and TMGB_OUTREPO_BG_COLOR. And then in the reset_statusbar function explicity setting them to "default"

arl commented 8 years ago

Thanks a lot get to the bottom of this. Still, I'm not sure I understand why. Looking at tmux changelogs I found nothing of interest. I'll compile tmux 2.0 and try to reproduce, I'll hopefully be able to provide a backward-forward compatible fix, as I'd not like to have to add some code switches, depending on the version of tmux

ghost commented 8 years ago

I am unsure but the tmux built-in 'default' might actually represent whatever is in the user's rc file. Which could in theory make the whole save_statusbar function unnecessary.

Though I am speaking entirely from speculation, as it is working for me sure enough, but I can't verify backwards compatibility.

arl commented 8 years ago

I am unsure but the tmux built-in 'default' might actually represent whatever is in the user's rc file. Which could in theory make the whole save_statusbar function unnecessary.

For the style attribute, or fg and bg: default means the default color of your terminal. It's not what is in the user rc file.

arl commented 8 years ago

From tmux changelogs:

Deprecated Changes

  • The various foo-{fg,bg,attr} commands have been deprecated and replaced with equivalent foo-style option instead. Currently this is still backwards-compatible, but will be removed over time.

So I came up with this PR #24 (not merged for now) that replaces this deprecated syntax. It hopefully will fix the issue you have :smiley: If you happen to have the time to pull it and see if that fixes the issue, I'd be eternally grateful! Didn't have the time to try on a tmux v2.0

ghost commented 8 years ago

Will do

arl commented 8 years ago

:+1:

ghost commented 8 years ago

Looks good so far. Well done my friend

arl commented 8 years ago

:tada: Good news! I'll use this branch myself at home, on tmux 1.9 and tomorrow at work, where I've got tmux 2.1. If you and I do not see some any problems after having used it, I'll merge this into master.

Thanks again for your contribution, my way to reward you is a comment line in the source code! 14d8290 :gift:

:smiley:

ghost commented 8 years ago

I just compiled 2.1 on my work computer (where I've been tinkering) and am not seeing any issues so far. I'll defer to your best judgment though, for more in depth testing.

arl commented 8 years ago

Ha ok, well done! There's not so much to test honestly, but tinkering with different sessions, paths (in/out of git), trying with different tmux status string configurations (tmux.conf) tmux-gitbar has a unit-test suite, but that doesn't include yet this kind of tests. However I'm currently working on a integration test suite that work with a VT100 terminal emulator, with colors! When this will be ready, all of this will be automatically testable. But for now, let's wait until tomorrow and I'll merge this if nothing hapens.

arl commented 8 years ago

I merged #24