From 614aeeae20b958b15459179fd8595630bd4096e4 Mon Sep 17 00:00:00 2001 From: Meni Livne Date: Tue, 29 Sep 2026 15:34:34 -0700 Subject: [PATCH] feat: integrate batpipe for archive and file preprocessing --- modules/shell.nix | 1 + src/home/.zshrc | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/shell.nix b/modules/shell.nix index 5457675..625a956 100644 --- a/modules/shell.nix +++ b/modules/shell.nix @@ -22,6 +22,7 @@ in # Syntax highlighting and colorized utilities eza bat + bat-extras.batpipe sourceHighlight zsh-syntax-highlighting fzf diff --git a/src/home/.zshrc b/src/home/.zshrc index 9628293..8680b07 100644 --- a/src/home/.zshrc +++ b/src/home/.zshrc @@ -88,8 +88,12 @@ else PROMPT='%F{cyan}%n%f@%F{blue}%m%f %F{green}%~%f %# ' fi -# Syntax highlighting for less and cat using bat (falls back to source-highlight) -if command -v bat &> /dev/null; then +# Syntax highlighting and archive preprocessing for less and cat using bat/batpipe +if command -v batpipe &> /dev/null; then + eval "$(batpipe)" + alias cat="bat" + export LESS="-R" +elif command -v bat &> /dev/null; then alias cat="bat" export LESSOPEN="| bat --color=always --style=plain %s" export LESS="-R" @@ -98,6 +102,15 @@ elif command -v src-hilite-lesspipe.sh &> /dev/null; then export LESS="-R" fi +# Route JSON files to jless when paging interactively +less() { + if [[ $# -eq 1 && "$1" == *.json && -f "$1" && -t 1 && -t 0 ]] && command -v jless &> /dev/null; then + jless "$@" + else + command less "$@" + fi +} + # Colorized man pages in less export LESS_TERMCAP_mb=$'\E[1;31m' export LESS_TERMCAP_md=$'\E[1;36m'