Skip to content

Commit

Permalink
Fixed: Add uptime script
Browse files Browse the repository at this point in the history
  • Loading branch information
DasLampe committed Oct 30, 2020
1 parent 3e9e360 commit 196cc71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 0 additions & 1 deletion tmux
Submodule tmux deleted from ffb1c5
16 changes: 16 additions & 0 deletions tmux/uptime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

up=$(cut -d ' ' -f1 < /proc/uptime)
up=${up%.*}

days=$(( up / 86400 ))
hours=$(( ( up % 86400 ) / 3600 ))
min=$(( (( up % 86400 ) % 3600 ) / 60 ))
sec=$(( (( up % 86400 ) % 3600 ) % 60 ))

[ $days = 0 ] || dout="${days}d "
[ $hours = 0 ] || hout="${hours}h "
[ $min = 0 ] || mout="${min}m "
[ $sec = 0 ] || sout="${sec}s"

echo "$dout$hout$mout$sout"

0 comments on commit 196cc71

Please sign in to comment.