[Top][All Lists]

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

Re: [Ranger-users] Page command

From: Wojciech 'vifon' Siewierski
Subject: Re: [Ranger-users] Page command
Date: Mon, 20 Apr 2015 19:27:57 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0

On 20/04/15 18:52, Michael Longval wrote:


I added a "page" command because "selecting" a text or .py file always
opens it. I don't always want that. 

Here is the rc.conf part:

map pp page %f

and this is the commands.py part:

Now I've been using this for a while now, and I don't recall if I
modified what was already there, or if I added this myself, anyway 
this simply pages the file to 'less'

Also this is very MacOSX specific because I assume that people are using

class page(Command):
    """:page <filename>

    Opens the specified file in 'less'

    def execute(self):
        theFile = self.fm.thisfile.path
        theCommand = "/usr/bin/clear;/usr/local/bin/less '" + theFile +"'"    # this ASSUMES using HOMEBREW
        call(theCommand, shell=True)

Hope it's usefull,


ranger already allows you to “page” the text files: press “i”. It’s not as fully featured but it’s there.

Also, be aware that a file named for example '; rm -rf . ; would be pretty dangerous for your function.

Try replacing call(theCommand, shell=True) with

call(["less", theFile])

or something like this. Just don’t call the shell and you should be fine in most cases.

Kind regards,
Wojciech 'vifon' Siewierski

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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