diff --git a/.config/zsh/functions.zsh b/.config/zsh/functions.zsh index c355efa..2da1ae3 100644 --- a/.config/zsh/functions.zsh +++ b/.config/zsh/functions.zsh @@ -31,11 +31,12 @@ function export-emacs # Highlight cat output with whatever less is using for highlighting function cat-highlight() { - if [[ -t 1 ]]; then # We're in a terminal + # Check if we are in a terminal and $LESSOPEN is not empty + if [[ -t 1 && -n "${LESSOPEN}" ]]; then CATOPEN="${LESSOPEN/| }" CATOPEN="${CATOPEN/ %s}" - cat $@ | eval ${CATOPEN} + \cat $@ | eval ${CATOPEN} else - cat $@ + \cat $@ fi }