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.
This commit is contained in:
2020-09-23 03:01:24 +02:00
parent a285fe2a1c
commit bcdbe8039b
2 changed files with 3 additions and 1 deletions

View File

@@ -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

View File

@@ -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