Skip to content
shellmap

lessPage through a file with backward navigation and search across all 5 shells

Equivalents in every shell

Bashunix
less file.txt

External pager, strict superset of `more`. `SPACE` / `b` page forward / back; `/pattern` searches forward, `?pattern` searches back; `n` / `N` next / previous match; `g` / `G` jump to start / end; `q` quits. `LESS=-R less` preserves ANSI colour. `less -F` auto-quits if the file fits on one screen.

Zshunix
less file.txt

Same external. Zsh users typically set `export PAGER=less` and `export LESS="-R -i -F -X"`. `${PAGER:-less}` is the canonical pipeline target — `man` and `git` both honour it. Zsh widget `Esc-h` (run-help) pages help text through `$PAGER`.

Fishunix
less file.txt

Same external. Fish auto-uses `less` for `--help` output of every builtin and function. `set -x LESS -R` in `config.fish` preserves colour escapes through `man` and `git diff`. Fish does not bundle its own pager.

PowerShellwindows
less file.txt

NO native `less` on Windows — install via `scoop install less` or `choco install less`. PowerShell `Out-Host -Paging` is the built-in fallback but lacks backward scrolling and regex search. PS 7 on Linux / macOS shells out to the system `/usr/bin/less` if invoked directly.

cmd.exewindows
less file.txt

No native `less`. Install via scoop / choco / WSL, or use `more` (limited — see /cmd/more). Git for Windows bundles a `less.exe` at `C:\Program Files\Git\usr\bin\less.exe` — add to PATH to make it the default pager for cmd-side tools.

Worked examples

Open a file in the pager

Bash
less app.log
Zsh
less app.log
Fish
less app.log
PowerShell
less app.log    # requires installed less, e.g. scoop install less

Tail a file and keep paging as it grows

Bash
less +F app.log
Zsh
less +F app.log
Fish
less +F app.log
PowerShell
Get-Content app.log -Wait -Tail 0

Preserve ANSI colour escapes in piped output

Bash
git diff | less -R
Zsh
git diff | less -R
Fish
git diff | less -R
PowerShell
git diff | less -R    # less.exe required

Gotchas

  • By default `less` STRIPS ANSI escapes — colourful output (git, ripgrep, diff) appears as raw `\e[31m...` codes. Pass `-R` (or set `LESS=-R` globally) to interpret them. `-r` also works but breaks line counting for very long files; prefer `-R`.
  • Without `-F` (`--quit-if-one-screen`), `less` ALWAYS clears the terminal even if the input fits on the visible screen — a common annoyance when paging short output. Set `LESS="-F -X"` in your shell rc: `-X` skips the terminal-init / reset escapes so short content stays visible after `q`.
  • In `+F` follow mode (`less +F app.log`, similar to `tail -f`), pressing `Ctrl-C` exits FOLLOW mode but leaves you IN the pager at the position the file had grown to. Press `q` to fully quit, or `F` to resume following. New users routinely think `Ctrl-C` exited but it did not.
  • Searching with `/pattern` is REGEX by default — `(`, `)`, `?`, `+` are special. For literal-string search, prefix with `\`: `/\(notice\)`. The `-i` flag makes search case-insensitive UNLESS the pattern contains uppercase (smart case, like vim and ripgrep).
  • Windows has NO `less` out of the box. Git for Windows bundles one in `C:\Program Files\Git\usr\bin\less.exe` (often THIS is what gets picked up when `git` invokes a pager), but standalone cmd / PowerShell sessions will not find it unless you add the path. PowerShell users on Windows commonly forget this and curse `more` for hours.

WSL & PowerShell Core notes

pwshpwsh has no bundled pager. Install `less` via scoop / choco on Windows; `/usr/bin/less` is preinstalled on Linux / macOS. To set a pwsh-wide pager (e.g. for `Get-Help`), `$PSDefaultParameterValues["Get-Help:Pager"] = "less -R"` — though `Get-Help` honours this only intermittently on Windows pwsh 7.x.
WSLWSL ships GNU `less`. To page Windows-side output through WSL `less`, use `cmd.exe /c dir | wsl less -R`. The opposite (`wsl ls | less.exe` from Windows) requires `less.exe` on PATH — typically via Git for Windows. ANSI colours survive both directions if `-R` is passed.

Related commands