From 119b6562e2d8826fa6c03d975933118c95df10de Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 19 Aug 2021 13:34:27 +0200 Subject: [PATCH] Wrap bat previews to preview window width --- home/.config/lf/previewer.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/home/.config/lf/previewer.sh b/home/.config/lf/previewer.sh index 962ff14..73784f3 100755 --- a/home/.config/lf/previewer.sh +++ b/home/.config/lf/previewer.sh @@ -122,7 +122,9 @@ text_handle() { # Handle all other formats as text and cat them # if highlighting tools are aviable, try to use them if command -v bat > /dev/null; then - bat -pp --color=always "$1" + num=$(printf "%0.f\n" "`echo "$(tput cols) / 2" | bc`") + numb=$(printf "%d\n" "`echo "$(tput cols) - $num - 3" | bc`") + bat -pp --color=always --wrap=character --terminal-width="$numb" "$1" elif command -v highlight > /dev/null; then highlight "$1" --out-format ansi --force else