Conversation
495f886 to
0aa436f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1345 +/- ##
==========================================
+ Coverage 88.53% 89.84% +1.30%
==========================================
Files 68 72 +4
Lines 11780 12246 +466
==========================================
+ Hits 10430 11002 +572
+ Misses 1350 1244 -106 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cbd573b to
8f51abd
Compare
…rofiles Users can now configure multiple pager profiles in config.toml, each with its own command, arguments, and activation conditions (e.g. based on environment variables or output follow mode). The pager is selected at runtime by evaluating each profile in priority order. HL_PAGER is the sole candidate-selection gate for the structured env candidate. Profile references (HL_PAGER=@name) resolve the profile for both modes and ignore HL_FOLLOW_PAGER entirely. For direct commands, HL_FOLLOW_PAGER specifies the follow-mode command; if it is not set, paging is disabled in follow mode. BREAKING CHANGE: Using `less` as a direct command via HL_PAGER or PAGER no longer automatically adds -R or sets LESSCHARSET=UTF-8. Use HL_PAGER=@less to delegate to the built-in less profile, which includes these settings explicitly, or pass the flags yourself: HL_PAGER="less -R". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR replaces the hard-coded
HL_PAGER/PAGERpager logic with a fully configurable pager system. Users can now define named pager profiles with role-specific arguments, control candidate search order, use platform/mode conditions, and enable pager support in--followmode.What's New
Pager profiles
Pager programs are now described as named profiles under
[[pager.profiles]]. Each profile specifies the command, base arguments, optional environment variables, an entry delimiter, and mode-specific overrides for view and follow modes.The
modes.follow.enabledflag controls pager behaviour in follow mode. Profile selection always ignores the mode — the first available profile wins. Mode is applied afterwards: whenfalse(the default), the selected profile disables paging forhl --followrather than falling through to a lower-priority candidate.Candidate search list
The
pager.candidatesarray defines the priority-ordered list of things to try.hlworks through the list and uses the first candidate whose pager executable is found inPATH. Three candidate forms are supported:Profile references via
@syntaxWhen an env candidate has
profiles = true, a value starting with@is treated as an explicit profile name rather than a command:Profile references bypass the env delimiter override — the profile's own
delimiterfield takes precedence. This prevents incoherent combinations of command and delimiter.The
PAGERvariable intentionally does not haveprofiles = truebecause it is a universal system variable shared with other programs.@inPAGERis treated literally.Follow-mode pager support
Follow mode (
hl --follow) now supports a pager when the selected profile hasmodes.follow.enabled = true.HL_PAGERis the sole candidate-selection gate for the structured env candidate. Its value drives the complete follow-mode behaviour:Profile reference (
HL_PAGER=@fzf): the profile resolves all configuration for both view and follow modes.HL_FOLLOW_PAGERis completely ignored — the profile's ownmodes.follow.enabledcontrols whether paging is active.HL_PAGER=@fzf hl --follow app.log # fzf profile decides; HL_FOLLOW_PAGER is ignoredDirect command (
HL_PAGER=cmd):HL_FOLLOW_PAGERspecifies the follow-mode command. IfHL_FOLLOW_PAGERis not set, paging is disabled for that invocation.HL_FOLLOW_PAGERalone (withoutHL_PAGER) has no effect on the structured env candidate — the candidate is skipped entirely whenHL_PAGERis not set.Simple env candidates like
{ env = "PAGER" }are skipped in follow mode entirely.Condition-based candidates and profiles
Candidates can carry an
iffield that gates them on platform or mode:Profile
conditionsentries add or override arguments and env vars conditionally:Supported condition strings:
os:macosos:linuxos:windowsos:unixmode:viewmode:follow--followmode!<condition>Entry delimiter per profile
Profiles can declare the output entry delimiter used by the pager:
For direct commands (not profiles), the delimiter can be controlled via
HL_PAGER_DELIMITER.Built-in profiles
The default config ships with ready-to-use profiles for
less,fzf,ov, andmost, including sensible defaults and platform-specific bindings. They are used automatically when the corresponding binary is found inPATH. Users can override any profile by adding a[[pager.profiles]]entry with the samenamein their config file.Behaviour Changes
Breaking:
HL_PAGER=lessno longer injects-RandLESSCHARSET=UTF-8Previously, using
lessas a direct command viaHL_PAGER(orPAGER) caused hl to silently inject the-Rflag and setLESSCHARSET=UTF-8. With the introduction of named profiles,lessis now configured explicitly in the default[[pager.profiles]]entry and carries those same flags there, making the implicit injection redundant. It has been removed.Migration: Use the profile instead of the bare command name:
Configuration Reference
Testing Checklist
HL_PAGER=less hl app.log— direct command, no extra args injectedHL_PAGER=@fzf hl app.log— profile reference (only whenprofiles = true)HL_PAGER=@nonexistent hl app.log— exits with profile-not-found errorHL_PAGER=nonexistent hl app.log— exits with command-not-found errorPAGER=@less hl app.log— treats@lessas a literal command name (not a profile)PAGER=less hl --follow app.log—PAGERis skipped in follow modeHL_PAGER=cat HL_FOLLOW_PAGER=fzf hl --follow app.log— direct command in HL_PAGER, fzf used for followHL_PAGER=cat hl --follow app.log— direct command without HL_FOLLOW_PAGER disables pagingHL_PAGER=@fzf HL_FOLLOW_PAGER=less hl --follow app.log— profile ref ignores HL_FOLLOW_PAGERmodes.follow.enabled = falsedisables paging in follow mode (no fallthrough)modes.follow.enabled = trueis used in follow mode withmodes.follow.args{ profile = "fzf", if = "!os:windows" }skipsfzfon Windowsconditions = [...]append args only when matchingdelimiteris used; envHL_PAGER_DELIMITERignored for profile refs