From 3ed002ea88506571f8c9d5c60be7adb72d897dfb Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 30 Dec 2024 17:00:08 +0000 Subject: [PATCH] programs: less: enable color highlighting --- hosts/common/programs/less.nix | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/hosts/common/programs/less.nix b/hosts/common/programs/less.nix index 708d927c2..433249099 100644 --- a/hosts/common/programs/less.nix +++ b/hosts/common/programs/less.nix @@ -2,16 +2,22 @@ { sane.programs.less = { sandbox.autodetectCliPaths = "existingFile"; - env.PAGER = "less"; # LESS flags: - # - F = quit if output fits on one screen - # - K = exit on ctrl+c - # - M = "long prompt" - # - R = output raw control characters - # - S = chop long lines instead of wrapping - # - X = Don't use termcap init/deinit strings (hence, `less` output is visible on the terminal even after exiting) + # - --LINE-NUMBERS (N) = render EVERY line with its number in the left column + # - --LONG-PROMPT (M) = "long prompt" + # - --RAW-CONTROL-CHARS (R) = output raw control characters + # - --chop-long-lines (S) = chop long lines instead of wrapping + # - --incsearch = start searching immediately as you type `/` + # - --no-init (X) = Don't use termcap init/deinit strings (hence, `less` output is visible on the terminal even after exiting) + # - --quit-if-one-screen (F) = quit if output fits on one screen + # - --quit-on-intr (K) = exit on ctrl+c + # - --shift=.n = left/right arrow-keys scroll by `n` screen widths + # - --use-color = enable color instead of just monochrome (highlights search matches) # SYSTEMD_LESS defaults to FRSXMK - env.LESS = "FRMK"; - env.SYSTEMD_LESS = "FRMK"; #< used by journalctl + env = rec { + PAGER = "less"; + LESS = "--incsearch --LONG-PROMPT --quit-if-one-screen --quit-on-intr --RAW-CONTROL-CHARS --shift=.2 --use-color"; + SYSTEMD_LESS = LESS; #< used by journalctl + }; }; }