LESS(1)
๐ LESS(1) ๐
less is the manual page for the General Commands Manual ๐ธ
โจ NAME โจ
less - display the contents of a file in a terminal ๐
๐ SYNOPSIS ๐
less -?
less --help
less -V
less --version
less [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]
[-b space] [-h lines] [-j line] [-k keyfile]
[-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
[-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
[-# shift] [+[+]cmd] [--] [filename]...
(Psst, the OPTIONS section has the alternate option syntax with long option names, so go check that out too ๐)
๐ฆ DESCRIPTION ๐ฆ
Okay so less is basically a cousin of more(1), but it has way more features ๐ It doesn't have to read the entire input file before it starts, so with big files it boots up faster than text editors like vi(1). Iconic behavior honestly โจ
It uses termcap (or terminfo on some systems), so it can run on a whole bunch of different terminals ๐ง There's even limited support for hardcopy terminals. (On a hardcopy terminal, lines that should be printed at the top of the screen get a caret in front of them ๐จ๏ธ)
Commands are based on both more and vi, so if you've used either, you're already halfway there ๐ Commands can be preceded by a decimal number, called N in the descriptions below. Some commands use it, and the ones that do will tell you so ๐ข
๐ COMMANDS ๐
In the following descriptions, ^X means control-X. ESC stands for the ESCAPE key, so for example ESC-v means the two character sequence "ESCAPE", then "v" ๐
horHโ Help! It displays a summary of these commands. If you forget everything else, remember this one ๐SPACEor^Vorfor^Fโ Scrolls forward N lines, default one window (see option-zbelow). If N is more than the screen size, only the final screenful gets displayed. > Warning: some systems use^Vas a special literalization character, so it might not do what you expect ๐zโ Like SPACE, but if N is specified, it becomes the new window size โจESC-SPACEโ Like SPACE, but it scrolls a full screenful, even if that takes you right to end-of-file ๐ENTERorRETURNor^Noreor^Eorjor^Jโ Scrolls forward N lines, default 1. The entire N lines get displayed, even if N is more than the screen size ๐ซถdor^Dโ Scrolls forward N lines, default one half of the screen size. If N is specified, it becomes the new default for laterdanducommands ๐bor^BorESC-vโ Scrolls backward N lines, default one window (see option-zbelow). If N is more than the screen size, only the final screenful gets displayed ๐wโ LikeESC-v, but if N is specified, it becomes the new window size ๐ชyor^Yor^Porkor^Kโ Scrolls backward N lines, default 1. The entire N lines get displayed, even if N is more than the screen size. > Warning: some systems use^Yas a special job control character, so watch out ๐จuor^Uโ Scrolls backward N lines, default one half of the screen size. If N is specified, it becomes the new default for laterdanducommands ๐Jโ Likej, but keeps scrolling past the end of the file ๐KorYโ Likek, but keeps scrolling past the beginning of the file ๐ESC-)or RIGHTARROW โ Scrolls horizontally right N characters, default half the screen width (see the-#option). If a number N is specified, it becomes the default for future RIGHTARROW and LEFTARROW commands. While the text is scrolled sideways, it acts like the-Soption (chop lines) is on ๐ESC-(or LEFTARROW โ Scrolls horizontally left N characters, default half the screen width (see the-#option). If a number N is specified, it becomes the default for future RIGHTARROW and LEFTARROW commands ๐ESC-}or^RIGHTARROWโ Scrolls horizontally right so you can see the end of the longest displayed line ๐โโ๏ธESC-{or^LEFTARROWโ Scrolls horizontally left all the way back to the first column ๐ror^Ror^Lโ Repaints the screen ๐จRโ Repaints the screen and throws away any buffered input. Basically it reloads the current file. Super useful if the file is changing while you're looking at it ๐Fโ Scrolls forward, and keeps trying to read when the end of file is reached. You'd normally use this when you're already at the end of the file. It's a way to watch the tail of a file that's growing while you view it ๐ (It acts similar to thetail -fcommand.) To stop waiting for more data, hit the interrupt character (usually^C). On systems that support poll(2), you can also use^Xor the character specified by the--introption. If the input is a pipe and the--exit-follow-on-closeoption is in effect, less will automatically stop waiting for data once the input side of the pipe is closed ๐ESC-Fโ LikeF, but as soon as it finds a line matching the last search pattern, the terminal bell rings and forward scrolling stops ๐gor<orESC-<โ Goes to line N in the file, default 1 (beginning of file). > Warning: this may be slow if N is large ๐ขGor>orESC->โ Goes to line N in the file, default the end of the file. > Warning: this may be slow if N is large, or if N is not specified and standard input (rather than a file) is being read ๐ESC-Gโ Same asG, except if no number N is specified and the input is standard input, it goes to the last line that's currently buffered ๐ฆpor%โ Goes to a position N percent into the file. N should be between 0 and 100, and may contain a decimal point ๐Pโ Goes to the line containing byte offset N in the file ๐ฏ{โ If a left curly bracket shows up in the top line on the screen, the{command goes to the matching right curly bracket. The matching right curly bracket gets positioned on the bottom line of the screen. If there's more than one left curly bracket on the top line, a number N can be used to pick the N-th bracket on that line ๐ง}โ If a right curly bracket shows up in the bottom line displayed on the screen, the}command goes to the matching left curly bracket. The matching left curly bracket gets positioned on the top line of the screen. If there's more than one right curly bracket on the bottom line, a number N can be used to pick the N-th bracket on that line ๐ง(โ Like{, but for parentheses instead of curly brackets ๐)โ Like}, but for parentheses instead of curly brackets ๐[โ Like{, but for square brackets instead of curly brackets ๐ฆ]โ Like}, but for square brackets instead of curly brackets ๐ฆESC-^Fโ Followed by two characters, it acts like{, but uses those two characters as the open and close brackets, respectively. For example,ESC ^F < >could be used to go forward to the>that matches the<on the top displayed line ๐ESC-^Bโ Followed by two characters, it acts like}, but uses those two characters as the open and close brackets, respectively. For example,ESC ^B < >could be used to go backward to the<that matches the>on the bottom displayed line โชmโ Followed by any lowercase or uppercase letter, marks the first displayed line with that letter. If the status column is enabled via the-Joption, the status column shows the marked line ๐๏ธMโ Acts likem, except the last displayed line gets marked instead of the first ๐๏ธ'โ (Single quote.) Followed by any lowercase or uppercase letter, returns you to the position that was previously marked with that letter. Followed by another single quote, returns you to the position where the last "large" movement command was executed. Followed by a^or$, it jumps to the beginning or end of the file respectively. Marks are preserved when a new file is examined, so the'command can be used to switch between input files ๐ช^X^Xโ Same as single quote ๐ชESC-mโ Followed by any lowercase or uppercase letter, clears the mark identified by that letter ๐งน/patternโ Searches forward in the file for the N-th line containing the pattern. N defaults to 1. The pattern is a regular expression, as recognized by the regular expression library your system supplies. By default, searching is case-sensitive (uppercase and lowercase are considered different), but the-ioption can change that ๐ The search starts at the first line displayed (but see the-aand-joptions, which change this).
Certain characters are special if you enter them at the beginning of the pattern. They modify the type of search rather than becoming part of the pattern ๐งโโ๏ธ
^Nor!โ Searches for lines that do NOT match the pattern ๐ โโ๏ธ^Eor*โ Searches multiple files. That is, if the search reaches the END of the current file without finding a match, the search keeps going in the next file in the command line list ๐^For@โ Begins the search at the first line of the FIRST file in the command line list, no matter what's on the screen or what the-aor-joptions are set to ๐^Kโ Highlights any text matching the pattern on the current screen, but doesn't move to the first match (you KEEP your current position) ๐๏ธ^Rโ Doesn't interpret regular expression metacharacters. It does a simple textual comparison instead ๐ค^Sโ Followed by a digit N between 1 and 5. Only text with a non-empty match for the N-th parenthesized SUB-PATTERN will be considered a match for the pattern. (This is only supported if less is built with one of the regular expression libraries posix, pcre, or pcre2.) You can specify multiple^Smodifiers to match more than one sub-pattern ๐งฉ^Wโ WRAPS around the current file. That is, if the search reaches the end of the current file without finding a match, it continues from the first line of the current file up to the line where it started ๐ If the^Wmodifier is set, the^Emodifier gets ignored.^Lโ The next character is taken literally, so it becomes part of the pattern even if it's one of the search modifier characters above ๐
โจ COMMANDS โจ (part 2, bestie, let's go ๐ซถ)
?pattern๐ โ okay so this one searches backward for the N-th line containing the pattern. It starts at the last line on screen (but the-aand-joptions can change that, so keep an eye on them ๐).
Certain characters are super special here, same as the / command:
^Nor!๐ โโ๏ธ โ finds lines that do NOT match the pattern. Lowkey iconic.^Eor*๐ธ โ searches multiple files. If it hits the beginning of the current file with no match, it keeps going in the previous file in the command line list.^For@๐ง โ starts the search at the last line of the last file in the command line list, no matter what's on screen or what-aor-jare set to.^Kโ same as forward searches, nothing new here bestie ๐^Rโ also same as forward searches โจ^Sโ yep, same as forward searches too ๐^W๐ โ WRAP around the current file. If it reaches the beginning without a match, it continues from the last line of the current file, all the way up to where it started.
ESC-/patternโ same as"/*"๐ฆESC-?patternโ same as"?*"๐ฆn๐ โ repeats the previous search for the N-th line containing the last pattern. If the last search was modified by^N, it finds the N-th line NOT containing the pattern. If it was modified by^E, it continues into the next (or previous) file when the current one doesn't have what you want. If it was modified by^R, the search skips regular expressions entirely. And if the last search was modified by^For^K,ndoes absolutely nothing ๐Nโ repeats the previous search but in the reverse direction ๐ESC-nโ repeats the previous search and crosses file boundaries. It's basically like the last search was modified by*๐ESC-Nโ reverse direction AND crossing file boundaries. Main character energy ๐ESC-u๐งน โ undoes search highlighting. It turns off the highlighting for strings matching the current search pattern. If highlighting is already off because you usedESC-ubefore, this turns it back on. Any search command will also flip highlighting back on. (You can also disable highlighting by toggling the-Goption, but in that case search commands will not turn it back on.)ESC-U๐ โ likeESC-u, but it also clears the saved search pattern. If the status column is turned on with the-Joption, this clears all the search matches marked in that column.&pattern๐ โ displays only the lines that match the pattern. Everything else gets hidden. If the pattern is empty (you type&and then hit ENTER right away), filtering is turned off and every line shows up again. While filtering is on, an ampersand shows up at the start of the prompt as a little reminder that some lines are hidden, so don't get confused, babe ๐ซถ You can stack multiple&commands, and then only lines matching all of the patterns will show.
Certain characters are special here too, same as the / command:
^Nor!โ displays only lines that do NOT match the pattern.^Rโ don't interpret regex metacharacters, just do a simple textual comparison ๐
:e [filename]๐ โ examines a new file. If you leave out the filename, the "current" file (see:nand:pbelow) from the command line list gets re-examined. A percent sign (%) in the filename gets replaced by the name of the current file, and a pound sign (#) gets replaced by the name of the previously examined file. Two percent signs in a row become a single%, so you can name a file that has a percent sign in it. Same deal with two pound signs becoming one#๐ The filename also gets added to the command line list so later:nand:pcommands can see it. If you give several files, they all get added to the list and the first one gets examined. If the filename has one or more spaces, wrap the whole thing in double quotes (also see the-"option).^X^VorEโ same as:e๐
โ ๏ธ Warning, bestie: some systems use^Vas a special literalization character. On those, you might not be able to use^Vat all ๐ญ
:nโญ๏ธ โ examines the next file from the list given on the command line. If you specify a number N, it examines the N-th next file instead.:pโฎ๏ธ โ examines the previous file in the command line list. If you give a number N, it's the N-th previous file.:x๐ฅ โ examines the first file in the command line list. If you give a number N, it examines the N-th file in the list.:d๐๏ธ โ removes the current file from the list of files. Byeee ๐t๐ท๏ธ โ goes to the next tag, but only if the current tag has more than one match. Check the-toption for more deets on tags.Tโ goes to the previous tag, again only if the current tag has more than one match.^O^Nor^On๐ โ searches forward in the file for the N-th next OSC 8 hyperlink.^O^Por^Opโ searches backward in the file for the N-th previous OSC 8 hyperlink.^O^Lor^Olโจ โ jumps to the currently selected OSC 8 hyperlink.=or^Gor:f๐ โ prints some info about the file you're viewing, including its name, plus the line number and byte offset of the bottom line on screen. If it's possible, it also prints the length of the file, the number of lines in it, and the percent of the file above the last displayed line. Stats-core behaviour ๐ค-๐๏ธ โ followed by one of the command line option letters (see OPTIONS below), this changes that option's setting and prints a message describing the new setting. If you type a^P(CONTROL-P) right after the dash, the option still changes but no message gets printed. If the option letter takes a numeric value (like-bor-h) or a string value (like-Por-t), you can type the new value right after the letter. If you don't enter a new value, you'll get a message describing the current setting and nothing changes.--โ like the-command, but it takes a long option name (see OPTIONS below) instead of a single letter. You have to press ENTER or RETURN after typing the name. A^Pright after the second dash suppresses the message, same as the-command ๐คซ-+๐ โ followed by one of the command line option letters, this resets the option to its default setting and prints a message describing the new setting. (The"-+X"command does the same thing as"-+X"on the command line.) This does not work for string-valued options, so don't even try ๐--+โ like the-+command, but with a long option name instead of a single letter.-!๐ โ followed by one of the command line option letters, this resets the option to the "opposite" of its default setting and prints a message describing the new setting. This does not work for numeric or string-valued options.--!โ like the-!command, but with a long option name instead of a single letter._(underscore) ๐ โ followed by one of the command line option letters, this prints a message describing the current setting of that option. The setting itself is not changed.__(double underscore) โ like the_command, but takes a long option name. You must press ENTER or RETURN after typing the name.+cmd๐ โ causes the specifiedcmdto run every time a new file gets examined. For example,+Gmakes less show each file starting at the end instead of the beginning. Lowkey a game changer ๐V๐ท๏ธ โ prints the version number of the less you're running.qorQor:qor:QorZZ๐ โ exits less. Peace out โ๏ธ
The following seven commands may or may not be valid, depending on your particular installation. So if one of these acts weird, it's probably your setup, not you ๐ซถ
v๐ โ invokes an editor to edit the current file being viewed. The editor comes from the environment variableVISUALif it's defined. IfVISUALisn't defined, it usesEDITOR. If neither is defined, it defaults to"vi". See also the discussion ofLESSEDITunder the section on PROMPTS below.! shell-command๐ โ invokes a shell to run the shell-command you give it. A percent sign (%) in the command gets replaced by the name of the current file, and a pound sign (#) gets replaced by the name of the previously examined file."!!"repeats the last shell command, and"!"with no shell command just invokes a shell. If you type a^P(CONTROL-P) right after the!, no "done" message gets printed after the shell command runs. On Unix systems, the shell comes from the environment variableSHELL, or defaults to"sh". On MS-DOS, Windows, and OS/2 systems, the shell is the normal command processor ๐ป# shell-commandโ similar to the!command, except the command gets expanded the same way as prompt strings. For example, the name of the current file would be written as"%f"๐งฉ| <m> shell-command๐ฐ โ here<m>stands for any mark letter. It pipes a section of the input file to the given shell command. The section is everything between the position marked by that letter and the current screen. The entire current screen is always included, whether the marked position is before or after it.<m>can also be^or$to mean the beginning or end of the file. If<m>is.or a newline, only the current screen gets piped. And if you type a^P(CONTROL-P) right after the mark letter, no "done" message gets printed after the shell command runs.s filename๐พ โ saves the input to a file. This only works if the input is a pipe, not an ordinary file, so it's not gonna work on regular files, sorry bestie ๐ฅบ^O^Oโ okay so this one is a whole vibe ๐ It runs a shell command to open the URI in the current OSC 8 hyperlink, the one you picked with a previous^O^Nor^O^P. To find that shell command, less reads the environment variable calledLESS_OSC8_xxx, wherexxxis the scheme from the URI (the part before the first colon), or it's empty if there's no colon in the URI at all. Then the variable's value gets expanded just like prompt strings (so any%ogets swapped out for the URI ๐ซถ) to make an OSC 8 "handler" shell command. Whatever the handler spits out to standard output is an "opener" shell command, and that's what gets executed to actually open the URI โจ
There are two special cases, and they're kind of iconic:
- If the URI begins with
#, the rest of the URI is treated as the value of the id parameter in another OSC 8 link in the same file, and^O^Owill just jump you straight to that link ๐ฆ - If the opener begins with the characters
:efollowed by whitespace and a filename, then instead of running the opener as a shell command, that filename gets opened in the current instance of less ๐
In a simple case where the opener takes the complete URI as a command line parameter, the handler can be as simple as:
echo mybrowser '%o'
In other cases the URI might need some tweaking first, so the handler may have to do some manipulation of the %o value ๐
If the LESS_OSC8_xxx variable isn't set, less tries the variable LESS_OSC8_ANY instead. If neither LESS_OSC8_xxx nor LESS_OSC8_ANY is set, links using the "xxx" scheme just cannot be opened, bestie ๐ BUT there are default handlers for the schemes "man" (used when LESS_OSC8_man isn't set) and "file" (used when LESS_OSC8_file isn't set). They should work on systems that provide the sed(1) command and a shell with syntax compatible with the Bourne shell sh(1). Now, if you use LESS_OSC8_ANY to override LESS_OSC8_file, you have to set LESS_OSC8_file to - to say "don't use the default value," and the same goes for LESS_OSC8_man ๐
The URI passed to an OSC8 handler via%ois guaranteed to NOT contain any single quote or double quote characters. It can contain other shell metacharacters like semicolons, dollar signs, ampersands, etc., so the handler needs to carefully quote its parameters in the opener command. Otherwise opening a URI full of metacharacters could run unintended shell commands ๐ญ Also, since the handler command gets expanded like a command prompt, any metacharacters that prompt expansion interprets (like percent, dot, colon, backslash, etc.) must be escaped with a backslash. Check thePROMPTSsection for the deets ๐ธ
^Xโ when the "Waiting for data" message is showing, like while you're in the F command, pressing^Xstops less from waiting and drops you back to a prompt โจ Heads up though: this might make less think the file ends at the current position, so you may need to use the R or F command to see more data. The--introption lets you pick a different character to use instead of^X. This command only works on systems that support thepoll(2)function. On systems withoutpoll(2), the interrupt character (usually^C) can be used instead ๐
โจ OPTIONS โจ
Command line options are described below, and most of them can be changed while less is running, via the - command ๐ง
Some options can be given in one of two forms: either a dash followed by a single letter, or two dashes followed by a long option name. A long option name can be abbreviated as long as the abbreviation is unambiguous. For example, --quit-at-eof can be shortened to --quit, but NOT --qui, because both --quit-at-eof and --quiet begin with --qui ๐
โโ๏ธ Some long option names are in uppercase, like --QUIT-AT-EOF, which is different from --quit-at-eof. Those only need their first letter capitalized, and the rest can be in either case. So --Quit-at-eof is equivalent to --QUIT-AT-EOF ๐
Options are also taken from the environment variable LESS. For example, so you don't have to type less -options ... every single time, you could tell csh:
setenv LESS "-options"
or if you use sh:
LESS="-options"; export LESS
On MS-DOS and Windows you don't need the quotes, but be careful that any percent signs in the options string aren't interpreted as an environment variable expansion ๐
The environment variable gets parsed before the command line, so command line options override the LESS environment variable. If an option appears in the LESS variable, you can reset it to its default value on the command line by starting the command line option with -+ ๐
Some options, like -k or -D, need a string to follow the option letter. That string is considered to end when a dollar sign ($) is found. For example, you can set two -D options like this:
LESS="Dnwb$Dsbw"
If the --use-backslash option appears earlier in the options, then a dollar sign or backslash can be included literally in an option string by putting a backslash in front of it. If --use-backslash is NOT in effect, backslashes aren't treated specially, and there's no way to include a dollar sign in the option string ๐ค
-?,--helpโ shows a summary of the commands less accepts (same as the h command) ๐ Depending on how your shell interprets the question mark, you might need to quote it, like this:-\?.-a,--search-skip-screenโ by default, forward searches start at the top of the displayed screen and backward searches start at the bottom (except for repeated searches from the n or N commands, which start after or before the "target" line respectively; check the-joption for more on the target line ๐ฏ). The-aoption flips it so forward searches start at the bottom of the screen and backward searches start at the top, which skips all the lines already displayed on screen โจ-A,--SEARCH-SKIP-SCREENโ makes ALL forward searches (not just the non-repeated ones) start just after the target line, and ALL backward searches start just before the target line. So forward searches skip part of the displayed screen (from the first line up to and including the target line), and backward searches skip the displayed screen from the last line up to and including the target line. This was the default behavior in less versions prior to 441 ๐ฐ๏ธ-bn,--buffers=nโ sets how much buffer space less uses for each file, in kilobytes (1024 bytes each). By default you get 64 KB per file (unless the file is a pipe; see the-Boption). The-boption lets you choose n kilobytes instead. If n is-1, the buffer space is unlimited, which means the entire file can be read into memory ๐ง-B,--auto-buffersโ by default, when data is read from a pipe, buffers get allocated automatically as needed. If a large amount of data comes through the pipe, that can eat up a lot of memory ๐ต The-Boption turns off this automatic buffer allocation for pipes, so only 64 KB (or whatever amount the-boption specifies) is used.
Warning: using -B can result in erroneous display, since only the most recently viewed part of the piped data is kept in memory. Any earlier data is lost, and lost characters get displayed as question marks โ
-c,--clear-screenโ makes full screen repaints paint from the top line down. By default, full screen repaints scroll from the bottom of the screen instead ๐-C,--CLEAR-SCREENโ same as-c, kept around for compatibility with older versions of less ๐ต-d,--dumbโ suppresses the error message that normally shows up if the terminal is dumb, meaning it's missing some important capability like clearing the screen or scrolling backward ๐ The-doption doesn't change anything else about how less behaves on a dumb terminal.-Dxcolor,--color=xcolorโ changes the color of different parts of the displayed text ๐xis a single character that picks which type of text gets its color set:Bโ Binary characters.Cโ Control characters.Eโ Errors and informational messages.Hโ Header lines and columns, set via the--headeroption.Mโ Mark letters in the status column.Nโ Line numbers enabled via the-Noption.Pโ Prompts.Rโ The rscroll character.Sโ Search results.Wโ The highlight enabled via the-woption.1-5โ The text in a search result that matches the first through fifth parenthesized sub-pattern. Sub-pattern coloring only works if less is built with one of the regular expression librariesposix,pcre, orpcre2๐dโ Bold text.kโ Blinking text.sโ Standout text.uโ Underlined text.
The uppercase letters and digits can only be used when the --use-color option is enabled. If a text color is specified by both an uppercase and a lowercase letter, the uppercase one takes precedence. For example, error messages are normally displayed as standout text, so if both s and E get a color, the E color applies to error messages and the s color applies to everything else that's standout ๐
The lowercase letters refer to bold and underline text formed by overstriking with backspaces (see the -U option) and to non-content text (like line numbers and prompts), but NOT to text formatted with ANSI escape sequences under the -R option. (Check the note below for different behavior on Windows and MS-DOS ๐ซถ)
Okay so bestie, we're picking up right where the -D color stuff left off, and it gets so detailed ๐ญ๐
A lowercase letter can be followed by a + ๐
which means you get the normal format change AND the color you picked. For example, -Dug shows underlined text as green without underlining, because green took over the usual underline look. But -Du+g gives you both green and underlined โจ Iconic.
color is either a 4-bit color string or an 8-bit color string ๐
4-bit color strings are one or two characters. The first one picks the foreground color and the second picks the background ๐จ
bโ Blue ๐cโ Cyan ๐ฉตgโ Green ๐kโ Black ๐คmโ Magenta ๐rโ Red โค๏ธwโ White ๐คyโ Yellow ๐
Uppercase version = a brighter shade โจ So -DNGk makes line numbers bright green on black, and -DEbR makes error messages blue on a bright red background ๐ญ If either character is a - or you just leave it out, that part goes back to normal text, no cap.
8-bit color strings are one or two decimal integers separated by a dot ๐ง The first is the foreground, the second is the background. Each number is between 0 and 255 inclusive, and it picks a CSI 38;5 color value (see https://en.wikipedia.org/wiki/ANSI_escape_code#SGR). Same deal here: a - or a missing number means normal text.
A 4-bit or 8-bit color string can also be followed by one or more of these attribute characters to add text styling on top of the color ๐
sor~โ Standout (reverse video) ๐uor_โ Underline ๐ซถdor*โ Bold ๐ชlor&โ Blinking ๐จ
Heads up, MS-DOS and Windows peeps ๐ The --color option acts a little different over there, in these ways:
- The bold (
dand*) and blinking (land&) attributes at the end of a color string are not supported ๐ - Lowercase color selector letters also refer to text formatted with ANSI escape sequences using
-R, plus overstruck and non-content text (but see-Da) โจ - For historical reasons ๐ฟ, when a lowercase color selector letter is followed by a numeric color value, the number is NOT read as a
CSI 38;5color value. Instead it's a 4-bitCHAR_INFO.Attributesvalue, between0and15inclusive (seehttps://learn.microsoft.com/en-us/windows/console/char-info-str).- To avoid confusion, use the matching letters instead of numbers after a lowercase color selector on MS-DOS/Windows. Trust ๐ซถ
- Numeric color values (
CSI 38;5color) after an uppercase color selector letter are not supported on systems older than Windows 10 ๐ญ - Only a limited set of ANSI escape sequences that set color in the content work properly. 4-bit color sequences work, but
CSI 38;5color sequences do not ๐ - The
-Daoption makes--coloract more like it does on non-MS-DOS/Windows systems ๐ It does this by (1) making lowercase color selector letters NOT affect text formatted with ANSI escape sequences, and (2) allowingCSI 38;5color sequences in the content to work by passing them through to the terminal. That second part only works on Windows 10 and later; on earlier Windows systems those sequences don't work no matter what-Dais set to ๐ญ
-e,--quit-at-eofโ Makes less auto-exit the second time it hits end-of-file โจ By default, the only way out of less is theqcommand ๐ช-E,--QUIT-AT-EOFโ Makes less auto-exit the first time it hits end-of-file ๐โโ๏ธ-f,--forceโ Forces non-regular files to open ๐ (A non-regular file is a directory or a device special file.) It also hides the warning you get when a binary file is opened ๐ By default, less refuses to open non-regular files. Heads up: some operating systems won't let directories be read even if-fis set ๐-F,--quit-if-one-screenโ Makes less auto-exit if the whole file fits on the first screen ๐ธ-g,--hilite-searchโ Normally less highlights ALL strings matching the last search command.-gchanges that so only the one particular string found by the last search gets highlighted โจ This can make less run a bit faster than the default ๐๏ธ-G,--HILITE-SEARCHโ Turns off ALL highlighting of strings found by searches ๐ซฅ-hn,--max-back-scroll=nโ Sets the max number of lines you can scroll backward ๐ If you need to scroll back more thannlines, the screen gets repainted in a forward direction instead. (If your terminal can't scroll backward,-h0is implied ๐ )-i,--ignore-caseโ Makes searches ignore case, so uppercase and lowercase count as the same ๐ค BUT this gets ignored if any uppercase letters show up in the search pattern. In other words, if your pattern has uppercase letters, that search stays case-sensitive ๐-I,--IGNORE-CASEโ Same as-i, except searches ignore case EVEN if the pattern has uppercase letters ๐ซจ-jn,--jump-target=nโ Picks the screen line where the "target" line gets placed ๐ฏ The target line is whichever line gets landed on by any command that searches for a pattern, jumps to a line number, jumps to a file percentage, or jumps to a tag. You can give the screen line as a number: the top line is1, the next is2, and so on. You can also use a negative number to count from the bottom: the bottom line is-1, second to bottom is-2, etc. Or you can use a fraction of the screen height, starting with a decimal point:.5is the middle of the screen,.3is three tenths down from the first line, and so on ๐ If you use a fraction, the actual line number gets recalculated when the terminal window is resized ๐ If the--headeroption is used and the target line from-jwould be hidden by the header, the target line gets moved to the first line after the header ๐ While--headeris active, the-Soption is ignored, and lines longer than the screen width get truncated โ๏ธ
If you use ANY form of -j, repeated forward searches (started with n or N) begin at the line right after the target line, and repeated backward searches begin at the target line itself, unless you change that with -a or -A ๐ซ For example, if you use -j4, the target line is the fourth line on the screen, so forward searches start at the fifth line on the screen. Nonrepeated searches (started with / or ?) always start at the start or end of the current screen, respectively ๐ง
-J,--status-columnโ Shows a status column on the left edge of the screen ๐ The character in that column can be one of these:>โ The line is chopped with-S, and the text chopped off past the right edge of the screen contains a match for the current search โก๏ธ<โ The line is horizontally shifted, and the text shifted past the left side of the screen contains a match for the current search โฌ ๏ธ=โ The line is both chopped and shifted, and there are matches past both sides of the screen ๐คฏ*โ There are matches in the visible part of the line, but none to the right or left of it โญa-z,A-Zโ The line has been marked with that letter using themcommand ๐๏ธ
-kfilename,--lesskey-file=filenameโ Makes less open and read the named file as alesskey(1)binary file ๐ You can use multiple-koptions. If theLESSKEYorLESSKEY_SYSTEMenvironment variable is set, or if a lesskey file is found in a standard place (see KEY BINDINGS), that gets used as a lesskey file too ๐ซถ Note the warning under "--lesskey-content" below โ ๏ธ--lesskey-src=filenameโ Makes less open and read the named file as alesskey(1)source file ๐ If theLESSKEYINorLESSKEYIN_SYSTEMenvironment variable is set, or if a lesskey source file is found in a standard place (see KEY BINDINGS), that gets used as a lesskey source file too ๐ Before version 582, you had to run the lesskey program to convert a lesskey source file into a lesskey binary file for less to use ๐ฅฑ Newer versions of less read the source file directly and ignore the binary file if the source file exists. Main character behavior ๐ Note the warning under "--lesskey-content" below โ ๏ธ--lesskey-content=textโ Makes less interpret the text you give it as the contents of alesskey(1)source file โจ In that text, lesskey lines can be separated by normal newlines, or by semicolons ๐ง To include a literal semicolon, put a backslash in front of it, like\;. Hmm, careful: the original says "a backslash followed by a semicolon", so write it as\followed by;.
Warning โ ๏ธ Certain environment variables likeLESS,LESSSECURE,LESSCHARSET, and others, which are used super early during startup, can NOT be set in a file given by a command line option (--lesskey,--lesskey-srcor--lesskey-content). If you want to use a lesskey file to set environment variables, it's safer to use the default lesskey file, or to point to the file with theLESSKEYINorLESSKEY_CONTENTenvironment variables instead of a command line option ๐ฅบ๐
Oops, I left some drafting notes in that last draft. Here is the clean version of the final lesskey-content line and the rest of the part:
--lesskey-content=textโ Makes less interpret the text you give it as the contents of alesskey(1)source file โจ In that text, lesskey lines can be separated by normal newlines, or by semicolons ๐ง To include a literal semicolon, put a backslash in front of it, so a backslash followed by a semicolon.
Warning โ ๏ธ Certain environment variables likeLESS,LESSSECURE,LESSCHARSET, and others, which get used super early during startup, can NOT be set in a file specified by a command line option (--lesskey,--lesskey-srcor--lesskey-content). If you want a lesskey file to set environment variables, it's safer to use the default lesskey file, or to specify the file with theLESSKEYINorLESSKEY_CONTENTenvironment variables instead of a command line option ๐ฅบ๐
-K,--quit-on-intrโ okay so this one makes less bail straight out with exit status2the moment you hit an interrupt character (usually^C) ๐. Normally ^C just stops whatever less is doing and sends you back to its command prompt, but with this on, that doesn't happen. Heads up bestie, using this means you can't get back to the command prompt from theFcommand ๐ญ.-L,--no-lessopenโ this tells less to ignore theLESSOPENenvironment variable ๐ (see the INPUT PREPROCESSOR section below). You can flip it on from inside less too, but it only applies to files opened after that. The file currently open stays the same.-m,--long-promptโ makes less prompt verbosely, like more(1) does, and shows the percent into the file ๐. By default less keeps it chill with a colon.-M,--LONG-PROMPTโ prompts even more verbosely than more(1). Extra dramatic, extra detail โจ.-n,--line-numbersโ suppresses line numbers ๐ซถ. Line numbers are on by default, but in some cases they can make less run more slowly, especially with a really huge input file. Turning them off with-navoids that problem. When line numbers are in use, the line number shows up in the verbose prompt and in the=command, and thevcommand passes the current line number to the editor (see also the discussion ofLESSEDITin PROMPTS below).-N,--LINE-NUMBERSโ puts a line number at the start of each line in the display ๐.-ofilename,--log-file=filenameโ makes less copy its input into the named file while you're viewing it ๐. This only works when the input is a pipe, not an ordinary file. If the file already exists, less will ask you to confirm before it overwrites it.-Ofilename,--LOG-FILE=filenameโ same vibe as-o, but this one overwrites an existing file without asking ๐ฅ.
If you haven't specified a log file yet, you can use -o and -O from inside less to pick one. If you leave out the file name, they'll just tell you the name of the log file that's already set. The s command does the same thing as -o from inside less ๐
.
-ppattern,--pattern=patternโ-pon the command line is the same as typing+/pattern. In other words, less starts at the first occurrence ofpatternin the file ๐ฆ.-Pprompt,--prompt=promptโ this is how you customise the three prompt styles to your own taste ๐. You'd usually put this in theLESSenvironment variable instead of typing it every single time. The option has to be the last one in theLESSvariable, or it has to end with a dollar sign.-Psfollowed by a string changes the default (short) prompt to that string.-Pmchanges the medium (-m) prompt.-PMchanges the long (-M) prompt.-Phchanges the prompt for the help screen.-P=changes the message printed by the=command.-Pwchanges the message printed while waiting for data (in theFcommand).
All prompt strings are made up of letters and special escape sequences. Check the PROMPTS section for the full tea โ.
-q,--quietor--silentโ moderately "quiet" mode ๐คซ. The terminal bell won't ring if you try to scroll past the end or before the beginning of the file. If the terminal has a "visual bell", that gets used instead. The bell still rings for certain other errors, like typing an invalid character. By default, the bell rings in all of these cases.-Q,--QUIETor--SILENTโ totally silent mode ๐. The terminal bell is never rung. If the terminal has a "visual bell", that's used in every case where the bell would've gone off.-r,--raw-control-charsโ shows "raw" control characters ๐. By default, control characters use caret notation, so a control-A (octal 001) shows up as "^A" (with some exceptions, as described under the-Uoption).
โ ๏ธ Warning: when you use -r, less can't keep track of what the screen actually looks like, because that depends on how the screen responds to each control character. So you can get display problems, like long lines getting split in the wrong place.
๐ซ USE OF THE -r OPTION IS NOT RECOMMENDED.
-R,--RAW-CONTROL-CHARSโ like-r, but only ANSI "color" escape sequences and OSC 8 hyperlink sequences get output in "raw" form ๐. Unlike-r, the screen appearance stays correct, as long as the file doesn't contain any escape sequences besides these types. Color escape sequences only work when the color changes within one line, not across lines. So the start of each line is assumed to be normal (non-colored), no matter what escape sequences came before it. For keeping track of the screen, these escape sequences are assumed not to move the cursor.
OSC 8 hyperlinks look like this:
ESC ] 8 ; ... \7
The ending can be either a BEL character (\7) or the two-character sequence "ESC \".
ANSI color escape sequences look like this:
ESC [ ... m
where the "..." is zero or more color specification characters. If you want less to think other characters can end an ANSI color escape sequence, set the LESSANSIENDCHARS environment variable to the list of characters that can end one. And if characters other than the standard ones can show up between the ESC and the m, set the LESSANSIMIDCHARS environment variable to the list of characters that can appear there ๐ง.
-s,--squeeze-blank-linesโ squishes consecutive blank lines down into a single blank line ๐งฝ. This is handy when you're viewing nroff output.-S,--chop-long-linesโ chops long lines (truncates them) instead of wrapping them when they're wider than the screen โ๏ธ. So the part of a long line that doesn't fit isn't shown until you press RIGHT-ARROW. Wrapping is the default, meaning the rest of the line shows up on the next line. See also the--wordwrapoption.-ttag,--tag=tagโ-tfollowed right away by a TAG opens the file that contains that tag ๐ท๏ธ. For this to work, the tag info has to exist. For example, there might be a file in the current directory called "tags" that was built earlier by ctags(1) or something equivalent. If theLESSGLOBALTAGSenvironment variable is set, it's treated as the name of a command compatible with global(1), and that command gets run to find the tag (seehttp://www.gnu.org/software/global/global.html). You can also use-tfrom inside less (with the-command) to look at a new file. The:tcommand does the same thing as-tfrom inside less.-Ttagsfile,--tag-file=tagsfileโ uses the tags file you name here instead of "tags" ๐.-u,--underline-specialโ makes backspaces and carriage returns count as printable characters ๐๏ธ. So they get sent to the terminal whenever they show up in the input.-U,--UNDERLINE-SPECIALโ makes backspaces, tabs, carriage returns and "formatting characters" (as defined by Unicode) count as control characters ๐ญ. That means they're handled the way the-roption says.
By default, if you give neither -u nor -U, things get handled with a bit of finesse. A backspace right next to an underscore is treated specially: the underlined text shows up using the terminal's hardware underlining. A backspace between two identical characters is also special: the overstruck text gets printed using the terminal's hardware boldface. Any other backspaces get deleted, along with the character before them. A carriage return immediately followed by a newline is deleted. Other carriage returns get handled the way the -r option says. Unicode formatting characters, like the Byte Order Mark, are sent to the terminal. Overstruck or underlined text can be searched, as long as neither -u nor -U is in effect.
See also the --proc-backspace, --proc-tab, and --proc-return options.
-V,--versionโ shows the version number of less ๐ข.-w,--hilite-unreadโ briefly highlights the first "new" line after a full page of forward movement ๐ก. The first "new" line is the one right after the line that used to be at the bottom of the screen. It also highlights the target line after agorpcommand. The highlight disappears at the next command that causes movement. If the--status-lineoption is in effect, the whole line (the full width of the screen) gets highlighted. Otherwise, only the text on the line is highlighted, unless the-Joption is in effect, in which case only the status column is highlighted.-W,--HILITE-UNREADโ like-w, but it highlights the first new line after any forward movement command that's bigger than one line ๐.-xn,...,--tabs=n,...โ sets tab stops ๐. If you specify only onen, tab stops land on multiples ofn. If you give several values separated by commas, the tab stops go at those positions, and then continue with the same spacing as the last two. For example,-x9,17sets tabs at positions 9, 17, 25, 33, and so on. The default fornis 8.-X,--no-initโ stops less from sending the termcap initialization and deinitialization strings to the terminal ๐ . This is sometimes what you want if the deinitialization string does something unnecessary, like clearing the screen.-yn,--max-forw-scroll=nโ okay so this one caps how far forward you can scroll before less just repaints the whole screen instead ๐ If you need to go forward more than n lines, it repaints, and-cor-Ccan repaint from the top if you want that. By default, any forward movement just scrolls โจ-zn,--window=n,-nโ this changes the default scrolling window size to n lines ๐ฆ The default is one full screenful. Thezandwcommands can change the window size too, and thezcan be left off for compatibility with some versions of more(1) ๐ธ If n is negative, it means n lines less than the current screen size. For example, on a 24-line screen,-z-4gives you a 20-line window. If the screen gets resized to 40 lines, the window automatically becomes 36 lines. The math is giving โจ-"cc,--quotes=ccโ this changes the filename quoting character ๐ It might be necessary if you're trying to name a file with both spaces and quote characters, which is a whole mood ๐ With one character, that character becomes the quote character, and filenames with a space should be wrapped in it instead of double quotes. With two characters, the first becomes the open quote and the second becomes the close quote. Filenames with a space should then be preceded by the open quote and followed by the close quote. Heads up: even after you change the quote characters, this option is still-"(a dash followed by a double quote) ๐ซถ-~,--tildeโ normally, lines after the end of the file show up as a single tilde (~) ๐ With this option, those lines show up as blank lines instead ๐ค-#,--shiftโ this sets the default number of positions to scroll horizontally with the RIGHTARROW and LEFTARROW commands โก๏ธ If you set it to zero, the default becomes one half of the screen width. You can also type it as a fraction of the screen width, starting with a decimal point:.5is half the screen width,.3is three tenths, and so on ๐ If you use a fraction, the actual number of scroll positions gets recalculated if the terminal window is resized ๐ง--exit-follow-on-closeโ when you're using the "F" command on a pipe, less will automatically stop waiting for more data once the input side of the pipe is closed ๐--file-sizeโ if you pass--file-size, less figures out the size of the file right after opening it ๐ Then the "=" command can show you the number of lines in the file ๐ Normally this doesn't happen, because it can be super slow if the input is non-seekable (like a pipe) and it's big ๐ญ--follow-nameโ okay so normally, if the input file gets renamed while an F command is running, less keeps showing the contents of the original file even after the name change ๐ With--follow-name, during an F command less will periodically try to reopen the file by name. If the reopen works and the file is different from the original (meaning a new file was created with the same name as the original, now renamed, file), less shows the contents of that new file instead ๐ฅ--header=L,C,Nโ this sets how many header lines and columns show up on the screen ๐ The number of header lines is L. If L is0, header lines are turned off. If L is empty or missing, the number of header lines stays the same. The number of header columns is C. If C is0, header columns are turned off. If C is empty or missing, the number of header columns stays the same. The first header line is line number N in the file. If N is empty or missing, it's taken to be the number of the line currently showing in the first line of the screen (if you typed the--headercommand from inside less), or1(if the--headeroption was given on the command line). The special form--header=-turns off header lines and header columns, and it's the same as--header=0,0๐
When L is nonzero, the first L lines at the top of the screen get replaced with the L lines of the file starting at line N, no matter which part of the file you're looking at ๐ When header lines are showing, any file contents before the header line can't be viewed ๐ When C is nonzero, the first C characters at the start of each line get replaced with the first C characters of the line, even if the rest of the line is scrolled sideways โจ
--incsearchโ subsequent search commands become "incremental" ๐ That means less jumps to the next line containing the search pattern as you type each character of the pattern ๐ฆ--intr=cโ uses the character c instead of^Xto interrupt a read when the "Waiting for data" message is showing ๐ c has to be an ASCII character, one with a value between 1 and 127 inclusive. A caret followed by a single character can be used to write a control character ๐ง--line-num-width=nโ sets the minimum width of the line number field to n characters when the-Noption is in effect ๐ข The default is 7 ๐--match-shift=nโ when-Sis in effect, if a search match isn't visible because it's shifted off to the left or right of the screen, the text shifts horizontally so the match becomes visible ๐ธ This option picks the column where the first character of the match lands after the shift. In other words, there will be n characters visible to the left of the match ๐ซถ
You can also type this as a fraction of the screen width, starting with a decimal point: .5 is half the screen width, .3 is three tenths, and so on. If you use a fraction, the actual number of scroll positions gets recalculated if the terminal window is resized ๐
--modelines=nโ before displaying a file, less reads the first n lines to look for a vim-compatible modeline ๐ท If n is zero, less doesn't look for modelines at all. With a modeline, the file itself can say which tab stops to use when you view it ๐
A modeline has, anywhere in the line, a program name (vi, vim, ex, or less), followed by a colon, possibly followed by the word set, and finally followed by zero or more option settings. If the word set is used, option settings are separated by spaces and end at the first colon. If the word set isn't used, option settings can be separated by either spaces or colons. The word set is required if the program name is less, but it's optional if any of the other three names are used. If any option setting has the form tabstop=n or ts=n, then tab stops are set automatically, just as if --tabs=n had been given. Check the --tabs description for the acceptable values of n ๐
--mouseโ enables mouse input ๐ฑ๏ธ Scrolling the mouse wheel down moves forward in the file, scrolling it up moves backward, a left-click sets the "#" mark to the line you clicked, and a right-click (or any other click) returns you to the "#" mark position ๐ฆ If you left-click while the mouse cursor is on an OSC 8 hyperlink, that hyperlink gets selected as if you'd used the^O^Ncommand ๐ If you left-click on an OSC 8 hyperlink that's already selected, it gets opened as if you'd used the^O^Ocommand ๐ The number of lines to scroll when the wheel moves can be set with the--wheel-linesoption. Mouse input only works on terminals that support X11 mouse reporting, and on the Windows version of less ๐ซถ--MOUSEโ same as--mouse, except the direction you scroll with the mouse wheel is reversed ๐--no-keypadโ stops less from sending the keypad initialization and deinitialization strings to the terminal โจ๏ธ This is sometimes handy if those keypad strings make the numeric keypad act weird ๐--no-histdupsโ this changes things so that if you type in a search string or file name that's already in the history list, the old copy gets removed from the history list before the new one is added ๐ That way, a given string only shows up once in the history list. Normally, a string can show up multiple times ๐--no-number-headersโ header lines (set up with the--headeroption) don't get line numbers ๐ข Line number 1 goes to the first line after any header lines ๐ธ--no-search-header-linesโ searches skip header lines, but still include header columns ๐--no-search-header-columnsโ searches skip header columns, but still include header lines ๐--no-search-headersโ searches skip both header lines and header columns ๐--no-vbellโ disables the terminal's visual bell ๐--proc-backspaceโ if set, backspaces get handled as if neither the-uoption nor the-Uoption were set ๐ง That means a backspace next to an underscore makes the text show up in underline mode, and a backspace between identical characters makes the text show up in boldface mode ๐ This option overrides-uand-U, so the display of backspaces can be controlled separately from tabs and carriage returns โจ If it's not set, backspace display is controlled by the-uand-Uoptions ๐--PROC-BACKSPACEโ if set, backspaces get handled as if the-Uoption were set, which means backspaces get treated as control characters ๐จ
Okay so, the options keep going, bestie ๐ โจ
--proc-return๐ โ If this is set, carriage returns get treated like neither-unor-Uwas set, so a carriage return right before a newline just vanishes ๐ซถ. This one overrides-uand-U, which means you can control carriage return display separately from backspaces and tabs ๐. If it's not set, the-uand-Uoptions are in charge of carriage returns.--PROC-RETURN๐ฅ โ If this is set, carriage returns act like-Uwas set. Basically they become control characters, no cap ๐.--proc-tab๐ฆ โ If this is set, tabs get treated like-Uwas not set, which means they're expanded into spaces โจ. This overrides-U, so tab display can be handled separately from backspaces and carriage returns ๐. If it's not set, tab display is controlled by the-Uoptions.--PROC-TAB๐ธ โ If this is set, tabs act like-Uwas set, so they're treated as control characters. Iconic behavior ๐.--redraw-on-quit๐ง โ When you quit, after the terminal deinitialization string gets sent, it redraws the entire last screen. This is lowkey essential for terminals whose deinit string switches away from an alternate screen ๐ญ, because it keeps the last screenful of the current file visible afterlessquits. Main character moment ๐.--rscroll=c๐ โ This changes the character used to mark truncated lines. It can start with a two-character attribute indicator, just likeLESSBINFMTdoes ๐ . If there's no attribute indicator, standout gets used. If you set it to"-", truncated lines won't be marked at all ๐.--save-marks๐ โ Marks get saved in the history file, so they stick around across different invocations oflessโจ. Literally so useful ๐ซถ.--search-options=...๐ฅ โ This sets default search modifiers ๐. The value is a string with one or more of the charactersE,F,K,N,RorW. Setting any of these is the same as typing that control character at the beginning of every search pattern ๐ . For example,--search-options=Wis the same as typing^Wat the start of every pattern. The value can also include a digit from1to5, which works the same as typing^Sfollowed by that digit at the start of every search pattern ๐ฆ. The value"-"disables all default search modifiers ๐.--show-preproc-errors๐ง โ If a preprocessor produces data but then exits with a non-zero exit code,lesswill show a warning ๐ฌ.--status-col-width=n๐ธ โ This sets the width of the status column when the-Joption is in effect ๐. The default is2characters.--status-lineโจ โ If a line is marked, the entire line gets highlighted instead of just the status column ๐. Lines highlighted because of the-woption will also have the entire line highlighted ๐ฅ. If--use-coloris set, the line is colored instead of highlighted ๐.--use-backslash๐ โ This changes how the options after it get interpreted ๐. After--use-backslash, any backslash in an option string gets removed, and the character right after it is taken literally ๐ . That's how you get a dollar sign into option strings, periodt ๐.--use-color๐ โ This enables colored text in various places โจ. You can use the-Doption to change the colors ๐. Heads up though: colored text only works if your terminal supports ANSI color escape sequences (as defined inhttps://www.ecma-international.org/publications-and-standards/standards/ecma-48) ๐ญ.--wheel-lines=n๐ฆ โ This sets how many lines to scroll when the mouse wheel moves, but only when the--mouseor--MOUSEoption is in effect ๐ซถ. The default is1line.--wordwrap๐ โ When the-Soption isn't in use, each line wraps at a space or tab whenever possible, so a word doesn't get split between two lines โจ. The default is to wrap at any character, which is lowkey messy ๐.--๐ง โ A command line argument of--marks the end of the option arguments ๐. Anything after it gets interpreted as a filename ๐ . This is super handy when you want to view a file whose name starts with a-or+๐.+๐ โ If a command line option begins with+, the rest of that option is treated as an initial command forless๐. For example,+Gtellslessto start at the end of the file instead of the beginning, and+/xyztells it to start at the first occurrence of"xyz"in the file ๐ฅ. As a special case,+<number>acts like+<number>g, meaning it starts the display at that line number (but check the caveat under thegcommand above ๐). If the option starts with++, the initial command applies to every file being viewed, not just the first one ๐. The+command described above can also be used to set or change an initial command for every file ๐.
โจ LINE EDITING โจ
When you're typing a command line at the bottom of the screen (like a filename for the :e command, or the pattern for a search ๐), you can use certain keys to manipulate that command line ๐
. Most commands have an alternate form in [ brackets ] that you can use if a key doesn't exist on your keyboard ๐ซถ. (Heads up: the forms beginning with ESC don't work on some MS-DOS and Windows systems, because ESC is the line erase character there ๐ญ.) Any of these special keys can be entered literally by putting the "literal" character in front of it, which is either ^V or ^A ๐. A backslash can also be entered literally by typing two backslashes ๐ฆ.
LEFTARROW[ ESC-h ]๐ธ โ Moves the cursor one space to the left.RIGHTARROW[ ESC-l ]๐ธ โ Moves the cursor one space to the right.^LEFTARROW[ ESC-b or ESC-LEFTARROW ]โจ โ (That is, CONTROL and LEFTARROW at the same time ๐.) Moves the cursor one word to the left.^RIGHTARROW[ ESC-w or ESC-RIGHTARROW ]โจ โ (That is, CONTROL and RIGHTARROW at the same time ๐.) Moves the cursor one word to the right.HOME[ ESC-0 ]๐ โ Moves the cursor to the beginning of the line ๐ง.END[ ESC-$ ]๐ โ Moves the cursor to the end of the line ๐.BACKSPACE๐๏ธ โ Deletes the character to the left of the cursor, or cancels the command if the command line is empty ๐.DELETEor[ ESC-x ]๐ โ Deletes the character under the cursor.^BACKSPACE[ ESC-BACKSPACE ]๐ฅ โ (That is, CONTROL and BACKSPACE at the same time.) Deletes the word to the left of the cursor ๐ซถ.^DELETE[ ESC-X or ESC-DELETE ]๐ฅ โ (That is, CONTROL and DELETE at the same time.) Deletes the word under the cursor ๐ญ.UPARROW[ ESC-k ]๐ โ Retrieves the previous command line โฌ๏ธ. If you type some text first and then pressUPARROW, it'll retrieve the previous command that begins with that text โจ.DOWNARROW[ ESC-j ]๐ โ Retrieves the next command line โฌ๏ธ. If you type some text first and then pressDOWNARROW, it'll retrieve the next command that begins with that text ๐.TAB๐ โ Completes the partial filename to the left of the cursor ๐ฆ. If it matches more than one filename, the first match goes into the command line ๐ธ. PressingTABagain cycles through the other matching filenames ๐. If the completed filename is a directory, a"/"gets appended to it (on MS-DOS and Windows systems, a"\"gets appended instead) ๐. The environment variableLESSSEPARATORcan be used to specify a different character to append to a directory name ๐ง.BACKTAB[ ESC-TAB ]๐ โ LikeTAB, but it cycles through the matching filenames in the reverse direction ๐.^L๐ฆ โ Completes the partial filename to the left of the cursor ๐ . If it matches more than one filename, all of the matches go into the command line (if they fit) ๐.^U(Unix and OS/2) orESC(MS-DOS and Windows) ๐งน โ Deletes the entire command line, or cancels the command if the command line is empty ๐. If you've changed your line-kill character in Unix to something other than^U, that character gets used instead of^U๐ซถ.^G๐ โ Deletes the entire command line and returns you to the main prompt ๐ .
โจ KEY BINDINGS โจ
You can define your own less commands by creating a lesskey source file ๐. This file specifies a set of command keys and an action for each key ๐. You can also change the line-editing keys (see LINE EDITING) and set environment variables used by less ๐. Check out the lesskey(1) manual page for details about the file format ๐.
If the environment variable LESSKEYIN is set, less uses that as the name of the lesskey source file ๐ง. Otherwise, less looks in a standard place for it. On Unix systems, less looks for a lesskey file called "$XDG_CONFIG_HOME/lesskey" or "$HOME/.config/lesskey" or "$HOME/.lesskey" ๐ง. On MS-DOS and Windows systems, less looks for a lesskey file called "$HOME/_lesskey", and if it's not found there, it looks for a lesskey file called "_lesskey" in any directory specified in the PATH environment variable ๐ช. On OS/2 systems, less looks for a lesskey file called "$HOME/lesskey.ini", and if it's not found, it looks for a lesskey file called "lesskey.ini" in any directory specified in the INIT environment variable. If it's not found there either, it looks for a lesskey file called "lesskey.ini" in any directory specified in the PATH environment variable ๐.
A system-wide lesskey source file can also be set up to provide key bindings ๐. If a key is defined in both a local lesskey file and the system-wide file, the bindings in the local file take precedence over the system-wide ones ๐. If the environment variable LESSKEYIN_SYSTEM is set, less uses that as the name of the system-wide lesskey file ๐
. Otherwise, less looks in a standard place for it. On Unix systems, the system-wide lesskey file is /usr/local/etc/syslesskey. (However, if less was built with a different sysconf directory than /usr/local/etc, that directory is where the syslesskey file gets found ๐๏ธ.) On MS-DOS and Windows systems, the system-wide lesskey file is c:\_syslesskey ๐ช. On OS/2 systems, the system-wide lesskey file is c:\syslesskey.ini ๐.
Heads up, bestie โ ๏ธ: previous versions ofless(before v582) used lesskey files with a binary format, produced by thelesskeyprogram. It's no longer necessary to use thelesskeyprogram ๐.
โจ INPUT PREPROCESSOR โจ
okay so you can set up an "input preprocessor" for less ๐ Before less opens a file, it gives your input preprocessor a chance to change how the file's contents get displayed ๐ฆ The preprocessor is just an executable program (or shell script) that writes the contents of the file into a different file, called the replacement file ๐ธ less then shows the replacement file's contents instead of the original's. BUT (this is the iconic part) it still looks like you opened the original file, because less shows the original filename as the name of the current file ๐
An input preprocessor gets one command line argument, the original filename exactly as you typed it ๐ It should create the replacement file and, once it's done, print the replacement file's name to its standard output โจ If the preprocessor doesn't output a replacement filename, less just uses the original file like normal ๐ The input preprocessor is never called when you're viewing standard input ๐
โโ๏ธ To set one up, set the LESSOPEN environment variable to a command line that runs your preprocessor ๐ซถ That command line needs exactly one occurrence of the string "%s", which gets swapped out for the filename when the preprocessor runs.
When less closes a file opened this way, it calls another program, the input postprocessor ๐งน This is the clean-up crew, so it can do whatever tidying you want (like deleting the replacement file that LESSOPEN made) ๐ It gets two command line arguments: the original filename as you typed it, and the replacement file's name. To set one up, set the LESSCLOSE environment variable to a command line that runs your postprocessor ๐ It can include two occurrences of "%s". The first one gets replaced with the original filename, and the second gets replaced with the replacement filename that LESSOPEN output.
For example, on lots of Unix systems, these two scripts let you keep files compressed but still view them straight in less ๐
lessopen.sh:
#! /bin/sh
case "$1" in
*.Z) TEMPFILE=$(mktemp)
uncompress -c $1 >$TEMPFILE 2>/dev/null
if [ -s $TEMPFILE ]; then
echo $TEMPFILE
else
rm -f $TEMPFILE
fi
;;
esac
lessclose.sh:
#! /bin/sh
rm $2
To use them, put both scripts somewhere they can be executed, then set LESSOPEN="lessopen.sh %s" and LESSCLOSE="lessclose.sh %s %s" ๐ง Fancier LESSOPEN and LESSCLOSE scripts can be written to handle other types of compressed files, and so on, the sky's the limit ๐
It's also possible to set up an input preprocessor that pipes the file data straight into less, instead of dumping it into a replacement file ๐ This means you don't have to decompress the whole file before you can start reading it, which is so efficient it's giving ๐ญ A preprocessor that works this way is called an input pipe. Instead of writing a replacement filename to its standard output, an input pipe writes the entire contents of the replacement to its standard output. If the input pipe doesn't write any characters to its standard output, there's no replacement and less uses the original file, as normal ๐ซ To use an input pipe, make the very first character of the LESSOPEN environment variable a vertical bar (|) so less knows it's a pipe ๐ซ Same as before, the command string must contain one occurrence of %s, which gets replaced with the input file's filename.
For example, on lots of Unix systems, this script does the same job as the previous example scripts ๐
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*) exit 1
;;
esac
exit $?
To use it, put the script where it can be executed and set LESSOPEN="|lesspipe.sh %s" ๐
โ ๏ธ Heads up, bestie: a preprocessor can't output an empty file, because less reads that as "no replacement" and quietly uses the original file ๐ค To get around this, ifLESSOPENstarts with two vertical bars (||), the script's exit status decides what happens when the output is empty ๐ซถ If the output is empty and the exit status is zero, the empty output counts as the replacement text โ If the output is empty and the exit status is nonzero, the original file gets used โ For compatibility with older versions of less, ifLESSOPENstarts with only one vertical bar, the preprocessor's exit status gets ignored ๐
When you're using an input pipe, a LESSCLOSE postprocessor can be used, but it's usually not necessary since there's no replacement file to clean up ๐งผ In that case, the replacement filename passed to the LESSCLOSE postprocessor is "-".
For compatibility with older versions of less, the input preprocessor or pipe is not used when less is viewing standard input ๐
โโ๏ธ BUT, if the first character of LESSOPEN is a dash (-), the input preprocessor gets used on standard input too, as well as on other files ๐ In this case the dash isn't counted as part of the preprocessor command ๐
When standard input is being viewed, the preprocessor gets passed a filename that's just a single dash. Similarly, if the first two characters of LESSOPEN are a vertical bar and a dash (|-), or two vertical bars and a dash (||-), the input pipe gets used on standard input as well as other files ๐ธ Again, the dash isn't considered part of the input pipe command ๐ฆ
๐ธ NATIONAL CHARACTER SETS ๐ธ
okay so there are three kinds of characters floating around in your input file ๐ฆ
- normal characters โ these can be shown straight on the screen, no drama ๐
- control characters โ you shouldn't display these directly, but they're totally expected to show up in regular text files (think backspace and tab) ๐ซถ
- binary characters โ not displayable, and they're not supposed to be hanging out in text files at all ๐
a "character set" is basically just a cheat sheet that says which characters count as normal, control, or binary โจ you pick one with the LESSCHARSET environment variable. here are the possible values, bestie ๐
asciiโ BS, TAB, NL, CR, and formfeed are control characters, anything with a value from 32 to 126 is normal, and everything else is binary ๐iso8859โ an ISO 8859 character set. it's the same as ASCII, except characters from 160 to 255 get treated as normal ๐latin1โ same asiso8859๐latin9โ same asiso8859๐dosโ a character set made for MS-DOS ๐พebcdicโ an EBCDIC character set ๐งIBM-1047โ an EBCDIC character set used by OS/390 Unix Services. it's the EBCDIC cousin oflatin1, so you get similar results by setting eitherLESSCHARSET=IBM-1047orLC_CTYPE=en_USin your environment ๐ฅkoi8-rโ a Russian character set ๐ธnextโ a character set made for NeXT computers ๐utf-8โ the UTF-8 encoding of the ISO 10646 character set. this one is special because it supports multi-byte characters in the input file, and it's the only character set that does โจwindowsโ a character set made for Microsoft Windows (cp 1252) ๐ฆ
in rare cases you might want less to use a character set that isn't in the LESSCHARSET list, and that's where LESSCHARDEF comes in ๐ซถ it should be set to a string where each character represents one character in the set. "." means normal, "c" means control, and "b" means binary, and a decimal number can be used for repetition. so "bccc4b." would mean character 0 is binary, 1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal. everything after the last one is treated the same as the last one, so characters 9 through 255 would be normal. (that's just an example, and it doesn't necessarily match any real character set ๐)
here's the LESSCHARDEF value that's equivalent to each of the LESSCHARSET values, no cap:
ascii 8bcccbcc18b95.b
dos 8bcccbcc12bc5b95.b.
ebcdic 5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b
9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
IBM-1047 4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc
191.b
iso8859 8bcccbcc18b95.33b.
koi8-r 8bcccbcc18b95.b128.
latin1 8bcccbcc18b95.33b.
next 8bcccbcc18b95.bb125.bb
okay so, the default-picking situation ๐
if neither LESSCHARSET nor LESSCHARDEF is set, but any of the strings "UTF-8", "UTF8", "utf-8" or "utf8" shows up in the LC_ALL, LC_CTYPE or LANG environment variables, then the default character set is utf-8 ๐
if that string isn't there, but your system supports the setlocale interface, less will ask setlocale what character set to use ๐ง setlocale is controlled by the LANG or LC_CTYPE environment variables.
and if the setlocale interface isn't available either? the default character set is utf-8 โจ no matter what, you're getting utf-8 as the fallback, periodt ๐
control and binary characters get shown in standout (reverse video) ๐ฅ each one shows up in caret notation if possible, so like ^A for control-A. caret notation is only used if inverting the 0100 bit gives you a normal printable character. otherwise, the character gets displayed as a hex number in angle brackets ๐
you can change this format with the LESSBINFMT environment variable ๐ it can begin with a "*" and one character to pick the display attribute:
"*k"โ blinking"*d"โ bold"*u"โ underlined"*s"โ standout"*n"โ normal
if LESSBINFMT doesn't begin with a "*", the normal attribute is assumed. the rest of LESSBINFMT is a string that can include one printf-style escape sequence (a % followed by x, X, o, d, etc.) ๐ฆ for example, if LESSBINFMT is "*u[%x]", binary characters show up as underlined hexadecimal surrounded by brackets ๐ซถ the default if you don't specify LESSBINFMT is "*s<%02X>".
โ ๏ธ heads up bestie: the result of expanding the character via LESSBINFMT must be less than 31 characters. go over that and it's not gonna be happy ๐
when the character set is utf-8, the LESSUTFBINFMT environment variable acts like LESSBINFMT but it applies to Unicode code points that were successfully decoded and are still unsuitable for display (like unassigned code points) ๐ธ its default value is "<U+%04lX>". quick heads up that LESSUTFBINFMT and LESSBINFMT share their display attribute setting ("*x"), so setting one will affect both ๐ LESSUTFBINFMT gets read after LESSBINFMT, so its setting, if it has one, wins the priority fight ๐
problematic octets in a UTF-8 file get displayed individually using LESSBINFMT, so it's easier to figure out how the UTF-8 file is broken ๐ง those are: octets of a truncated sequence, octets of a complete but non-shortest form sequence, invalid octets, and stray trailing octets ๐ญ
when the character set is utf-8, sometimes (rarely!) you might want to override Unicode's idea of what type a certain character is ๐ฆ for example, characters in a Private Use Area are normally treated as control characters. but if you're using a custom font with printable characters in that range, you might want less to treat them as printable ๐ you do that by setting the LESSUTFCHARDEF environment variable to a comma-separated list of character type definitions โจ
each character type definition is either one hexadecimal codepoint or a pair of codepoints separated by a dash, followed by a colon and a type character ๐ each hex codepoint can optionally start with a "U" or "U+". if you give a pair, the type gets set for every character inclusively between the two values. if there are multiple comma-separated codepoint values, they have to be in ascending numerical order ๐ the type character can be one of:
pโ a normal printable character ๐wโ a wide (2-space) printable character ๐ธbโ a binary (non-printable) character ๐cโ a composing (zero width) character ๐ง
for example, setting LESSUTFCHARDEF to this:
E000-F8FF:p,F0000-FFFFD:p,100000-10FFFD:p
would make all Private Use Area characters be treated as printable ๐ซถโจ
โจ PROMPTS โจ
okay so the -P option lets you totally customize your prompt, bestie ๐
whatever string you give -P replaces the default prompt string. Some characters in there get interpreted in special ways. The prompt system is kinda complicated because it's built for maximum flexibility, but you don't need to understand all of it to make a cute prompt ๐
A percent sign followed by a single character gets expanded based on that character. (Anywhere you see input file size below, it means the preprocessed size if you're using an input preprocessor ๐ง)
%bXโ Gets replaced with the byte offset into the current input file ๐ฆ Thebis followed by one character (theXabove) that picks which line's offset you want.tmeans the top line on the display,mmeans the middle line,bmeans the bottom line,Bmeans the line right after the bottom line, andjmeans the "target" line set by the-joption.%Bโ Gets replaced with the size of the current input file.%cโ Gets replaced with the column number of the text in the first column of the screen.%dXโ Gets replaced with the page number of a line in the input file. Which line is used depends on theX, same as%b๐%Dโ Gets replaced with the number of pages in the input file. Or, equivalently, the page number of the last line in the input file.%Eโ Gets replaced with the name of your editor. It comes from theVISUALenvironment variable, or theEDITORenvironment variable ifVISUALisn't defined. Check out the LESSEDIT discussion below ๐%fโ Gets replaced with the name of the current input file.%Fโ Gets replaced with the last part of the current input file's name.%gโ Gets replaced with the shell-escaped name of the current input file. This is super useful when the expanded string is going into a shell command, like in LESSEDIT ๐%iโ Gets replaced with the index of the current file in the list of input files.%lXโ Gets replaced with the line number of a line in the input file. Again,Xpicks the line, same as%b๐ธ%Lโ Gets replaced with the line number of the last line in the input file.%mโ Gets replaced with the total number of input files.%oโ Gets replaced with the URI of the currently selected OSC 8 hyperlink. If no hyperlink is selected, you get a question mark instead. OSC 8 handlers use this, as explained in the^O^Ocommand description ๐%pXโ Gets replaced with the percent into the current input file, based on byte offsets. The line is picked byX, same as%b.%PXโ Gets replaced with the percent into the current input file, based on line numbers. The line is picked byX, same as%b.%sโ Exactly the same as%B๐%tโ Removes any trailing spaces. It's usually placed at the end of the string, but it can go anywhere ๐งน%Tโ Normally expands to the word "file". But if you're viewing files through a tags list with the-toption, it expands to the word "tag" ๐ท๏ธ%xโ Gets replaced with the name of the next input file in the list.
If something is unknown (like the file size when your input is a pipe), a question mark gets printed instead ๐
The prompt string can also change depending on certain conditions, and this is the bit that makes it feel so smart โจ A question mark followed by one character acts like an "IF". Depending on the character after the question mark, a condition gets checked. If it's true, everything after the question mark and condition character, up until a period, gets included in the prompt. If it's false, all of that gets skipped ๐ฆ A colon between the question mark and the period works like an "ELSE": anything between the colon and the period only shows up if the IF condition is false. The condition characters (the ones right after a question mark) can be:
?aโ True if anything has been added to the prompt so far.?bXโ True if the byte offset of the specified line is known.?Bโ True if the size of the current input file is known.?cโ True if the text is shifted horizontally (%cisn't zero).?dXโ True if the page number of the specified line is known.?eโ True if you're at end-of-file.?fโ True if there's an input filename (aka, your input isn't a pipe).?lXโ True if the line number of the specified line is known.?Lโ True if the line number of the last line in the file is known.?mโ True if there's more than one input file.?nโ True if this is the first prompt in a new input file.?pXโ True if the percent into the current input file, based on byte offsets, for the specified line is known.?PXโ True if the percent into the current input file, based on line numbers, for the specified line is known.?sโ Exactly the same as?B.?xโ True if there's a next input file (aka, the current file isn't the last one).
Any character that isn't special (question mark, colon, period, percent, or backslash) just shows up in the prompt as-is. If you want one of the special characters to show up literally, put a backslash in front of it ๐ซถ
Some examples, because examples are everything:
?f%f:Standard input.
This prompt prints the filename if it's known. Otherwise it prints the string "Standard input".
?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-...
This prompt prints the filename if it's known. After that it prints the line number if it's known. If the line number isn't known, it prints the percent if that's known. If that isn't known either, it prints the byte offset if known. If none of those work, a dash gets printed. Notice how every question mark has a matching period, and how the % after %pt is included literally because it's escaped with a backslash ๐ญ
?n?f%f .?m(%T %i of %m) ..?e(END) ?x- Next\: %x..%t
This prints the filename if it's the first prompt in a file, followed by the "file N of N" message if there's more than one input file. Then, if you're at end-of-file, it prints "(END)" followed by the name of the next file, if there is one. Last of all, any trailing spaces get trimmed. This is the default prompt ๐ For reference, here are the defaults for the other two prompts (-m and -M respectively). I've split each one into two lines here just so they're easier to read:
?n?f%f .?m(%T %i of %m) ..?e(END) ?x- Next\: %x.:
?pB%pB\%:byte %bB?s/%s...%t
?f%f .?n?m(%T %i of %m) ..?ltlines %lt-%lb?L/%L. :
byte %bB?s/%s. .?e(END) ?x- Next\: %x.:?pB%pB\%..%t
And here's the default message the = command produces:
?f%f .?m(%T %i of %m) .?ltlines %lt-%lb?L/%L. .
byte %bB?s/%s. ?e(END) :?pB%pB\%..%t
The prompt expansion stuff gets used for something else too ๐ง If an environment variable called LESSEDIT is defined, it's the command that runs when you use the v command. The LESSEDIT string gets expanded the same way the prompt strings do. The default value for LESSEDIT is:
%E ?lm+%lm. %g
So this expands to the editor name, then a +, then the line number, then the shell-escaped file name. If your editor doesn't accept the "+linenumber" syntax, or if it has other differences in how it's invoked, you can change the LESSEDIT variable to tweak this default ๐
๐ SECURITY ๐
When the environment variable LESSSECURE is set to 1, less goes into a "secure" mode ๐ก๏ธ In this mode, these features get turned off:
editโ the edit command (v)examineโ the examine command (:e)globโ metacharacters like*in filenames, and filename completion (TAB,^L)historyโ the history filelesskeyโ using lesskey files (-kand--lesskey-src)lessopenโ the input preprocessor (LESSOPENenvironment variable)logfileโ log files (sand-o)osc8โ opening OSC 8 links (^O^O)pipeโ the pipe command (|)shellโ the shell and pshell commands (!and#)stopโ stopping less with aSIGSTOPsignaltagsโ using tags files (-t)
The LESSSECURE_ALLOW environment variable can be set to a comma-separated list of feature names that get selectively turned back on when LESSSECURE is set ๐ Each feature name is the first word of each line in the list above. You can shorten a feature name as long as the shortened version is unambiguous. For example, if LESSSECURE=1 and LESSSECURE_ALLOW=hist,edit were set, every feature above would stay disabled except for history files and the edit command ๐
Heads up: less can also be compiled to be permanently in "secure" mode. In that case, theLESSSECUREandLESSSECURE_ALLOWvariables get ignored, so no sneaking around it ๐ โโ๏ธ
๐ฆ COMPATIBILITY WITH MORE ๐ฆ
If the environment variable LESS_IS_MORE is set to 1, or if the program gets invoked through a file link named "more", less behaves (mostly) like the POSIX more(1) command spec ๐ In this mode, less acts differently in these ways:
The -e option works differently. If -e isn't set, less acts like -e is set. If -e is set, less acts like -E is set ๐
The -m option works differently. If -m isn't set, the medium prompt is used, and it gets prefixed with the string "--More--". If -m is set, the short prompt is used โจ
The -n option acts like the -z option. The normal behavior of -n isn't available in this mode ๐
The parameter to the -p option is treated as a less command rather than a search pattern ๐
The LESS environment variable gets ignored, and the MORE environment variable gets used in its place ๐
โจ ENVIRONMENT VARIABLES โจ
okay so environment variables can be set the normal way in the system environment, OR in a lesskey(1) file ๐๏ธ if there's a clash, the local lesskey file wins, then the system environment, then the system-wide lesskey file. the hierarchy is literally giving ๐
COLUMNSโ sets how many columns the screen has. It beats the number of columns fromTERM. (But if you've got a windowing system that supportsTIOCGWINSZorWIOCGETD, the window system's idea of the screen size wins overLINESandCOLUMNSenv vars ๐ช)EDITORโ the editor you want for thevcommand โ๏ธHOMEโ your home directory. less uses it to find a lesskey file on Unix and OS/2 systems ๐HOMEDRIVE,HOMEPATHโ ifHOMEisn't set, these two get smooshed together into your home directory. This is only in the Windows version ๐ชINITโ your init directory, used to find a lesskey file on OS/2 systems ๐LANGโ the language, used for figuring out the character set ๐LC_CTYPEโ also the language, used for figuring out the character set ๐LESSโ options that get passed to less automatically ๐LESSANSIENDCHARSโ the characters that can end an ANSI color escape sequence (default"m") ๐LESSANSIMIDCHARSโ the characters that can show up between the ESC character and the end character in an ANSI color escape sequence (default"0123456789:;[?!"'#%()*+ ") ๐ขLESSBINFMTโ the format used to display non-printable, non-control characters ๐LESSCHARDEFโ defines a character set ๐คLESSCHARSETโ picks a predefined character set ๐LESSCLOSEโ the command line that invokes the (optional) input-postprocessor ๐งนLESSECHOโ the name of the lessecho program (default"lessecho"). lessecho is needed to expand metacharacters, like*and?, in filenames on Unix systems ๐LESSEDITโ the editor prototype string (used for thevcommand). See the discussion under PROMPTS ๐LESSGLOBALTAGSโ the name of the command the-toption uses to find global tags. Normally you'd set this to"global"if your system has the global(1) command. If it's not set, global tags just aren't used ๐ท๏ธLESSHISTFILEโ the name of the history file that remembers search commands and shell commands between less sessions. If it's set to"-"or"/dev/null", no history file gets used ๐๏ธ The default depends on your OS, but is usually:- Linux and Unix:
"$XDG_STATE_HOME/lesshst"or"$HOME/.local/state/lesshst"or"$XDG_DATA_HOME/lesshst"or"$HOME/.lesshst"๐ง - Windows and MS-DOS:
"$HOME/_lesshst"๐ช - OS/2:
"$HOME/lesshst.ini"or"$INIT/lesshst.ini"๐ป
- Linux and Unix:
LESSHISTSIZEโ the max number of commands saved in the history file. The default is100๐ฏLESSKEYINโ the name of the default lesskey source file ๐LESSKEYโ the name of the default lesskey binary file. (Not used if"$LESSKEYIN"exists.) ๐LESSKEY_CONTENTโ the value gets parsed like it's the parameter of a--lesskey-contentoption ๐งพLESSKEYIN_SYSTEMโ the name of the default system-wide lesskey source file ๐LESSKEY_SYSTEMโ the name of the default system-wide lesskey binary file. (Not used if"$LESSKEYIN_SYSTEM"exists.) ๐LESSMETACHARSโ a list of characters the shell considers "metacharacters" ๐ โโ๏ธLESSMETAESCAPEโ a prefix less adds before each metacharacter in a command sent to the shell. IfLESSMETAESCAPEis an empty string, commands containing metacharacters won't be passed to the shell at all ๐ซLESSOPENโ the command line that invokes the (optional) input-preprocessor ๐ ๏ธLESSSECUREโ runs less in "secure" mode. See the discussion under SECURITY ๐ก๏ธLESSSECURE_ALLOWโ turns on individual features that LESSSECURE normally disables. See the discussion under SECURITY ๐LESSSEPARATORโ the string added after a directory name during filename completion ๐LESSUTFBINFMTโ the format used to display non-printable Unicode code points ๐ฃLESSUTFCHARDEFโ overrides the type of specified Unicode characters ๐จLESS_COLUMNSโ sets how many columns the screen has. UnlikeCOLUMNS, this one beats the system's idea of the screen size, so you can make less use less than the full width. If it's set to a negative number, the columns used become that much less than the actual screen width ๐LESS_LINESโ sets how many lines the screen has. UnlikeLINES, this one beats the system's idea of the screen size, so you can make less use less than the full height. If it's set to a negative number, the lines used become that much less than the actual screen height. When it's set, less repaints the entire screen on every movement command, so scrolling may be slower ๐ขLESS_DATA_DELAYโ how long (in milliseconds) after starting to read input data before the "Waiting for data" message shows up. The default is4000(4 seconds) โณLESS_IS_MOREโ makes less emulate the more(1) command ๐ญLESS_OSC8_xxxโ wherexxxis a URI scheme likehttporfile, this sets an OSC 8 handler for opening OSC 8 links with a URI of that scheme ๐LESS_OSC8_ANYโ sets an OSC 8 handler for opening OSC 8 links that don't have a specificLESS_OSC8_xxxhandler for their scheme ๐LESS_TERMCAP_xxโ wherexxis any two characters, this overrides the definition of that termcap capability for the terminal ๐๏ธLESS_UNSUPPORTโ a space-separated list of command line options. These get ignored (with no error message) if they show up on the command line or in theLESSenv var. Options listed inLESS_UNSUPPORTcan still be changed by the-and--commands ๐ Each option inLESS_UNSUPPORTis either a dash followed by a single option letter, or two dashes followed by a long option name ๐งฉLINESโ sets how many lines the screen has. It beats the number of lines fromTERM. (But if you've got a windowing system that supportsTIOCGWINSZorWIOCGETD, the window system's idea of the screen size wins over theLINESandCOLUMNSenv vars ๐ช)MOREโ options that get passed to less automatically when it's running in more-compatible mode ๐ฟPATHโ the user's search path (used to find a lesskey file on MS-DOS, Windows, and OS/2 systems) ๐บ๏ธSHELLโ the shell used to run the!command, and also used to expand filenames ๐TERMโ the type of terminal less is running on ๐บVISUALโ the name of the editor (used for thevcommand) ๐จXDG_CONFIG_HOMEโ a possible location for the lesskey file; see the KEY BINDINGS section ๐๏ธXDG_DATA_HOMEโ a possible location for the history file; see the description of theLESSHISTFILEenv var ๐XDG_STATE_HOMEโ a possible location for the history file; see the description of theLESSHISTFILEenv var ๐ฑ
โจ SEE ALSO โจ
lesskey(1), lessecho(1) ๐ซถ
๐ COPYRIGHT ๐
Copyright (C) 1984-2024 Mark Nudelman ๐
less is part of the GNU project and is free software ๐ธ You can redistribute it and/or modify it under the terms of either (1) the GNU General Public License as published by the Free Software Foundation; or (2) the Less License. See the file README in the less distribution for more details regarding redistribution. You should have received a copy of the GNU General Public License along with the source for less; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. You should also have received a copy of the Less License; see the file LICENSE.
less is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE ๐ญ See the GNU General Public License for more details.
๐ AUTHOR ๐
Mark Nudelman ๐งโ๐ป
Report bugs at https://github.com/gwsw/less/issues. ๐ For more information, see the less homepage at https://greenwoodsoftware.com/less. ๐
bestie, that's the whole page! ๐ฆ less Version 668, last touched 06 Oct 2024, man page for LESS(1) ๐ you're officially less-literate now, periodt โจ
๐ฆ where this page comes from
- ubuntu questing: less 668-1 ยท GPL-3.0-or-later OR Less
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms