Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ in
# Syntax highlighting and colorized utilities
eza
bat
bat-extras.batpipe
sourceHighlight
zsh-syntax-highlighting
fzf
Expand Down
17 changes: 15 additions & 2 deletions src/home/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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'
Expand Down
Loading