Navigating the command line is a cornerstone of Linux proficiency, and the man
command is your trusty guide, providing detailed manuals for virtually every command. But what if you need to test something out or run a quick command while immersed in a lengthy man page? Do you have to exit, execute, and then laboriously find your place again? Thankfully, no! There’s a neat trick, let’s call it the “Page Cat” maneuver, that lets you seamlessly drop into a shell and then return right back to where you were reading.
This “Page Cat” technique leverages the power of pagers, the tools man
uses to display its output, and it’s incredibly simple to use. Let’s explore how you can harness this to boost your command-line workflow.
The most common pager in Linux is less
, and it comes with a fantastic feature: the ability to escape to a shell. Here’s how to use the “Page Cat” with less
:
First, access your man page as usual, for example:
$ man col | col -b | less
This command pipes the output of man col
through col -b
(which removes backspaces for cleaner output) and then into less
. Once you are viewing the col
man page in less
, simply type:
!bash
This magical command, the heart of our “Page Cat” trick, will drop you directly into a bash
shell prompt, right from within less
! You can now execute any commands you need, without losing your place in the man page.
pwd
exit
In the example above, we ran the pwd
command to see our current directory. When you’re done with your shell commands, just type exit
and you’ll be instantly returned to the less
pager, exactly where you left off in the col
man page. It’s like a cat smoothly slipping out and back in – hence, our “Page Cat” name!
ss of demo
This seamless transition is incredibly useful for trying out commands explained in the man page, checking file paths, or performing any other quick shell tasks without interrupting your reading flow.
Streamlining with the -P
Switch
For even faster “Page Cat” access, you can tell man
to specifically use less
as the pager right from the start with the -P
switch:
$ man -P less col
This command directly invokes man
and instructs it to output the col
man page using less
. From here, the “Page Cat” trick works exactly the same: use !bash
to jump to the shell and exit
to return. This method is slightly more streamlined as it avoids piping through col
in the command itself if you know you’ll be using less
.
The Default Pager is Already Your “Page Cat”
Interestingly, you might already be using the “Page Cat” without even realizing it! The default pager that man
uses (often less
or a similar pager like more
) typically also supports the !bash
shell escape command.
So, even if you simply use:
$ man col
and you are in the default pager, you can very likely still use the !bash
command to access the shell and exit
to return. This means the “Page Cat” functionality is often readily available without any special commands or configurations.
Beyond less
: Vim as a Pager for Power Users
For those who want even more control and features, you can even configure vim
as your man page pager. This is a more advanced setup, but it unlocks the full power of vim
‘s editing and navigation capabilities within your man pages. Detailed instructions for setting up vim
as a man page viewer can be found in resources like the Vim Wikia: Using vim as a man-page viewer under Unix.
This opens up a world of possibilities for power users who are already comfortable with vim
‘s extensive commands and want to bring that efficiency to their man page reading experience.
Conclusion: Embrace the “Page Cat” for Efficient Command-Line Mastery
The “Page Cat” trick – using !bash
within your man
page pager – is a simple yet incredibly effective way to enhance your Linux command-line workflow. Whether you’re using the default pager or specifically invoking less
, this technique allows you to seamlessly switch between reading documentation and executing commands, saving you time and keeping you in the flow. Try out the “Page Cat” today and experience a smoother, more efficient command-line journey!