pager: support SYSTEMD_LESS environment variable
This allows customization of the arguments used by less. The main motivation is that some folks might not like having --no-init on every invocation of less.
This commit is contained in:
parent
db999e0f92
commit
f366d58dc1
|
@ -887,6 +887,10 @@
|
||||||
this to an empty string or the value
|
this to an empty string or the value
|
||||||
<literal>cat</literal> is equivalent to passing
|
<literal>cat</literal> is equivalent to passing
|
||||||
<option>--no-pager</option>.</para></listitem>
|
<option>--no-pager</option>.</para></listitem>
|
||||||
|
<term><varname>$SYSTEMD_LESS</varname></term>
|
||||||
|
<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
|
||||||
|
default options passed to <literal>less</literal>
|
||||||
|
(<literal>FRSXMK</literal>).</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
|
@ -265,6 +265,10 @@
|
||||||
this to an empty string or the value
|
this to an empty string or the value
|
||||||
<literal>cat</literal> is equivalent to passing
|
<literal>cat</literal> is equivalent to passing
|
||||||
<option>--no-pager</option>.</para></listitem>
|
<option>--no-pager</option>.</para></listitem>
|
||||||
|
<term><varname>$SYSTEMD_LESS</varname></term>
|
||||||
|
<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
|
||||||
|
default options passed to <literal>less</literal>
|
||||||
|
(<literal>FRSXMK</literal>).</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
|
@ -486,6 +486,10 @@
|
||||||
this to an empty string or the value
|
this to an empty string or the value
|
||||||
<literal>cat</literal> is equivalent to passing
|
<literal>cat</literal> is equivalent to passing
|
||||||
<option>--no-pager</option>.</para></listitem>
|
<option>--no-pager</option>.</para></listitem>
|
||||||
|
<term><varname>$SYSTEMD_LESS</varname></term>
|
||||||
|
<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
|
||||||
|
default options passed to <literal>less</literal>
|
||||||
|
(<literal>FRSXMK</literal>).</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
|
@ -311,6 +311,10 @@
|
||||||
this to an empty string or the value
|
this to an empty string or the value
|
||||||
<literal>cat</literal> is equivalent to passing
|
<literal>cat</literal> is equivalent to passing
|
||||||
<option>--no-pager</option>.</para></listitem>
|
<option>--no-pager</option>.</para></listitem>
|
||||||
|
<term><varname>$SYSTEMD_LESS</varname></term>
|
||||||
|
<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
|
||||||
|
default options passed to <literal>less</literal>
|
||||||
|
(<literal>FRSXMK</literal>).</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
|
@ -1479,6 +1479,10 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
|
||||||
equivalent to passing
|
equivalent to passing
|
||||||
<option>--no-pager</option>.</para>
|
<option>--no-pager</option>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<term><varname>$SYSTEMD_LESS</varname></term>
|
||||||
|
<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
|
||||||
|
default options passed to <literal>less</literal>
|
||||||
|
(<literal>FRSXMK</literal>).</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
|
@ -335,6 +335,10 @@ $ eog targets.svg</programlisting>
|
||||||
equivalent to passing
|
equivalent to passing
|
||||||
<option>--no-pager</option>.</para>
|
<option>--no-pager</option>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<term><varname>$SYSTEMD_LESS</varname></term>
|
||||||
|
<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
|
||||||
|
default options passed to <literal>less</literal>
|
||||||
|
(<literal>FRSXMK</literal>).</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
|
@ -239,6 +239,10 @@
|
||||||
this to an empty string or the value
|
this to an empty string or the value
|
||||||
<literal>cat</literal> is equivalent to passing
|
<literal>cat</literal> is equivalent to passing
|
||||||
<option>--no-pager</option>.</para></listitem>
|
<option>--no-pager</option>.</para></listitem>
|
||||||
|
<term><varname>$SYSTEMD_LESS</varname></term>
|
||||||
|
<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
|
||||||
|
default options passed to <literal>less</literal>
|
||||||
|
(<literal>FRSXMK</literal>).</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
|
@ -84,14 +84,17 @@ int pager_open(bool jump_to_end) {
|
||||||
|
|
||||||
/* In the child start the pager */
|
/* In the child start the pager */
|
||||||
if (pager_pid == 0) {
|
if (pager_pid == 0) {
|
||||||
|
const char* less_opts;
|
||||||
|
|
||||||
dup2(fd[0], STDIN_FILENO);
|
dup2(fd[0], STDIN_FILENO);
|
||||||
close_pipe(fd);
|
close_pipe(fd);
|
||||||
|
|
||||||
|
less_opts = getenv("SYSTEMD_LESS");
|
||||||
|
if (!less_opts)
|
||||||
|
less_opts = "FRSXMK";
|
||||||
if (jump_to_end)
|
if (jump_to_end)
|
||||||
setenv("LESS", "FRSXMK+G", 1);
|
less_opts = strappenda(less_opts, " +G");
|
||||||
else
|
setenv("LESS", less_opts, 1);
|
||||||
setenv("LESS", "FRSXMK", 1);
|
|
||||||
|
|
||||||
/* Make sure the pager goes away when the parent dies */
|
/* Make sure the pager goes away when the parent dies */
|
||||||
if (prctl(PR_SET_PDEATHSIG, SIGTERM) < 0)
|
if (prctl(PR_SET_PDEATHSIG, SIGTERM) < 0)
|
||||||
|
|
Loading…
Reference in New Issue