Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neofetch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
neofetch
Commits
854f9e50
Commit
854f9e50
authored
Apr 29, 2016
by
Dylan Araps
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #231 from dylanaraps/uptime_fixes
OSX and BSD uptime fixes.
parents
2f96e8b3
1c9f19fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
20 deletions
+27
-20
neofetch
neofetch
+27
-20
No files found.
neofetch
View file @
854f9e50
...
@@ -586,37 +586,44 @@ getuptime () {
...
@@ -586,37 +586,44 @@ getuptime () {
uptime=
$((
now
-
boot
))
uptime=
$((
now
-
boot
))
# Convert uptime to days/hours/mins
# Convert uptime to days/hours/mins
mins=
$((
uptime
/
60
%
60
))
min
ute
s=
$((
uptime
/
60
%
60
))
hours=
$((
uptime
/
3600
%
24
))
hours=
$((
uptime
/
3600
%
24
))
days=
$((
uptime
/
86400
))
days=
$((
uptime
/
86400
))
# Format the output like Linux's "
uptime
-p
" cmd.
case "
$minutes
" in
if [ "
$mins
" == 1 ]; then
1) minutes="
1
minute
" ;;
uptime="
$mins
minute
"
0) unset minutes ;;
elif [ "
$mins
" != 0 ]; then
*) minutes="
$minutes
minutes
" ;;
uptime="
$mins
minutes
"
esac
fi
if [ "
$hours
" == 1 ]; the
n
case "
$hours
" i
n
uptime="
$hours
hour,
$uptime
"
1) hours="
1
hour
" ;;
elif [ "
$mins
" != 0 ]; then
0) unset hours ;;
uptime="
$hours
hours,
$uptime
"
*) hours="
$hours
hours
" ;;
fi
esac
if [ "
$days
" == 1 ]; then
case "
$days
" in
uptime="
$days
day,
$uptime
"
1) days="
1
day
" ;;
elif [ "
$days
" != 0 ]; then
0) unset days ;;
uptime="
$days
days,
$uptime
"
*) days="
$days
days
" ;;
fi
esac
[ ! -z "
$hours
" ] &&
\
[ ! -z "
$minutes
" ] &&
\
hours+="
,
"
[ ! -z "
$days
" ] &&
\
[ ! -z "
$hours
" ] &&
\
days+="
,
"
uptime="
up
$
uptime
"
uptime="
up
$
days
$hours
$minutes
"
;;
;;
esac
esac
# Make the output of uptime smaller.
# Make the output of uptime smaller.
case "
$uptime_shorthand
" in
case "
$uptime_shorthand
" in
"
on
")
"
on
")
uptime=
${
uptime
/up
}
uptime=
${
uptime
/up
}
uptime=
${
uptime
/minutes/mins
}
uptime=
${
uptime
/minutes/mins
}
uptime=
${
uptime
/minute/min
}
uptime=
${
uptime
/minute/min
}
uptime=
${
uptime
/seconds/secs
}
uptime=
${
uptime
/seconds/secs
}
...
@@ -624,7 +631,7 @@ getuptime () {
...
@@ -624,7 +631,7 @@ getuptime () {
;;
;;
"
tiny
")
"
tiny
")
uptime=
${
uptime
/up
}
uptime=
${
uptime
/up
}
uptime=
${
uptime
/ days/d
}
uptime=
${
uptime
/ days/d
}
uptime=
${
uptime
/ day/d
}
uptime=
${
uptime
/ day/d
}
uptime=
${
uptime
/ hours/h
}
uptime=
${
uptime
/ hours/h
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment