Skip to content

Commit

Permalink
Respect clock format in the status line (#50)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
perryjiang authored Aug 25, 2020
1 parent 25c64f5 commit 4e2dc2a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions nord.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ __cleanup() {
unset -v NORD_TMUX_STATUS_CONTENT_OPTION NORD_TMUX_NO_PATCHED_FONT_OPTION
unset -v _current_dir
unset -f __load __cleanup
tmux set-environment -gu NORD_TMUX_STATUS_TIME_FORMAT
}

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

if [ "$(tmux show-option -gqv "clock-mode-style")" == '12' ]; then
tmux set-environment -g NORD_TMUX_STATUS_TIME_FORMAT "%I:%M %p"
else
tmux set-environment -g NORD_TMUX_STATUS_TIME_FORMAT "%H:%M"
fi

if [ "$status_content" != "0" ]; then
if [ "$no_patched_font" != "1" ]; then
tmux source-file "$_current_dir/$NORD_TMUX_STATUS_CONTENT_FILE"
Expand Down
2 changes: 1 addition & 1 deletion src/nord-status-content-no-patched-font.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set -g @prefix_highlight_copy_mode_attr "fg=black,bg=brightcyan"
#+--------+
#+--- Bars ---+
set -g status-left "#[fg=black,bg=blue,bold] #S "
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 "
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 "

#+--- Windows ---+
set -g window-status-format " #[fg=white,bg=brightblack]#I #[fg=white,bg=brightblack]#W #F"
Expand Down
2 changes: 1 addition & 1 deletion src/nord-status-content.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -g @prefix_highlight_copy_mode_attr "fg=brightcyan,bg=black,bold"
#+--- Bars ---+
#set -g status-left "#[fg=black,bg=blue,bold] #S#[fg=blue,bg=black,nobold,noitalics,nounderscore]"
set -g status-left "#[fg=black,bg=blue,bold] #S #[fg=blue,bg=black,nobold,noitalics,nounderscore]"
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 "
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 "

#+--- Windows ---+
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]"
Expand Down

0 comments on commit 4e2dc2a

Please sign in to comment.