gpakosz / .tmux

🇫🇷 Oh my tmux! My self-contained, pretty & versatile tmux configuration made with ❤️
MIT License
21.79k stars 3.36k forks source link

Bug with weather custom variable example in .local file #613

Closed mreishus closed 1 year ago

mreishus commented 1 year ago

I found that the weather custom variable did not work out of the box:

https://github.com/gpakosz/.tmux/blob/fa601ed607300f0884306493d9ddfdbde6bff11d/.tmux.conf.local#L421-L424

I tested by setting this and looking for weather information. I have curl installed:

tmux_conf_theme_status_right='#{prefix}#{mouse}#{pairing}#{synchronized} , %R , %d %b #{weather} | #{username}#{root} | #{hostname} '

It was verifiable by running the command used to process them: (only online appears, not weather)

$ perl -n -e 'print if s!^#\s+([^_][^()\s]+)\s*\(\)\s*{\s*\n!s%#\\\{\1((?:\\s+(?:[^\{\}]+?|#\\{(?:[^\{\}]+?)\}))*)\\\}%#(cut -c3- ~/.tmux.conf.local | sh -s \1\\1)%g; !p' < ~/.tmux.conf.local
s%#\{online((?:\s+(?:[^{}]+?|#\{(?:[^{}]+?)}))*)\}%#(cut -c3- ~/.tmux.conf.local | sh -s online\1)%g; 

I was able to fix by removing the 'second comments' from the custom variable:

# # /!\ do not remove the following line
# EOF
#
# # /!\ do not "uncomment" the functions: the leading "# " characters are needed
#
# weather() {                                         
#   curl -f -s -m 2 'wttr.in?format=3' || printf '\n' 
#   sleep 900                                         
# }
#
# online() {
#   ping -c 1 1.1.1.1 >/dev/null 2>&1 && printf '✔' || printf '✘'
# }
#
# "$@"
# # /!\ do not remove the previous line

After this, weather worked for me.

gpakosz commented 1 year ago

Hey @mreishus 👋

Good catch! Can you please add comments back and try the gh-603 branch please?

mreishus commented 1 year ago

Can you please add comments back and try the gh-603 branch please?

I'll gladly try, but I'm not seeing that branch yet :) https://github.com/gpakosz/.tmux/branches/all

gpakosz commented 1 year ago

Forgot to push!

mreishus commented 1 year ago

Working for me. LGTM :heavy_check_mark:

davidgomesdev commented 1 year ago

Someone reverted this