Split prev/text.sh into 4 different previews

This commit is contained in:
Nikita Ivanov 2022-06-01 21:09:33 +05:00
parent cc0b5d9342
commit 266ed12cdb
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133
6 changed files with 26 additions and 28 deletions

15
prev/bat.sh Normal file
View File

@ -0,0 +1,15 @@
if exists bat; then
batcmd=bat
elif exists batcat; then
batcmd=batcat
else
exit 127
fi
"$batcmd" \
--color always \
--style plain \
--paging never \
--terminal-width "$w" \
--wrap character \
-- "$f"

1
prev/cat.sh Normal file
View File

@ -0,0 +1 @@
cat "$f"

3
prev/highlight.sh Normal file
View File

@ -0,0 +1,3 @@
highlight \
--replace-tabs=4 --out-format=ansi \
--style='pablo' --force -- "$f"

3
prev/source_highlight.sh Normal file
View File

@ -0,0 +1,3 @@
source-highlight \
--tab=4 --out-format=esc \
--style=esc256.style --failsafe -i "$f"

View File

@ -1,27 +0,0 @@
if exists bat; then
batcmd=bat
elif exists batcat; then
batcmd=batcat
else
batcmd=
fi
if [ -n "$batcmd" ]; then
"$batcmd" \
--color always \
--style plain \
--paging never \
--terminal-width "$w" \
--wrap character \
-- "$f"
elif exists highlight; then
highlight \
--replace-tabs=4 --out-format=ansi \
--style='pablo' --force -- "$f"
elif exists source-highlight; then
source-highlight \
--tab=4 --out-format=esc \
--style=esc256.style --failsafe -i "$f"
else
cat "$f"
fi

View File

@ -15,7 +15,10 @@
Preview previews[] = {
PP(NULL, NULL, NULL, wrapper, INT_MAX),
PR(NULL, "text", NULL, text),
PR(NULL, "text", NULL, bat),
PR(NULL, "text", NULL, highlight),
PR(NULL, "text", NULL, source_highlight),
PR(NULL, "text", NULL, cat),
PR(NULL, NULL, NULL, any),
PR("md", NULL, NULL, markdown),
PR(NULL, "application", "json", json),