diff options
-rwxr-xr-x | .local/bin/lesspipe-highlight.sh | 19 | ||||
-rw-r--r-- | .profile | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/.local/bin/lesspipe-highlight.sh b/.local/bin/lesspipe-highlight.sh new file mode 100755 index 0000000..b55e513 --- /dev/null +++ b/.local/bin/lesspipe-highlight.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# TODO: cache source-highlight extensions? + +# XXX: enable overriding +LESSPIPE="$(which lesspipe.sh 2>/dev/null)" +SHLPIPE="$(which src-hilite-lesspipe.sh 2>/dev/null)" + +SHLEXTS= + +[ -x "${LESSPIPE}" ] || LESSPIPE=cat +[ -x "${SHLPIPE}" ] \ + && SHLEXTS=$(source-highlight --lang-list | cut -d = -f1 | sed 's/^/\*./' | paste -d'|' -s) \ + || SHLPIPE=cat + +eval "\ + case \"$1\" in + ${SHLEXTS%|}) ${SHLPIPE} "$1";; + *) ${LESSPIPE} "$1";; + esac" @@ -2,3 +2,4 @@ export PATH="${PATH}:${HOME}/.local/bin:${HOME}/bin" export KRB5_CONFIG="${HOME}/.krb5conf" export EDITOR="vim" export PAGER="less -FRXS" +export LESSOPEN="||${HOME}/.local/bin/lesspipe-highlight.sh %s" |