-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux-code
executable file
·76 lines (72 loc) · 1.89 KB
/
tmux-code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /bin/bash
# Copy of /usr/lib/byobu/uptime
# License for uptime-code
# uptime: condensed uptime of the machine
#
# Copyright (C) 2009 Raphaël Pinson.
# Copyright (C) 2009 Canonical Ltd.
# Copyright (C) 2011-2014 Dustin Kirkland
#
# Authors: Raphaël Pinson <[email protected]>
# Dustin Kirkland <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# with colors removed
__uptime() {
local u= idle= str=
if [ -r /proc/uptime ]; then
read u idle < /proc/uptime
u=${u%.*}
if [ "$u" -gt 86400 ]; then
str="$(($u / 86400))d$((($u % 86400) / 3600))h"
elif [ "$u" -gt 3600 ]; then
str="$(($u / 3600))h$((($u % 3600) / 60))m"
elif [ "$u" -gt 60 ]; then
str="$(($u / 60))m"
else
str="${u}s"
fi
else
str=$(uptime | sed -e "s/.* up *//" -e "s/ *days, */d/" -e "s/:/h/" -e "s/,.*/m/")
fi
[ -n "$str" ] || return
printf "%s" "${str}";
}
# Based on /usr/lib/byobu/load_average
__load() {
if [ -r "/proc/loadavg" ]; then
read one five fifteen procs lastpid < /proc/loadavg;
printf "$one"
fi
}
__reboot() {
if [ -f /var/run/reboot-required ]; then
printf '🔄 ';
else
printf '';
fi
}
case $1 in
uptime*)
__uptime
;;
load*)
__load
;;
reboot*)
__reboot
;;
*)
printf "$(__reboot)$(__uptime) $(__load)"
;;
esac