aboutsummaryrefslogtreecommitdiff
path: root/files/.lessfilter.sh
diff options
context:
space:
mode:
authorAnton Bobov <abobov@gmail.com>2020-02-04 23:08:59 +0500
committerAnton Bobov <abobov@gmail.com>2020-02-04 23:08:59 +0500
commit2a063c9edf44ff4e5824a4b73e617c0bd321fb36 (patch)
treebed679ef3b501ebfb4ed305552e826ee8d09f019 /files/.lessfilter.sh
parentb00908d513f35dbee98c52b6609cfceaa6eae371 (diff)
Updates.
Diffstat (limited to 'files/.lessfilter.sh')
-rwxr-xr-xfiles/.lessfilter.sh26
1 files changed, 21 insertions, 5 deletions
diff --git a/files/.lessfilter.sh b/files/.lessfilter.sh
index 9580bf6..b487794 100755
--- a/files/.lessfilter.sh
+++ b/files/.lessfilter.sh
@@ -1,10 +1,26 @@
-#!/bin/sh
+#!/bin/bash
case $1 in
- *.xml) if [ -x `which xmlstarlet 2>/dev/null` ]; then exec xmlstarlet fo "$1"; fi ;;
- *.json) if [ -x `which jq 2>/dev/null` ]; then exec jq -C . "$1"; fi ;;
- *.md) if [ -x `which pandoc 2>/dev/null` ]; then exec pandoc -t plain "$1"; fi ;;
- *) exec /bin/lesspipe "$1";;
+ *.xml)
+ if [ -x "$(command -v xmlstarlet)" ]; then
+ exec xmlstarlet fo "$1"
+ fi
+ ;;
+ *.json)
+ if [ -x "$(command -v jq)" ]; then
+ exec jq -C . "$1"
+ elif [ -x "$(command -v python)" ] ; then
+ exec python -m json.tool "$1"
+ fi
+ ;;
+ *.md)
+ if [ -x "$(command -v pandoc)" ]; then
+ exec pandoc -t plain "$1"
+ fi
+ ;;
+ *)
+ exec /bin/lesspipe "$1"
+ ;;
esac
exit 1