diff --git a/prev/bat.sh b/prev/bat.sh new file mode 100644 index 0000000..b3a14cc --- /dev/null +++ b/prev/bat.sh @@ -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" diff --git a/prev/cat.sh b/prev/cat.sh new file mode 100644 index 0000000..926d339 --- /dev/null +++ b/prev/cat.sh @@ -0,0 +1 @@ +cat "$f" diff --git a/prev/highlight.sh b/prev/highlight.sh new file mode 100644 index 0000000..30ffe1c --- /dev/null +++ b/prev/highlight.sh @@ -0,0 +1,3 @@ +highlight \ + --replace-tabs=4 --out-format=ansi \ + --style='pablo' --force -- "$f" diff --git a/prev/source_highlight.sh b/prev/source_highlight.sh new file mode 100644 index 0000000..7dfb8a5 --- /dev/null +++ b/prev/source_highlight.sh @@ -0,0 +1,3 @@ +source-highlight \ + --tab=4 --out-format=esc \ + --style=esc256.style --failsafe -i "$f" diff --git a/prev/text.sh b/prev/text.sh deleted file mode 100644 index 9461dc1..0000000 --- a/prev/text.sh +++ /dev/null @@ -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 diff --git a/previews.h b/previews.h index 044a9f0..35236d3 100644 --- a/previews.h +++ b/previews.h @@ -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),