Eless - A Better Less
*eless* is a combination of Bash script and a minimal emacs
This script is designed to:
- Be portable – Just one bash script to download to run
- Be independent of a user’s emacs config
- You can still customize the =eless= config if you like.
- Not require an emacs server to be already running
It was created out of a need to have something like
less (in the
sense of launch quickly, do, and quit), but better in these ways:
- Syntax highlighting
- Org-mode file rendering
- A better navigable man page viewer
- A better Info viewer
- Dired, especially
wdired(batch edit symbolic links, for example?)
- Colored diffs,
ls, etc. (auto ANSI detection)
- Filter log files to only show (or not show) lines matching a regexp
- Auto-revert log files when I want (like
- Quickly change frame and font sizes
- .. and more; basically everything that emacs has to offer!
I call it
eless and here’s a little taste of what it looks like:
Shown above, starting from top left image and proceeding clock-wise..
rg --color=ansi 'man pages' | eless(rg?)
man grep(I have set my
PAGERenv var to
info eless(I have aliased
infoto =’\info \!* | eless’= in my tcsh shell.)
eless .(Shows the current directory contents in
eless.orgwith an older saved version and piping the result to
- [X] This script passes ShellCheck, and
- [X] Unofficial Bash strict mode is enabled.
- [X] Always-in-sync documentation as the
elessscript and documentation are generated using Org Babel from one file (even this README).
- [X] The documentation site is generated on-the-fly on Netlify using that same one file.
- [X] This bash script has tests too!
|If only running the |
|This is a |
|Perl is used to replace |
- If the environment variable
elessuses that as the emacs binary, else it defaults to using
emacsas emacs binary.
I do not have an installation script for this project, but you can install it quickly with few manual steps.
Clone this rep
For the following instructions, let’s assume that you clone this repo
git clone https://github.com/kaushalmodi/eless ~/downloads/eless
Assuming that you have
~/.local/bin/ directory added to your
cp -f ~/downloads/eless/eless ~/.local/bin/. # Just making sure that the script has executable permissions. chmod +x ~/.local/bin/eless
And finally, let’s say have a
~/.local/share/ directory. Then copy
the documentation to an
eless/ sub-directory in that.
mkdir -p ~/.local/share/eless/info # Org source - One source for script + documentation cp -f ~/downloads/eless/eless.org ~/.local/share/eless/eless.org cp -f ~/downloads/eless/docs/eless.info ~/.local/share/eless/info/eless.info cp -f ~/downloads/eless/docs/dir ~/.local/share/eless/info/dir
Make sure that you add
~/.local/share/eless/info to your environment
Installation Directory Structure
In the end, the file structure for the newly copied files should look like this:
~/.local ├── bin/ │ └── eless └── share/ └── eless/ ├── eless.org └── info/ ├── eless.info └── dir
If you plan to keep the cloned
eless repo updated to the latest
master all the time (which I recommend), then you may even create
symlinks to those instead of copying them in the above steps.
Try it out
Here are some usage examples:
eless foo.txt # Open foo.txt in eless in terminal (-nw) mode by default. eless foo.txt --gui # Open foo.txt in eless in GUI mode. echo 'foo' | eless # echo 'foo' | eless - # Same as above. The hyphen after eless does not matter; is anyways discarded. grep 'bar' foo.txt | eless # diff foo bar | eless # Colored diff! diff -u foo bar | eless # Colored diff for unified diff format eless . # Open dired in the current directory (enhanced 'ls') ls --color=always | eless # Auto-detect ANSI color codes and convert those to colors PAGER=eless git diff # Show git diff with ANSI coded colors eless -h | eless # See eless help ;-) info emacs | eless # Read emacs Info manual in eless eless foo.tar.xz # Read the contents of archives; emacs does the unarchiving automatically PAGER=eless python3; help('def') # Read (I)Python keyword help pages (example: help for 'def' keyword) PAGER=eless python3; help('shlex') # Read (I)Python module help pages (example: help for 'shlex' module) PAGER=eless python3; help('TYPES') # Read (I)Python topic help pages (example: help for 'TYPES' topic) PAGER=eless man grep # Launches man pages in eless (terminal mode), if the env var PAGER is set to eless (does not work on macOS). PAGER=less man -P eless grep # Launches man pages in eless (terminal mode), if the env var PAGER is *not* set to eless (works on macOS). PAGER="eless --gui" man grep # Launches man pages in eless (GUI mode), if the env var PAGER is set to "eless --gui" (does not work on macOS). PAGER=less man -P "eless --gui" grep # Launches man pages in eless (GUI mode), if the env var PAGER is *not* set to eless (works on macOS).
- Above examples are tested to work in a =bash=
shell. Specifically, examples like
PAGER=eless man grepmight need to be adapted for the shell you are using, and also the OS.
- Thanks to Skye Shaw for helping improving
elessso that it can run on macOS and emacs 22.1, and suggesting Bash
- Thanks to Iqbal Ansari for adding support to
read piped data in
emacs -Q -nw.
- Thanks to Adam Porter for adding a
bashcollapsing function for debug statements, and testing out and providing suggestions on improving the