File tree Expand file tree Collapse file tree 3 files changed +51
-7
lines changed Expand file tree Collapse file tree 3 files changed +51
-7
lines changed Original file line number Diff line number Diff line change @@ -231,6 +231,12 @@ tmux window list
231231- ` @tmux2k-window-list-format ` : Sets the format for the window list. Default: ` '#I:#W' `
232232- ` @tmux2k-window-list-compact ` : Enables or disables compact mode for the window list. Default: ` false `
233233
234+ #### 15. ` uptime `
235+
236+ Show current system uptime
237+
238+ - ` tmux2k-uptime-icon ` : Icon for system uptime, default: ` `
239+
234240#### 🪆 Add New Plugins
235241
236242To add a new plugin:
Original file line number Diff line number Diff line change @@ -53,19 +53,20 @@ yellow=$(get_tmux_option "@tmux2k-yellow" '#ffd21a')
5353dark_yellow=$( get_tmux_option " @tmux2k-dark-yellow" ' #b8860b' )
5454
5555declare -A plugin_colors=(
56- [" session " ]=" green text"
57- [" git " ]=" green text"
56+ [" bandwidth " ]=" purple text"
57+ [" battery " ]=" pink text"
5858 [" cpu" ]=" light_green text"
5959 [" cwd" ]=" blue text"
60- [" ram " ]=" yellow text"
60+ [" git " ]=" green text"
6161 [" gpu" ]=" red text"
62- [" battery" ]=" pink text"
6362 [" network" ]=" purple text"
64- [" bandwidth" ]=" purple text"
6563 [" ping" ]=" purple text"
66- [" weather" ]=" orange text"
67- [" time" ]=" light_blue text"
6864 [" pomodoro" ]=" red text"
65+ [" ram" ]=" yellow text"
66+ [" session" ]=" green text"
67+ [" time" ]=" light_blue text"
68+ [" uptime" ]=" light_blue text"
69+ [" weather" ]=" orange text"
6970 [" window_list" ]=" black blue"
7071 [" custom" ]=" red text"
7172)
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ current_dir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
4+ source " $current_dir /../lib/utils.sh"
5+
6+ uptime_icon=$( get_tmux_option " @tmux2k-uptime-icon" " " )
7+
8+ main () {
9+ uptime_output=$( uptime)
10+ uptime_text=$( echo " $uptime_output " | awk -F' up ' ' {print $2}' | awk -F' ,' ' {print $1}' )
11+
12+ days=0
13+ hours=0
14+ minutes=0
15+
16+ echo " $uptime_text " | awk '
17+ {
18+ for (i = 1; i <= NF; i++) {
19+ if ($i ~ /^[0-9]+$/ && $(i+1) == "days") { days = $i }
20+ if ($i ~ /^[0-9]+:[0-9]+$/) { split($i, t, ":"); hours = t[1]; minutes = t[2] }
21+ if ($i ~ /^[0-9]+$/ && $(i+1) == "hours") { hours = $i }
22+ if ($i ~ /^[0-9]+$/ && $(i+1) == "mins") { minutes = $i }
23+ }
24+ }
25+ END { printf "%d %d %d\n", days, hours, minutes }' | {
26+ read days hours minutes
27+
28+ output=" "
29+ [ " $days " -gt 0 ] && output=" $output ${days} D "
30+ [ " $hours " -gt 0 ] && output=" $output ${hours} H "
31+ [ " $minutes " -gt 0 ] && output=" $output ${minutes} M"
32+
33+ echo " $uptime_icon $output "
34+ }
35+ }
36+
37+ main
You can’t perform that action at this time.
0 commit comments