chiark / gitweb /
pager: introduce "jump to end" option
authorHarald Hoyer <harald@redhat.com>
Thu, 7 Mar 2013 19:44:35 +0000 (20:44 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 7 Mar 2013 20:16:04 +0000 (21:16 +0100)
$ journalctl -be

is what you want :)

https://bugzilla.redhat.com/show_bug.cgi?id=867841

man/journalctl.xml
src/cgls/cgls.c
src/delta/delta.c
src/journal/coredumpctl.c
src/journal/journalctl.c
src/locale/localectl.c
src/login/loginctl.c
src/shared/pager.c
src/shared/pager.h
src/systemctl/systemctl.c
src/timedate/timedatectl.c

index e2740e42133de67fe3ad0afe22d87474162327ae..201f66a3b5378e923c20be5df8186335fcbc42af 100644 (file)
                                 the journal.</para></listitem>
                         </varlistentry>
 
+                        <varlistentry>
+                                <term><option>-e</option></term>
+                                <term><option>--pager-end</option></term>
+
+                                <listitem><para>Immediately jump to
+                                the end of the journal inside the
+                                implied pager tool. Very useful in
+                                combination with the
+                                <option>-b</option> option. Note that
+                                this is only supported for the
+                                <citerefentry><refentrytitle>less</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+                                pager.</para></listitem>
+                        </varlistentry>
+
                         <varlistentry>
                                 <term><option>-n</option></term>
                                 <term><option>--lines=</option></term>
index a05f9795be26b0e351273751c6c062d254860e42..e649b75df605b5a53bc3c38d8fa55a83c3a5150c 100644 (file)
@@ -132,7 +132,7 @@ int main(int argc, char *argv[]) {
         }
 
         if (!arg_no_pager) {
-                r = pager_open();
+                r = pager_open(false);
                 if (r > 0) {
                         if (arg_full == -1)
                                 arg_full = true;
index 16b10021b78f0159a57305eac4b091f95c4cc25a..aec3dc899505cad7a78c33ca9c26d9e9419f9060 100644 (file)
@@ -454,7 +454,7 @@ int main(int argc, char *argv[]) {
                 arg_flags |= SHOW_OVERRIDDEN;
 
         if (!arg_no_pager)
-                pager_open();
+                pager_open(false);
 
         if (optind < argc) {
                 int i;
index b6e558186d812111cdaca948aeb91449e84c0cd2..8bfab0075f5438ee7ad79d080203455f253b4fc3 100644 (file)
@@ -560,7 +560,7 @@ int main(int argc, char *argv[]) {
 
         case ACTION_LIST:
                 if (!arg_no_pager)
-                        pager_open();
+                        pager_open(false);
 
                 r = dump_list(j);
                 break;
index c90fecd239e5bc641ea01068569a3361d5363f46..5fb2db3ba58aedeb866645dcc554cb612af55f12 100644 (file)
@@ -56,6 +56,7 @@
 #define DEFAULT_FSS_INTERVAL_USEC (15*USEC_PER_MINUTE)
 
 static OutputMode arg_output = OUTPUT_SHORT;
+static bool arg_pager_end = false;
 static bool arg_follow = false;
 static bool arg_full = false;
 static bool arg_all = false;
@@ -103,6 +104,7 @@ static int help(void) {
                "  -u --unit=UNIT         Show data only from the specified unit\n"
                "     --user-unit=UNIT    Show data only from the specified user session unit\n"
                "  -p --priority=RANGE    Show only messages within the specified priority range\n"
+               "  -e --pager-end         Immediately jump to end of the journal in the pager\n"
                "  -f --follow            Follow journal\n"
                "  -n --lines[=INTEGER]   Number of journal entries to show\n"
                "     --no-tail           Show all lines, even in follow mode\n"
@@ -163,6 +165,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "help",         no_argument,       NULL, 'h'              },
                 { "version" ,     no_argument,       NULL, ARG_VERSION      },
                 { "no-pager",     no_argument,       NULL, ARG_NO_PAGER     },
+                { "pager-end",    no_argument,       NULL, 'e'              },
                 { "follow",       no_argument,       NULL, 'f'              },
                 { "output",       required_argument, NULL, 'o'              },
                 { "all",          no_argument,       NULL, 'a'              },
@@ -199,7 +202,7 @@ static int parse_argv(int argc, char *argv[]) {
         assert(argc >= 0);
         assert(argv);
 
-        while ((c = getopt_long(argc, argv, "hfo:an::qmbD:p:c:u:F:xr", options, NULL)) >= 0) {
+        while ((c = getopt_long(argc, argv, "hefo:an::qmbD:p:c:u:F:xr", options, NULL)) >= 0) {
 
                 switch (c) {
 
@@ -216,6 +219,10 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_no_pager = true;
                         break;
 
+                case 'e':
+                        arg_pager_end = true;
+                        break;
+
                 case 'f':
                         arg_follow = true;
                         break;
@@ -1075,7 +1082,7 @@ int main(int argc, char *argv[]) {
         }
 
         if (!arg_no_pager && !arg_follow)
-                pager_open();
+                pager_open(arg_pager_end);
 
         if (!arg_quiet) {
                 usec_t start, end;
index ce31e1ffce9c97459cfe9db44090c317a1dc3d91..9f996dbc9820fa559105f153e6291e7fc30dda07 100644 (file)
@@ -53,7 +53,7 @@ static void pager_open_if_enabled(void) {
         if (arg_no_pager)
                 return;
 
-        pager_open();
+        pager_open(false);
 }
 
 static void polkit_agent_open_if_enabled(void) {
index 473c77b92d4b9951bbfc78302a804772d42c4bc6..fe27003a92bc27e5109a2022a90468f5c8e4310f 100644 (file)
@@ -58,7 +58,7 @@ static void pager_open_if_enabled(void) {
         if (arg_no_pager)
                 return;
 
-        pager_open();
+        pager_open(false);
 }
 
 static void polkit_agent_open_if_enabled(void) {
index 5165d2b1c854f101285e8e58fef06d297a66f988..4ffb530e934810b41f3455e1ea18bae8a6054196 100644 (file)
@@ -44,7 +44,7 @@ _noreturn_ static void pager_fallback(void) {
         _exit(EXIT_SUCCESS);
 }
 
-int pager_open(void) {
+int pager_open(bool jump_to_end) {
         int fd[2];
         const char *pager;
         pid_t parent_pid;
@@ -85,7 +85,10 @@ int pager_open(void) {
                 dup2(fd[0], STDIN_FILENO);
                 close_pipe(fd);
 
-                setenv("LESS", "FRSXK", 0);
+                if (jump_to_end)
+                        setenv("LESS", "FRSXK+G", 0);
+                else
+                        setenv("LESS", "FRSXK", 0);
 
                 /* Make sure the pager goes away when the parent dies */
                 if (prctl(PR_SET_PDEATHSIG, SIGTERM) < 0)
index 5e7b5ab91e39fb498b45e146f0a255d6e6b5d93c..325ca98f79cebffab7b5f6aba2eb5fd5476b070e 100644 (file)
@@ -23,6 +23,6 @@
 
 #include <stdbool.h>
 
-int pager_open(void);
+int pager_open(bool jump_to_end);
 void pager_close(void);
 bool pager_have(void);
index 72e9c5539b13d53b75719f954f17ee1c2d9cef14..4a55c566eca136fe9b1fcc62199eb589b37aacb5 100644 (file)
@@ -136,7 +136,7 @@ static void pager_open_if_enabled(void) {
         if (arg_no_pager)
                 return;
 
-        pager_open();
+        pager_open(false);
 }
 
 static void ask_password_agent_open_if_enabled(void) {
index f5b5f0ca84e9accc702b1a4f8e4164de42ee8bd2..ef2ea0830006bfd1cfee75fb4745a008ebe5a5f5 100644 (file)
@@ -51,7 +51,7 @@ static void pager_open_if_enabled(void) {
         if (arg_no_pager)
                 return;
 
-        pager_open();
+        pager_open(false);
 }
 
 static void polkit_agent_open_if_enabled(void) {