ranger-users
[Top][All Lists]
Advanced

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

Re: [Ranger-users] Page command


From: hut
Subject: Re: [Ranger-users] Page command
Date: Mon, 20 Apr 2015 19:44:19 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

> 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)
>         self.fm.ui.redraw_window()
>         self.fm.ui.initialize()

This equivalent command would be simpler:

    :alias page shell less %f

There is also a secret ninja trick. You may know that
`:shell -p <command>` opens the output of <command> in a pager.  Only
few people know (probably because I forgot to document it) that if you
leave out the command, the default command "cat" will be used.
I.e. ":shell -p" == ":shell -p cat".  This allows you to rewrite the
command like:

    :alias page shell -p

And since the key "#" opens the console with `:shell -p`, you can simply
type "#<enter>" to view the file in your pager.

Then, of course, there is the builtin pager which is accessible by
typing "i", as vifon said.

Regards,
hut



reply via email to

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