From bcdbe8039b1f92360fae7c4e7a9cdb3a6859aaca Mon Sep 17 00:00:00 2001 From: druckdev <63563978+druckdev@users.noreply.github.com> Date: Wed, 23 Sep 2020 03:01:24 +0200 Subject: [PATCH] ranger: Use bat to preview text files (WIP) wrap_plaintext_previews has to be disabled, otherwise bats output is completely messed up. On the other hand I'd like to have it turned on since it is useful when the usually pretty long file type classification is used as preview. --- .config/ranger/rc.conf | 2 +- .config/ranger/scope.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.config/ranger/rc.conf b/.config/ranger/rc.conf index b41a007..06c2b8a 100644 --- a/.config/ranger/rc.conf +++ b/.config/ranger/rc.conf @@ -129,7 +129,7 @@ set preview_directories true set collapse_preview true # Wrap long lines in plain text previews? -set wrap_plaintext_previews true +set wrap_plaintext_previews false # Save the console history on exit? set save_console_history true diff --git a/.config/ranger/scope.sh b/.config/ranger/scope.sh index 1812609..57d5713 100755 --- a/.config/ranger/scope.sh +++ b/.config/ranger/scope.sh @@ -296,6 +296,8 @@ handle_mime() { ## Text text/* | */xml) + bat --decorations=always --color=always --paging=never \ + --terminal-width="$PV_WIDTH" -- "${FILE_PATH}" && exit 0 ## Syntax highlight if [[ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then exit 2