lesspipe
Filter/format file contents for 'less' display
SYNOPSIS
lesspipe
DESCRIPTION
lesspipe is a preprocessor for less that allows it to display various file types in a more human-readable format. Instead of displaying raw data, lesspipe uses external programs to convert files to plain text before presenting them to less. This enables viewing compressed files, archives, PDFs, images, and more directly within less without manual extraction or conversion.
It intelligently detects the file type using the file command and appropriate conversion tools. It aims to transparently handle a wide range of formats including zip archives, gzip, bzip2, tarballs, rpm packages, pdf and other document formats, image files, and even audio/video files (by extracting their metadata). lesspipe improves the usability of less when working with a heterogeneous collection of files, by avoiding the need for manually preprocessing files before viewing them.
Configuration can be done using environment variables and shell scripts, allowing customization of the conversion process for different file types. It is a valuable tool for sysadmins, developers, and anyone who frequently needs to view the contents of various file formats from the command line.
CAVEATS
Requires external utilities (e.g., 7z, unrar, pdftotext) to be installed for handling specific file types. Performance can be affected by the size and complexity of the files being processed.
ENVIRONMENT VARIABLES
lesspipe can be customized through environment variables. For example, LESSOPEN and LESSCLOSE are used by less to interface with lesspipe. Other variables can control the behavior of specific file converters. See the script itself for details on available variables.
CONFIGURATION
The script lesspipe typically resides in /usr/bin or /usr/local/bin. It is a shell script that can be modified to add support for new file types or change the behavior of existing converters. The configuration is usually done by editing the script directly.
DEPENDENCIES
The functionality of lesspipe heavily relies on external tools such as: file, gzip, bzip2, tar, zip, unzip, rar, unrar, pdftotext, odt2txt, djvutxt, ffmpeg and many others. Install these tools with your distributions package manager.
HISTORY
lesspipe was created to extend the functionality of less, specifically to handle a wider variety of file formats automatically. Its development arose from the need to view the contents of archive files and compressed files without manually extracting them first. Over time, it has evolved to support even more file formats and provide configuration options for customizing the conversion process.