ranger-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ranger-users] enhance preview script


From: Liu Yubao
Subject: Re: [Ranger-users] enhance preview script
Date: Mon, 21 Feb 2011 10:25:19 +0800

Hi Hut,

Thank you for applying my patch, but I'm sorry the patch I sent
is wrapped by GMail so that you missed the "exit 0" parts for
w3m etc.

I hope for preview of html files scope.sh returns 0 not 5 because:
(1) I guess dumping html into text should be very fast thus not
     worth caching.
(2) More importantly, I often maximize and occassionally restore
     my terminal window and hope the preview in ranger can adapt
     the change of terminal geometry.

I have attached the new patch against master branch so that you
can easily apply it.

Best regards,
Yubao Liu

On Tue, Feb 15, 2011 at 9:31 AM, Hut <address@hidden> wrote:
> Hi.
>
> Good idea to use fmt, I was looking for a tool like fmt but didn't find
> for some reason :)
>
> Thanks for the patch, I applied it now, finally
>
> Regards,
> Roman
>
> On Sun, Jan 30, 2011 at 10:34:39AM +0800, Liu Yubao wrote:
>> [[ please Cc to me, I don't subscribe this list.]]
>>
>> Hi,
>>
>> I enhanced the script with the patch against master branch to add
>> these features:
>>
>> (1) add -l 10 to pdftotext to speed up the response, or ranger will
>> freeze on my box
>> (2) add -nopgbrk to suppress ^L in output of pdftotext
>> (3) support w3m text web browser, this is installed in all Debian
>> boxes by default
>> (4) split long lines in output of preview mode for pdf/html as I don't
>> like to press 'l' to scroll,
>>      thus also make scope.sh return 0 in these cases to adapt width
>> change of the preview column.
>>      I don't split for output of highlight because I think they are
>> often well formatted and don't
>>      have too much long lines.
>>
>> Hope they are useful.
>>
>> Regards,
>> Yubao Liu
>>
>> diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh
>> index 754b54d..db184f9 100755
>> --- a/ranger/data/scope.sh
>> +++ b/ranger/data/scope.sh
>> @@ -41,12 +41,13 @@ case "$extension" in
>>                 exit 1;;
>>         # PDF documents:
>>         pdf)
>> -               pdftotext -q "$path" - | head -n $maxln
>> -               success && exit 3 || exit 1;;
>> +               pdftotext -l 10 -nopgbrk -q "$path" - | head -n $maxln
>> | fmt -s -w $width
>> +               success && exit 0 || exit 1;;
>>         # HTML Pages:
>>         htm|html|xhtml)
>> -               have lynx   && lynx   -dump "$path" | head -n $maxln && exit 
>> 5
>> -               have elinks && elinks -dump "$path" | head -n $maxln && exit 
>> 5
>> +               have w3m    && w3m    -dump "$path" | head -n $maxln |
>> fmt -s -w $width && exit 0
>> +               have lynx   && lynx   -dump "$path" | head -n $maxln |
>> fmt -s -w $width && exit 0
>> +               have elinks && elinks -dump "$path" | head -n $maxln |
>> fmt -s -w $width && exit 0
>>                 ;; # fall back to highlight/cat if theres no lynx/elinks
>>  esac
>>
>
>

Attachment: scope-sh.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]