fix(config_help): use --pattern for section jump; correct ov nav keys
--jump-target does not work reliably on piped stdin. Replace with --pattern which positions ov at the first occurrence of the keyword (works like less +/pattern) and keeps the match highlighted so the user can press n/N to navigate further occurrences. Also correct the section navigation keys in the offline manual: Space = next section (not '.') ^ = previous section (not ',') Alt+u = section list sidebar
This commit is contained in:
+20
-12
@@ -47,23 +47,31 @@ function config_help --description 'Open the offline fish shell configuration ma
|
||||
end
|
||||
|
||||
# ── Viewer fallback chain ────────────────────────────────────
|
||||
# Best case: bat colors the output; ov matches headers in the ANSI stream
|
||||
# via a regex that skips the escape codes preceding each '#'.
|
||||
# bat emits headers as: ESC[<color>m# ... so we match ^(ESC\[[0-9;]*m)+#
|
||||
# This is theme-agnostic (works for any 8/24-bit color sequence) and
|
||||
# gives us both syntax highlighting AND section navigation (,/.).
|
||||
# bat colors the output; ov matches headers via an ANSI-aware regex.
|
||||
# bat emits: ESC[<color>m# ... so delimiter ^(\x1b\[[0-9;]*m)+# matches
|
||||
# any 8/24-bit color sequence before a '#', theme-agnostic.
|
||||
# Section nav: Space (next), ^ (previous), Alt+u (section list sidebar).
|
||||
# Keyword jump uses --pattern which positions at the first search match.
|
||||
if type -q ov; and type -q bat
|
||||
set -l ov_args \
|
||||
--section-delimiter "^(\x1b\[[0-9;]*m)+#" \
|
||||
--section-header
|
||||
if test -n "$argv[1]"
|
||||
set -a ov_args --pattern "$argv[1]"
|
||||
end
|
||||
bat --color=always --style=plain --language=markdown "$doc_file" \
|
||||
| ov --section-delimiter "^(\x1b\[[0-9;]*m)+#" \
|
||||
--section-header \
|
||||
--jump-target "$start_line"
|
||||
| ov $ov_args
|
||||
|
||||
# ov alone: section navigation on raw Markdown; no code highlighting.
|
||||
else if type -q ov
|
||||
ov --section-delimiter "^#" \
|
||||
--section-header \
|
||||
--jump-target "$start_line" \
|
||||
"$doc_file"
|
||||
set -l ov_args \
|
||||
--section-delimiter "^#" \
|
||||
--section-header \
|
||||
"$doc_file"
|
||||
if test -n "$argv[1]"
|
||||
set -a ov_args --pattern "$argv[1]"
|
||||
end
|
||||
ov $ov_args
|
||||
|
||||
# bat alone: syntax highlighting with built-in paging; no line jump.
|
||||
else if type -q bat
|
||||
|
||||
Reference in New Issue
Block a user