From e0a45082ebb5381e585f7a41de2993a7789b9448 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sat, 22 Jun 2019 21:45:36 +0200 Subject: [PATCH] added support for #{uptime_y} variable --- .tmux.conf | 11 ++++++++++- .tmux.conf.local | 5 +++-- README.md | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 8c1e64db0..100215a46 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -603,6 +603,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # now=$(date +%s) # ;; # *Linux*|*CYGWIN*|*MSYS*|*MINGW*) +# boot=0 # now=$(cut -d' ' -f1 < /proc/uptime) # ;; # *OpenBSD*) @@ -613,12 +614,16 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # awk -v boot="$boot" -v now="$now" ' # BEGIN { # uptime = now - boot +# y = int(uptime / 31536000) +# dy = int(uptime / 86400) % 365 # d = int(uptime / 86400) # h = int(uptime / 3600) % 24 # m = int(uptime / 60) % 60 # s = int(uptime) % 60 # -# system("tmux set -g @uptime_d " d + 0 " \\; " \ +# system("tmux set -g @uptime_y " y + 0 " \\; " \ +# "set -g @uptime_dy " dy + 0 " \\; " \ +# "set -g @uptime_d " d + 0 " \\; " \ # "set -g @uptime_h " h + 0 " \\; " \ # "set -g @uptime_m " m + 0 " \\; " \ # "set -g @uptime_s " s + 0) @@ -1145,12 +1150,16 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # case "$status_left $status_right" in # *'#{uptime_d}'*|*'#{uptime_h}'*|*'#{uptime_m}'*) # status_left=$(echo "$status_left" | sed -E \ +# -e 's/#\{(\?)?uptime_y/#\{\1@uptime_y/g' \ # -e 's/#\{(\?)?uptime_d/#\{\1@uptime_d/g' \ +# -e '/@uptime_y/ s/@uptime_d/@uptime_dy/g' \ # -e 's/#\{(\?)?uptime_h/#\{\1@uptime_h/g' \ # -e 's/#\{(\?)?uptime_m/#\{\1@uptime_m/g' \ # -e 's/#\{(\?)?uptime_s/#\{\1@uptime_s/g') # status_right=$(echo "$status_right" | sed -E \ +# -e 's/#\{(\?)?uptime_y/#\{\1@uptime_y/g' \ # -e 's/#\{(\?)?uptime_d/#\{\1@uptime_d/g' \ +# -e '/@uptime_y/ s/@uptime_d/@uptime_dy/g' \ # -e 's/#\{(\?)?uptime_h/#\{\1@uptime_h/g' \ # -e 's/#\{(\?)?uptime_m/#\{\1@uptime_m/g' \ # -e 's/#\{(\?)?uptime_s/#\{\1@uptime_s/g') diff --git a/.tmux.conf.local b/.tmux.conf.local index 7d7851d46..53b94c777 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -172,13 +172,14 @@ tmux_conf_theme_right_separator_sub='|' # - #{prefix} # - #{root} # - #{synchronized} -# - #{uptime_d} +# - #{uptime_y} +# - #{uptime_d} (modulo 365 when #{uptime_y} is used) # - #{uptime_h} # - #{uptime_m} # - #{uptime_s} # - #{username} # - #{username_ssh} -tmux_conf_theme_status_left=' ❐ #S | ↑#{?uptime_d, #{uptime_d}d,}#{?uptime_h, #{uptime_h}h,}#{?uptime_m, #{uptime_m}m,} ' +tmux_conf_theme_status_left=' ❐ #S | ↑#{?uptime_y, #{uptime_y}y,}#{?uptime_d, #{uptime_d}d,}#{?uptime_h, #{uptime_h}h,}#{?uptime_m, #{uptime_m}m,} ' tmux_conf_theme_status_right='#{prefix}#{pairing}#{synchronized} #{?battery_status, #{battery_status},}#{?battery_bar, #{battery_bar},}#{?battery_percentage, #{battery_percentage},} , %R , %d %b | #{username}#{root} | #{hostname} ' # status left style diff --git a/README.md b/README.md index 4f69f88c4..45dd227c2 100644 --- a/README.md +++ b/README.md @@ -251,7 +251,8 @@ This configuration supports the following builtin variables: - `#{prefix}`: is prefix being depressed? - `#{root}`: is current user root? - `#{synchronized}`: are the panes synchronized? - - `#{uptime_d}`: uptime days + - `#{uptime_y}`: uptime years + - `#{uptime_d}`: uptime days, modulo 365 when `#{uptime_y}` is used - `#{uptime_h}`: uptime hours - `#{uptime_m}`: uptime minutes - `#{uptime_s}`: uptime seconds