Skip to content

Commit 4e2dc2a

Browse files
authored
Respect clock format in the status line (#50)
Added the new `NORD_TMUX_STATUS_TIME_FORMAT` environment variable that stores the time format for the status bar element based on the value of the `clock-mode-style` configuration. This can be either `12` or `24` and the display format will be changed based on this to ensure the clock element in the default status bar content matches the preferred style of the user. Resolves GH-24
1 parent 25c64f5 commit 4e2dc2a

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

nord.tmux

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ __cleanup() {
2222
unset -v NORD_TMUX_STATUS_CONTENT_OPTION NORD_TMUX_NO_PATCHED_FONT_OPTION
2323
unset -v _current_dir
2424
unset -f __load __cleanup
25+
tmux set-environment -gu NORD_TMUX_STATUS_TIME_FORMAT
2526
}
2627

2728
__load() {
@@ -30,6 +31,12 @@ __load() {
3031
local status_content=$(tmux show-option -gqv "$NORD_TMUX_STATUS_CONTENT_OPTION")
3132
local no_patched_font=$(tmux show-option -gqv "$NORD_TMUX_NO_PATCHED_FONT_OPTION")
3233

34+
if [ "$(tmux show-option -gqv "clock-mode-style")" == '12' ]; then
35+
tmux set-environment -g NORD_TMUX_STATUS_TIME_FORMAT "%I:%M %p"
36+
else
37+
tmux set-environment -g NORD_TMUX_STATUS_TIME_FORMAT "%H:%M"
38+
fi
39+
3340
if [ "$status_content" != "0" ]; then
3441
if [ "$no_patched_font" != "1" ]; then
3542
tmux source-file "$_current_dir/$NORD_TMUX_STATUS_CONTENT_FILE"

src/nord-status-content-no-patched-font.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ set -g @prefix_highlight_copy_mode_attr "fg=black,bg=brightcyan"
1616
#+--------+
1717
#+--- Bars ---+
1818
set -g status-left "#[fg=black,bg=blue,bold] #S "
19-
set -g status-right "#{prefix_highlight}#[fg=white,bg=brightblack] %Y-%m-%d #[fg=white,bg=brightblack,nobold,noitalics,nounderscore]|#[fg=white,bg=brightblack] %H:%M #[fg=cyan,bg=brightblack,nobold,noitalics,nounderscore] #[fg=black,bg=cyan,bold] #H "
19+
set -g status-right "#{prefix_highlight}#[fg=white,bg=brightblack] %Y-%m-%d #[fg=white,bg=brightblack,nobold,noitalics,nounderscore]|#[fg=white,bg=brightblack] ${NORD_TMUX_STATUS_TIME_FORMAT} #[fg=cyan,bg=brightblack,nobold,noitalics,nounderscore] #[fg=black,bg=cyan,bold] #H "
2020

2121
#+--- Windows ---+
2222
set -g window-status-format " #[fg=white,bg=brightblack]#I #[fg=white,bg=brightblack]#W #F"

src/nord-status-content.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -g @prefix_highlight_copy_mode_attr "fg=brightcyan,bg=black,bold"
1919
#+--- Bars ---+
2020
#set -g status-left "#[fg=black,bg=blue,bold] #S#[fg=blue,bg=black,nobold,noitalics,nounderscore]"
2121
set -g status-left "#[fg=black,bg=blue,bold] #S #[fg=blue,bg=black,nobold,noitalics,nounderscore]"
22-
set -g status-right "#{prefix_highlight}#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] %Y-%m-%d #[fg=white,bg=brightblack,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] %H:%M #[fg=cyan,bg=brightblack,nobold,noitalics,nounderscore]#[fg=black,bg=cyan,bold] #H "
22+
set -g status-right "#{prefix_highlight}#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] %Y-%m-%d #[fg=white,bg=brightblack,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] ${NORD_TMUX_STATUS_TIME_FORMAT} #[fg=cyan,bg=brightblack,nobold,noitalics,nounderscore]#[fg=black,bg=cyan,bold] #H "
2323

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

0 commit comments

Comments
 (0)