nordtheme / tmux

An arctic, north-bluish clean and elegant tmux color theme.
https://www.nordtheme.com/ports/tmux
MIT License
1.06k stars 141 forks source link

Support tmux-weather plugin. #43

Open kierun opened 4 years ago

kierun commented 4 years ago

Source

Supporting that plugin would be great.

kierun commented 4 years ago

Here is a screen shot of me doing just that. I replaced the date (which I do not need) with the weather:

screenshot

All working but for the e at the end of the status. No idea how to get ride of it…

nikita-y commented 4 years ago

Hey @kierun I have a very similar solution without problem with the 'e' at the end Also I used -ga option to split the lines. It helps a lot when you playing with the parameters.

#+--- Bars ---+
set -g status-left "#[fg=black,bg=blue,bold] #S "
set -ga status-left '#[fg=black,bg=blue]#{?window_zoomed_flag, Z ,}'
set -ga status-left "#[fg=blue,bg=black,nobold,noitalics,nounderscore]"

set -g status-right  "#{prefix_highlight}"
set -ga status-right "#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]"
set -ga status-right "#[fg=white,bg=brightblack] %a %b %d "
set -ga status-right "#[fg=white,bg=brightblack,nobold,noitalics,nounderscore]"
set -ga status-right "#[fg=white,bg=brightblack] #{weather}"
set -ga status-right "#[fg=cyan,bg=brightblack,nobold,noitalics,nounderscore]"
set -ga status-right "#[fg=black,bg=cyan,bold] %H:%M "

#+--- Windows ---+
set -g window-status-format  "#[fg=black,bg=brightblack,nobold,noitalics,nounderscore] "
set -ga window-status-format "#[fg=white,bg=brightblack]#I "
set -ga window-status-format "#[fg=white,bg=brightblack,nobold,noitalics,nounderscore] "
set -ga window-status-format "#[fg=white,bg=brightblack]#W #F "
set -ga window-status-format "#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]"

set -g window-status-current-format  "#[fg=black,bg=cyan,nobold,noitalics,nounderscore] "
set -ga window-status-current-format "#[fg=black,bg=cyan]#I "
set -ga window-status-current-format "#[fg=black,bg=cyan,nobold,noitalics,nounderscore] "
set -ga window-status-current-format "#[fg=black,bg=cyan]#W #F "
set -ga window-status-current-format "#[fg=cyan,bg=black,nobold,noitalics,nounderscore]"

I hope it will help

kierun commented 4 years ago

Hey @kierun I have a very similar solution without problem with the 'e' at the end

Thank you! I removed all my lines, added yours, and the "e" vanished. Sadly, it was replaced by "n"!

Running tmux 3.1, in case that's an issue…

Also I used -ga option to split the lines. It helps a lot when you playing with the parameters.

Now, that is a superb option! Thank you.

kierun commented 4 years ago

Itrestingly enough, messing around some options, I got this:

Untitled

Colour me confused…

nikita-y commented 4 years ago

Running tmux 3.1, in case that's an issue…

@kierun I'm running tmux 3.1 on macos catalina 10.15.4. I don't have the issue.

However I'm using a self-made weather plugin. Out of curiosity I switched to plugin by xamut and I immediately noticed some problems with the alignment. self-made: image by xamut: image

kierun commented 4 years ago

@nikita-y Yes, there is some weird alignment going on. When I maximise then minimise the window, I get a 1/2 character gap which is filled with black where the extra character was. Trying xamut's minus Nord does not show this problem.

Just if it matters: this happens on both Ubuntu and Fedora. It really should not matter…

arcticicestudio commented 4 years ago

Adding dedicated support for every plugin would mean that the bar will burst when there are more requests from other users. That's why this plugin only provides a minimal default content to prevent bloat.

Of course I'm very aware that users should be able to customize the content to fit their needs, but unfortunately the current implementation of the plugin doesn't allow to simply modify single elements but only disable the default content at all.

There are more open requests in this repository for other plugins and a way to design the content per user configurations, but I haven't got the time to refactor the plugin to allow this. I'd appreciate every PR and contribution to make this possible.

So for the weather plugin the only way is to customize the plugin sources on your own or disable the default content at all like described in the documentations I've linked above. Sorry for not being able to provide this feature at the moment.

kierun commented 4 years ago

@arcticicestudio No worries whatsoever. Thank you for you work and explanations. Sadly, I am at the limits of my knowledge of tmux configuration so would not even know where to start to help even if I had the time. ☹ However, do let me know if you want anything tested in the future.

All the best and thank you for a super theme! ☺

nicm commented 4 years ago

The problem seems like your terminal, font and/or libc disagreeing about the width of the Unicode codepoints you are using for the weather symbols. You could try rebuilding tmux with --enable-utf8proc.

kierun commented 4 years ago

@nicm I use st and that should support uft8… Of course, it is a trivially simple terminal which means it might not work.

I tried re-compiling tmux with --enable-utf8proc and get the same issue:

; ldd `which tmux`
        linux-vdso.so.1 (0x00007f85e1672000)
        libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f85e0f95000)
        libutf8proc.so.2 => /usr/lib/x86_64-linux-gnu/libutf8proc.so.2 (0x00007f85e0d4c000)
        libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f85e0b22000)
        libevent-2.1.so.6 => /usr/lib/x86_64-linux-gnu/libevent-2.1.so.6 (0x00007f85e08d1000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f85e06b6000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f85e02c5000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f85e00a6000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f85e144c000)
nicm commented 4 years ago

It is not about general support for UTF-8 it is about the widths of the characters, if tmux and the terminal have different ideas about the width of characters that you use then the status line will not be aligned properly. Either it will be too long and wrap onto the following line, or it will be too short and there will be stray output at the end (like in your case).

Are you sure you restarted tmux entirely after rebuilding? tmux kill-server.

What is the actual character that is causing a problem?

kierun commented 4 years ago

@nicm

Are you sure you restarted tmux entirely after rebuilding? tmux kill-server.

Yes, I did.

What is the actual character that is causing a problem?

So far it seems to be any of the weather icons. @nikita-y seems not to have problems when they are not using them.

nicm commented 4 years ago

Right, but I don't know what weather icons are, can you copy and paste one of them here?

kierun commented 4 years ago

Right, but I don't know what weather icons are, can you copy and paste one of them here?

Ah, I see. Here are some examples:

; curl -s 'wttr.in/{Paris,london,moscow,tokyo}?format=3'
Paris:⛅ +17°C
london: ☀ +15°C
moscow: 🌩 +24°C
tokyo:⛅ +19°C

And how it looks on my terminal:

Untitled

nicm commented 4 years ago

I see the same problem on OS X, libc doesn't know the width of this symbol so tmux assumes it is width 1. If you run for example tmux -Ltest -f/dev/null -vv new then do:

printf '⛅\n'
exit

Do you see this in the log?

$ grep Unicode tmux-server*.log
1588597364.430575 Unicode 26c5, wcwidth() -1

If I build with libutf8proc then tmux gets the correct width 2.

What version of utf8proc do you have? I have 2.5.0.

nicm commented 4 years ago

I think you will have trouble actually if st is also using wcwidth(), so you may need to use a different terminal.

kierun commented 4 years ago

Do you see this in the log?

Sadly, I see nothing in the logs.

What version of utf8proc do you have? I have 2.5.0.

I have 2.1.0-1 which is the default Ubuntu one.

I think you will have trouble actually if st is also using wcwidth(), so you may need to use a different terminal.

St does use that. Using gnome-terminal, I do not get the problem.

nicm commented 4 years ago

If you look for top_bit you will see the width tmux is using:

$ grep top_bit tmux-server-*.log
1588599649.505904 input_top_bit_set 3 '\342\233\205' (width 2)

If tmux is using width 2 (with or without utf8proc), and it works in gnome-terminal, then it sounds like an st problem and you would be best talking to them about it.

kierun commented 4 years ago

Ah, it does look like a st problem then:

; grep top_bit tmux-server-*.log
13206:1588599861.114720 input_top_bit_set 3 '\342\233\205' (width 2)
13426:1588599861.851887 input_top_bit_set 3 '\342\233\205' (width 2)
13855:1588599862.339703 input_top_bit_set 3 '\342\233\205' (width 2)

I shall open a bug (if I can figure out how) with them and link to this issue…