diff --git a/doc.go b/doc.go index 0c1a504..627c982 100644 --- a/doc.go +++ b/doc.go @@ -1163,7 +1163,7 @@ Extensions can then be used to match cleanly within a conditional: *.rar) unrar l "$1";; *.7z) 7z l "$1";; *.pdf) pdftotext "$1" -;; - *) highlight -O ansi "$1" || cat "$1";; + *) highlight -O ansi "$1";; esac Another important consideration for efficiency is the use of programs with short startup times for preview. @@ -1173,13 +1173,9 @@ This is especially relevant for big files. lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read. When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview. Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code and avoid caching. -You may trap SIGPIPE in your preview script to avoid error propogation: +You may add a trailing '|| true' command to avoid such errors: - #!/bin/sh - - trap "" PIPE - - ... + highlight -O ansi "$1" || true You may also use an existing preview filter as you like. Your system may already come with a preview filter named 'lesspipe'. diff --git a/docstring.go b/docstring.go index ab045fe..5a9ba56 100644 --- a/docstring.go +++ b/docstring.go @@ -1298,7 +1298,7 @@ match cleanly within a conditional: *.rar) unrar l "$1";; *.7z) 7z l "$1";; *.pdf) pdftotext "$1" -;; - *) highlight -O ansi "$1" || cat "$1";; + *) highlight -O ansi "$1";; esac Another important consideration for efficiency is the use of programs with @@ -1311,14 +1311,10 @@ script output pipe with a SIGPIPE when enough lines are read. When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview. Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code -and avoid caching. You may trap SIGPIPE in your preview script to avoid -error propogation: +and avoid caching. You may add a trailing '|| true' command to avoid such +errors: - #!/bin/sh - - trap "" PIPE - - ... + highlight -O ansi "$1" || true You may also use an existing preview filter as you like. Your system may already come with a preview filter named 'lesspipe'. These filters may have diff --git a/lf.1 b/lf.1 index cad48b3..29479ee 100644 --- a/lf.1 +++ b/lf.1 @@ -1292,22 +1292,14 @@ Since this script is called for each file selection change it needs to be as eff *.rar) unrar l "$1";; *.7z) 7z l "$1";; *.pdf) pdftotext "$1" -;; - *) highlight -O ansi "$1" || cat "$1";; + *) highlight -O ansi "$1";; esac .EE .PP -Another important consideration for efficiency is the use of programs with short startup times for preview. For this reason, 'highlight' is recommended over 'pygmentize' for syntax highlighting. Besides, it is also important that the application is processing the file on the fly rather than first reading it to the memory and then do the processing afterwards. This is especially relevant for big files. lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read. When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview. Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code and avoid caching. You may trap SIGPIPE in your preview script to avoid error propogation: +Another important consideration for efficiency is the use of programs with short startup times for preview. For this reason, 'highlight' is recommended over 'pygmentize' for syntax highlighting. Besides, it is also important that the application is processing the file on the fly rather than first reading it to the memory and then do the processing afterwards. This is especially relevant for big files. lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read. When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview. Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code and avoid caching. You may add a trailing '|| true' command to avoid such errors: .PP .EX - #!/bin/sh -.EE -.PP -.EX - trap "" PIPE -.EE -.PP -.EX - ... + highlight -O ansi "$1" || true .EE .PP You may also use an existing preview filter as you like. Your system may already come with a preview filter named 'lesspipe'. These filters may have a mechanism to add user customizations as well. See the related documentations for more information.