Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - 5 cool terminal pagers in Fedora

#1
5 cool terminal pagers in Fedora

Large files like logs or source code can run into the thousands of lines. That makes navigating them difficult, particularly from the terminal. Additionally, most terminal emulators have a scrollback buffer of only a few hundred lines. That can make it impossible to browse large files in the terminal using utilities which print to standard output like cat, head and tail. In the early days of computing, programmers solved these problems by developing utilities for displaying text in the form of virtual “pages” — utilities imaginatively described as pagers.

Pagers offer a number of features which make text file navigation much simpler, including scrolling, search functions, and the ability to feature as part of a pipeline of commands. In contrast to most text editors, some terminal pagers do not require loading the entire file for viewing, which makes them faster, especially for very large files.

In the modern era of Linux computing, terminal emulators are more sophisticated than ever. They offer support for a kaleidoscope of colors, terminal resizing, as well as a host of other features to make parsing text on screen easier and more efficient. Terminal pagers have undergone a similar evolution, from extremely simple UNIX utilities like pg and more, to sophisticated programs with a wide range of features, covering any number of use cases. With this in mind, we’ve put together a list of some of the most popular terminal paging utilities — more or less.

More


more is one of the earliest pagers, initially featured in version 3.0 BSD. The first implementation of more was written in 1978 by Daniel Halbert. Since then, more has become a ubiquitous feature of many operating systems, including Windows, OS/2, MacOS and most linux distributions.

more is a very lightweight utility. The version featured in util-linux runs to just under 2100 lines of C. However, this small footprint comes at a price. Most versions of more feature relatively limited functionality, with no support for backwards scroll or search. Commands are similarly stripped back: press enter to scroll one line, or space to scroll one page. Some other useful commands include:

  • Press v while reading to open the current file in your default terminal editor.
  • ‘/pattern‘ let’s you search for the next occurrence of pattern.
  • :n and :p will open the next and previous files respectively when more is called with more than one file as arguments

Less


less was initially conceived as a successor to more, addressing some of its limitations. Building on the functionality of more, less adds a number of useful features including backwards scroll, backwards search. It is also more amenable to window resizing.

Navigation in less is similar to more, though less borrows a few useful commands from the vi editor as well. Users can navigate the document using the familiar home row navigational keys. A glance at the man page for less reveals a fairly rich repertoire of available commands. Some particularly useful examples include:

  • ?pattern lets you search backwards in the file for pattern
  • &pattern shows only lines which feature pattern. This is particularly useful for those who find themselves issuing $ grep pattern | less regularly.
  • Calling less with the -s (–sqeueeze-blank-lines) flag allows you to view text files with large gaps. Multiple newline characters are reduced to single breaks.
  • s filename, called from within the program, saves input to filename (if input is a pipe).
  • Alternatively, calling less with the -o filename flag will save the input of less to filename.

With this enhanced functionality comes a little extra weight. The version of less that ships with Fedora at the time of writing clocks in at around 25000 lines of source code. Granted, for all but the most storage constrained systems, this is a non-issue. Besides, less is more than more.

Most


While less aims to expand on the existing capabilities of more, most takes a different approach. Rather than expanding on the traditional single file view, most gives users the ability to split their view into “windows.” Each window contains different files in different viewing modes.
Significantly, most takes into account the width of its input text. The default viewing mode doesn’t wrap text (-S in less), a feature particularly useful when dealing with “wide” files. While these design decisions might represent a significant departure from tradition for some users, the end result is very powerful.

In addition to the navigation commands offered by more, most uses intuitive mnemonics for file navigation. For example, t moves to the top of a file, and b moves to the bottom. As a result, users unfamiliar with vi and its descendants will find most to be refreshingly simple.

The distinguishing feature of most is its ability to split windows and contexts quickly and easily. For example, one could open two distinct text files using the following:

$ most textFile1.txt textFile2.txt

In order to split the screen horizontally, use the key combos Ctrl+x, 2 or Ctrl+w, 2. The command :n will open the next file argument in a given window, offering a split screen view of two files:


If you turn wrap off in one window, it does not affect the behavior of other windows. The \ character indicates a wrap or fold, while the $ character indicates that the file extends past the limitations of the current window.

pspg


Those who work with SQL databases often need to be able to examine the contents of our databases at a glance. The command line interfaces for many popular open source DBMS’s, such as MySQL and PostGreSQL, use the system default pager to view outputs that don’t fit on a single screen. Utilities like more and less are designed around the idea of presenting text files, but for more structured data, leave something to be desired. Naive text paginating programs have no concept of broad, tabular data, which can be frustrating when dealing with large queries.

pspg attempts to address this by offering users the ability to freeze columns while viewing, sort data in situ, and colourize output. While pspg was intended initially to serve as a pager replacement for psql specifically, the program also supports the viewing of CSV data, and is a suitable drop-in replacement for mysql and pgcli.

Vim


In a modern, technicolor terminal, the idea of endless pages of drab grey on black text can feel like something of an anachronism. The syntax highlighting options offered by powerful text editors like vim can be useful for browsing source code. Furthermore, the search functions offered by vim vastly outclass the competition. With this in mind, vim ships with a shell script less.sh that lets vim serve as a replacement for conventional pagers.

To set vim as the default pager for man pages, add the following to your shell’s config (such as ~/.bashrc if using the default bash shell):

export MANPAGER="/bin/sh -c \"col -b | vim -c 'set ft=man ts=8 nomod nolist nonu noma' -\""

Alternatively, to set vim as the default pager system-wide, locate the less.sh script. (You can find it at /usr/share/vim/vim81/macros/ on current Fedora systems.) Export this location as the variable PAGER to set it as default, or under an alias to invoke it explicitly.


Photo by Cathy Mü on Unsplash.



https://www.sickgaming.net/blog/2019/12/...in-fedora/
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Fedora - Using network bound disk encryption with Stratis xSicKxBot 0 8 04-07-2021, 02:52 PM
Last Post: xSicKxBot
  Fedora - Contribute at Fedora Linux 34 Upgrade, Audio, and Virtualization test days xSicKxBot 0 10 04-06-2021, 10:27 AM
Last Post: xSicKxBot
  Fedora - Fedora Council statement on Richard Stallman rejoining FSF Board xSicKxBot 0 8 04-03-2021, 11:11 AM
Last Post: xSicKxBot
  Fedora - Playing with modular synthesizers and VCV Rack xSicKxBot 0 21 03-31-2021, 02:01 PM
Last Post: xSicKxBot
  Fedora - Network address translation part 3 – the conntrack event framework xSicKxBot 0 18 03-26-2021, 10:16 AM
Last Post: xSicKxBot
  Fedora - Announcing the release of Fedora Linux 34 Beta xSicKxBot 0 23 03-24-2021, 02:28 PM
Last Post: xSicKxBot
  Fedora - Productivity with Ulauncher xSicKxBot 0 21 03-22-2021, 06:29 PM
Last Post: xSicKxBot
  Fedora - 4 cool new projects to try in COPR for March 2021 xSicKxBot 0 24 03-19-2021, 09:16 AM
Last Post: xSicKxBot
  Fedora - Fedora Workstation 34 Feature Focus: Updated Activities Overview xSicKxBot 0 28 03-17-2021, 03:08 PM
Last Post: xSicKxBot
  Fedora - How to use Poetry to manage your Python projects on Fedora xSicKxBot 0 28 03-09-2021, 10:57 AM
Last Post: xSicKxBot

Forum Jump:

[-]
Active Threads
[Tut] Your First Dash App – How to Get S...
Last Post: xSicKxBot
Yesterday 06:58 PM
» Replies: 0
» Views: 3
(Indie Deal) Patrician, Sudden Strike, C...
Last Post: xSicKxBot
Yesterday 05:40 PM
» Replies: 0
» Views: 3
picoCAD — A Tiny Modeller For Tiny Model...
Last Post: xSicKxBot
Yesterday 05:40 PM
» Replies: 0
» Views: 4
News - Community Focus – Gumpita
Last Post: xSicKxBot
Yesterday 05:38 PM
» Replies: 0
» Views: 3
Xbox Wire - Black Desert: New Sage Class...
Last Post: xSicKxBot
Yesterday 05:37 PM
» Replies: 0
» Views: 4
News - Twitch outlines plan to take acti...
Last Post: xSicKxBot
Yesterday 05:36 PM
» Replies: 0
» Views: 8
News - Don’t Miss: Devs reflect on the i...
Last Post: xSicKxBot
Yesterday 05:36 PM
» Replies: 0
» Views: 7
News - World War 2 MMO Enlisted Out Now ...
Last Post: xSicKxBot
Yesterday 05:36 PM
» Replies: 0
» Views: 8
AppleInsider - Logitech discontinues Har...
Last Post: xSicKxBot
Yesterday 08:21 AM
» Replies: 0
» Views: 7
News - Legend Of Mana’s Physical Switch ...
Last Post: xSicKxBot
Yesterday 08:20 AM
» Replies: 0
» Views: 6

[-]
Twitter

[-]
Sponsored
Get the Deal of the Week at RefurBees.com

Copyright © SickGaming.net 2012-2020