One of my professional goals this year is to make a marked improvement on my shell (zsh) and editor (vim) skills. I know enough commands to get me through the work day, yet every time I see a real shell or vim poweruser go to town, I am reminded that I am probably only confident in 10% of the commands that I could be using.
Every now and then, I’ll force myself to use h, j, k, l instead of ←, ↑, ↓, → to
navigate in Vim and my Tmux panels. The skill lasts about a week before I’m back
to the arrow keys and mouse. Every now and then, I’ll try to expand beyond
cat, in the shell.
I always rebound after a couple weeks, because I can get 90% done with those
Hence, a series of articles summarizing the man pages for different applications. A process that hopefully sees me making more regular use of them.
My typical solution to navigating a read-only text file is
clear && cat
$filename and then scrollback with the mouse or to pipe. My solution to log
files are to pipe them into text files and open them in Vim (not recommended on
memory-limited systems). So my first Unix command for the year is
wonderful program that I get dumped into by Git all the time.
Less is a program that outputs a text file or stream with a buffer to display either more of the stream or page up to previously output lines.
Less gives me something that I’ve been trying, incorrectly to do with
cat all along: display a buffer of just the text file. With my old solution, on
long file outputs, it was easy to scroll up past the start of the file and into
old commands. With Less, this isn’t a problem. The buffer starts and ends with
the contents of the text file. Likewise, I frequently output formatted excerpts
from my Todo List using the XP and LSGP/LSGC add-ons and
pipe them into text files or open new terminals to have a clean buffer to scroll
back on. Less solves this by outputing the multi-screen-height output into a
|SPACE||Scroll down a screen.|
|RETURN||Scroll down one line.|
|d||Scroll down half a page.|
|u||Scroll up half a page|
|y||Scroll up one line.|
|F||Scroll to the end then
|g||Go to line N|
|G||Go to end of file.|
|m + Char||Marks position with that letter.|
|’ + Char||Return to marked position.|
|@||Search for pattern in file|
|n||Repeat search to next result|
|N||Repeat serach to previous result|
|t||Go to next tag|
|T||Go to previous tag|
|v||Open file in Vim|
|! + Cmd||Invokes shell from inside less|
|-R||Terminal colors maintained|
|-N||Show line numbers|