feat: add prepend/append hooks for default status-left and status-right#99
Open
pmkolo wants to merge 1 commit into
Open
feat: add prepend/append hooks for default status-left and status-right#99pmkolo wants to merge 1 commit into
pmkolo wants to merge 1 commit into
Conversation
Allow users to prepend/append custom tmux status fragments to Nord's default status-left and status-right content without disabling the predefined status bar entirely. New options: - @nord_tmux_status_left_prepend - @nord_tmux_status_left_append - @nord_tmux_status_right_prepend - @nord_tmux_status_right_append
|
This is great! I was actually looking to implement something like this myself. Thank's for making this PR :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This update makes Nord’s predefined tmux status content extensible without requiring users to disable it entirely. At the moment, Nord sources its built-in status content and sets status-left / status-right directly, which means users who want to add extra plugin output usually have to either fork the theme, patch the installed files locally or turn off Nord’s predefined status content completely via @nord_tmux_show_status_content "0".
This change adds four new extension points:
@nord_tmux_status_left_prepend
@nord_tmux_status_left_append
@nord_tmux_status_right_prepend
@nord_tmux_status_right_append
These hook options are re-expanded when rendered, so users can inject normal tmux formats, content from other tmux user options and shell-backed status fragments while still preserving Nord’s built-in layout and styling. tmux’s documented E / T format modifiers are specifically intended for this kind of “expand the contents of an option again” workflow.
Motivation
There have been repeated user requests to combine Nord’s default status bar with other plugins, myself included. In practice, the answer has usually been “disable Nord’s predefined status content and build your own status line,” which works but is much less ergonomic than extending the existing theme output.
This update keeps Nord’s existing default appearance intact for users who do nothing, while providing a lightweight mechanism for users who want to add one or two extra status segments without copying the whole status definition into their own config. That seems aligned with Nord’s existing philosophy of making predefined status content optional instead of mandatory. And allows further plugin updates while retaining user defined content in status line.
Changes
Nord’s default status-left and status-right definitions are updated so they compose the final status bar from:
The new hook options are rendered using tmux's re-expansion, so users can store dynamic content in tmux options and have it evaluated correctly when the status line is drawn. This avoids the common issue where a tmux option containing #{...} or #(...) is shown literally unless E: / T: is used.
Example
Users who want to keep Nord’s default status content but prepend or append additional segments can now do things like:
This is particularly useful for theme integration with plugins that expose reusable status fragments via tmux options. A reusable option exported by any plugin can be consumed cleanly via Nord’s new hook mechanism.
Example with a reusable plugin option:
set -g @nord_tmux_status_right_prepend '#{E:@pomodoro_status} 'Backwards compatibility
This change is intended to be fully backwards-compatible:
Users who do not set any of the new hook options will keep the existing Nord status bar behavior.
Users who already disable Nord’s status content with @nord_tmux_show_status_content "0" can continue doing so unchanged.
The change only affects how Nord assembles the final status-left / status-right strings when the predefined status content is enabled.
Deliberately keeping
{prefix_highlight}part of the status-right option, which may be migrated to@nord_tmux_status_right_prependoption in the future.Why not just use @nord_tmux_show_status_content "0"?
That option is still useful and should absolutely remain supported. Nord’s release notes already describe it as the way to disable predefined status content for full custom status bars. However, many users do not want to replace the entire Nord status line, they just want to add an extra segment or two while keeping the built-in themed separators, date/time, hostname, and plugin styling. This PR intends to fill that gap.
Real-world problems this addresses
This change directly helps with the class of issues where users report that adding custom content or third-party plugin output “does not work” once Nord is enabled, because Nord’s built-in status content becomes the final rendered value for status-left / status-right. Similar requests and workarounds have come up around custom right-side content, like battery/cpu integration.
Instead of telling users to modify plugin files under ~/.tmux/plugins/... or copy the theme’s status bar into their own config, this change provides an extension mechanism in the theme itself.
Notes
This change is intentionally generic and does not hardcode support for any specific third-party plugin.
It keeps Nord’s current “predefined status content is optional” behavior, while making the predefined content easier to extend.
It follows tmux’s documented format-expansion model for options that themselves contain format strings or shell-backed fragments.
Config reloads
tmux options persist in the running tmux server. If you remove one of the @nord_tmux_status_*_{prepend,append} assignments from config and reload with source-file, the old value may remain until explicitly unset or until the tmux server is restarted. To make reloads idempotent, users could unset the hook options before reassigning them:
set -gu @nord_tmux_status_left_prepend
set -gu @nord_tmux_status_left_append
set -gu @nord_tmux_status_right_prepend
set -gu @nord_tmux_status_right_append