Skip to content

feat(weather): add TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE option#515

Open
turtle11311 wants to merge 3 commits into
erikw:mainfrom
turtle11311:fix/weather-icon-style
Open

feat(weather): add TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE option#515
turtle11311 wants to merge 3 commits into
erikw:mainfrom
turtle11311:fix/weather-icon-style

Conversation

@turtle11311
Copy link
Copy Markdown
Contributor

Problem

Some terminals miscount the tmux status-bar width when weather condition symbols use VS16 variation selectors. For example, ☀️ is U+2600 + U+FE0F: tmux measures the base character as 1 cell while the terminal renders the pair as 2, causing the right side of the status bar to overflow or wrap.

Related: #511 (deanbear) which addresses the same width issue via a different approach.

Fix

Adds TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE with four values:

Value Description
emoji VS16 preserved — default, original behaviour
emoji_fixed VS16 stripped; fixes width miscounting on affected terminals
nerdfonts Nerd Font PUA icons (fixed 1-cell width, no ambiguity)
auto nerdfonts when tp_patched_font_in_use() detects a patched font, otherwise emoji

The default is emoji, so existing users see no change without opting in.

The nerdfonts path uses MDI icons already in the Nerd Font PUA range, consistent with how other tmux-powerline segments use patched-font icons.

Configuration

# In your tmux-powerline config (e.g. ~/.config/tmux-powerline/config.sh):

# Use Nerd Font icons (fixed-width, no tmux miscounting):
export TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE="nerdfonts"

# Or strip VS16 selectors from emoji (simpler fix for affected terminals):
export TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE="emoji_fixed"

# Or auto-detect based on whether a patched font is in use:
export TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE="auto"

This is a focused split of #513 (which also fixed a separate non-blocking fetch issue — that is tracked in a companion PR #514).

Some terminals miscount the tmux status-bar width when weather condition
symbols use VS16 variation selectors (e.g. ☀️  is U+2600 + U+FE0F):
tmux measures the base character as 1 cell while the terminal renders
the pair as 2, causing the right side of the status bar to overflow or
wrap.

Adds TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE with four values:
  emoji       - VS16 preserved (default, original behaviour)
  emoji_fixed - VS16 stripped; fixes width for affected terminals
  nerdfonts   - Nerd Font PUA icons (fixed 1-cell width, no ambiguity)
  auto        - nerdfonts when tp_patched_font_in_use(), else emoji

The default is "emoji" so existing users see no change.

Related: PR erikw#511 (deanbear) which addresses the same width issue.
This is a focused split of erikw#513, extracted as a standalone change.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a configurable weather icon style option so users can choose the existing emoji rendering, VS16-stripped emoji, Nerd Font icons, or automatic selection based on patched-font detection.

Changes:

  • Adds TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE defaults and generated config documentation.
  • Resolves icon style during weather rendering, including auto detection.
  • Expands weather condition symbol selection to support emoji, fixed emoji, and Nerd Font output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread segments/weather.sh Outdated
if [ "$style" = "nerdfonts" ]; then
# All Nerd Font icons are PUA (1 cell), no width ambiguity
case "$condition" in
"clearsky_day") printf "\UF0599" ;; # 󰖙 mdi-weather-sunny
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turtle11311 please address this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — replaced all printf "\\UF..." calls with literal UTF-8 glyphs embedded directly in the source file. Bash 3.2-safe.

Also took this opportunity to fix the related portability issue raised in the adjacent Copilot comment (line 236): the sed 's/\xef\xb8\x8f//g' VS16-stripping (GNU sed only) has been replaced with an explicit emoji_fixed lookup table that pre-defines each symbol without VS16, so no sed is needed at all.

Comment thread segments/weather.sh Outdated
*) symbol="?" ;;
esac
if [ "$style" = "emoji_fixed" ]; then
printf '%s' "$symbol" | sed 's/\xef\xb8\x8f//g'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — the entire sed-based approach has been dropped. emoji_fixed is now a standalone lookup table with the VS16-free symbols pre-defined, so no post-processing is needed at all.

Comment thread segments/weather.sh Outdated
Comment on lines +148 to +154
local icon_style="${TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE:-$TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE_DEFAULT}"
if [ "$icon_style" = "auto" ]; then
tp_patched_font_in_use && icon_style="nerdfonts" || icon_style="emoji"
fi
# condition_symbol=$(__get_yrno_condition_symbol "$condition" "$sunrise" "$sunset")
condition_symbol=$(__get_yrno_condition_symbol "$condition")
local condition_symbol
condition_symbol=$(__get_yrno_condition_symbol "$condition" "$icon_style")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turtle11311 please address this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — icon style is now resolved at the top of run_segment() before the cache read, and the cache file path encodes the style (weather_cache_data_${icon_style}.txt). Switching TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE takes effect immediately without waiting for the cache to expire.

Comment thread segments/weather.sh Outdated
Comment on lines +193 to +195
"heavyrainandthunder" | "heavyrainshowersandthunder_day" | "heavyrainshowersandthunder_night" | "heavysleetandthunder" | "heavysleetshowersandthunder_day" | "heavysnowandthunder" | "heavysnowshowersandthunder_day" | "heavysnowshowersandthunder_night" | "lightrainandthunder" | "lightrainshowersandthunder_day" | "lightrainshowersandthunder_night" | "lightsleetandthunder" | "lightsnowandthunder" | "lightssleetshowersandthunder_day" | "lightssleetshowersandthunder_night" | "lightssnowshowersandthunder_day" | "lightssnowshowersandthunder_night" | "rainandthunder" | "rainshowersandthunder_day" | "rainshowersandthunder_night" | "sleetandthunder" | "sleetshowersandthunder_day" | "sleetshowersandthunder_night" | "snowandthunder" | "snowshowersandthunder_day" | "snowshowersandthunder_night")
printf "\UF067E" ;; # 󰙾 mdi-weather-lightning-rainy
"heavyrainshowers_day" | "heavysleetshowers_day" | "heavysleetshowersandthunder_night" | "lightrainshowers_day" | "lightsleetshowers_day" | "rainshowers_day" | "sleetshowers_day")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turtle11311 please address this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — heavysleetshowersandthunder_night moved into the thunder/lightning group across all three style branches (nerdfonts, emoji_fixed, emoji).

Copy link
Copy Markdown
Owner

@erikw erikw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turtle11311 please address comments abovce

- Replace printf \U Unicode escapes with literal UTF-8 glyphs (Bash 3.2
  / macOS-safe; \U is a bash 4+ extension)
- Replace sed \xHH VS16-stripping with an explicit emoji_fixed lookup
  table (BSD sed does not support \xHH escape syntax)
- Move heavysleetshowersandthunder_night into the thunder/lightning
  group across all three style branches (was incorrectly placed in the
  partly-rainy showers group)
- Resolve icon_style in run_segment() before the cache read and encode
  it into the cache file path, so changing ICON_STYLE takes effect
  immediately without waiting for the weather cache to expire

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@turtle11311 turtle11311 force-pushed the fix/weather-icon-style branch from d7c5488 to d6d3762 Compare May 28, 2026 11:48
Literal UTF-8 glyphs are unreadable in diffs without Nerd Fonts;
U+XXXXX comments let reviewers identify each icon without the font.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread segments/weather.sh
Comment on lines +14 to +15
# Icon style: "emoji" (default), "nerdfonts", "emoji_fixed", "auto"
TMUX_POWERLINE_SEG_WEATHER_ICON_STYLE_DEFAULT="emoji"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this

Copy link
Copy Markdown
Owner

@erikw erikw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix merge conflict.

Comment thread segments/weather.sh

run_segment() {
local weather=""
# Resolve icon style before the cache read so the cache file path is
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this block of code added make sense to do in __process_settings(), my hunch is that it would.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants