Add -p|--pretty option to uptime(1) for pretty output.

This patch adds the -p option to the uptime(1) command, which changes
the uptime displayed from something like:

 10:35:52 up  2:33,  1 user,  load average: 1.69, 1.65, 1.63

to:

 up 2 hours, 33 minutes

I originally implemented this as the up(1) program about 14 years ago.
In 2008 or 2009, I created a patch for procps to add this functionality
to uptime and submitted it to the project.  Never heard from the
project and no new releases of procps had been made.  Then I found out
about this project and decided to port my patch to it.  So here it is.

This is really just for fun.  There is no real technical reason to
have this functionality.  But even now, 14 years later, I still get
emails asking where the source code for up is.  So I thought it would
be nice for the uptime command on Linux to sport the up functionality
by default.
This commit is contained in:
David Cantrell
2012-02-22 10:35:12 -05:00
parent d9c226c695
commit 3e7f78d296
7 changed files with 101 additions and 34 deletions

View File

@@ -3388,10 +3388,10 @@ static void summary_show (void) {
// Display Uptime and Loadavg
if (isROOM(View_LOADAV, 1)) {
if (!Rc.mode_altscr)
show_special(0, fmtmk(LOADAV_line, Myname, sprint_uptime()));
show_special(0, fmtmk(LOADAV_line, Myname, sprint_uptime(0)));
else
show_special(0, fmtmk(CHKw(w, Show_TASKON)? LOADAV_line_alt : LOADAV_line
, w->grpname, sprint_uptime()));
, w->grpname, sprint_uptime(0)));
Msg_row += 1;
}