From d3d16b3ab6acf23010b5d301c3589be00ece53b5 Mon Sep 17 00:00:00 2001 From: Digital Studium Date: Sun, 17 Mar 2024 11:56:36 +0300 Subject: [PATCH] Add markdown preview --- install_fonts.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ install_software.sh | 4 +++- lf_preview.sh | 6 ++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 install_fonts.sh diff --git a/install_fonts.sh b/install_fonts.sh new file mode 100644 index 0000000..d001709 --- /dev/null +++ b/install_fonts.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +declare -a fonts=( + BitstreamVeraSansMono + CodeNewRoman + DroidSansMono + FiraCode + FiraMono + Go-Mono + Hack + Hermit + JetBrainsMono + Meslo + Noto + Overpass + ProggyClean + RobotoMono + SourceCodePro + SpaceMono + Ubuntu + UbuntuMono +) + +version='3.1.1' +fonts_dir="${HOME}/.local/share/fonts" + +if [[ ! -d "$fonts_dir" ]]; then + mkdir -p "$fonts_dir" +fi + +for font in "${fonts[@]}"; do + zip_file="${font}.zip" + download_url="https://github.com/ryanoasis/nerd-fonts/releases/download/v${version}/${zip_file}" + echo "Downloading $download_url" + wget "$download_url" + unzip "$zip_file" -d "$fonts_dir" + rm "$zip_file" +done + +find "$fonts_dir" -name '*Windows Compatible*' -delete + +fc-cache -fv + diff --git a/install_software.sh b/install_software.sh index 7ae08e9..09f2401 100755 --- a/install_software.sh +++ b/install_software.sh @@ -31,7 +31,9 @@ tensorrt-libs \ bat \ locales \ fzf \ -scrot +scrot `# screenshots` \ +libreadline-dev `# for nnn` \ +nnn `# nnn is file manager` sudo locale-gen ru_RU sudo locale-gen ru_RU.UTF-8 diff --git a/lf_preview.sh b/lf_preview.sh index 62545bb..1284b9f 100755 --- a/lf_preview.sh +++ b/lf_preview.sh @@ -33,6 +33,12 @@ case "$MIME" in unzip -l "$1" ;; # any plain text file that doesn't have a specific handler + *text/plain*) + pandoc $1 > /tmp/lf_preview.html && cutycapt --url=file:///tmp/lf_preview.html --out=/tmp/lf_preview.png && chafa -s "$2x$3" -f sixel /tmp/lf_preview.png + ;; + *text/plain*) + ;; + # any plain text file that doesn't have a specific handler *text/plain*) # return false to always repaint, in case terminal size changes batcat --force-colorization --paging=never --style=changes,numbers \