ranger-users
[Top][All Lists]
Advanced

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

Re: [Ranger-users] Ranger-users Digest, Vol 51, Issue 17


From: Michael Longval
Subject: Re: [Ranger-users] Ranger-users Digest, Vol 51, Issue 17
Date: Sat, 25 Apr 2015 00:31:08 +0000

Hey guys, 

Many thanks to Wojciech 'vifon' Siewierski and to hut for pointing that stuff out to me. 

Cheers!

Mike 




On Tue, Apr 21, 2015 at 12:00 PM <address@hidden> wrote:
Send Ranger-users mailing list submissions to
        address@hidden

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.nongnu.org/mailman/listinfo/ranger-users
or, via email, send a message with subject or body 'help' to
        address@hidden

You can reach the person managing the list at
        address@hidden

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Ranger-users digest..."


Today's Topics:

   1. Preview command (Michael Longval)
   2. Page command (Michael Longval)
   3. Re: Page command (Wojciech 'vifon' Siewierski)
   4. Re: Page command (hut)
   5. Ranger 1.7.0: Interaction between :filter and     :linemode
      (Gary Johnson)


----------------------------------------------------------------------

Message: 1
Date: Mon, 20 Apr 2015 12:40:50 -0400
From: Michael Longval <address@hidden>
To: address@hidden
Subject: [Ranger-users] Preview command
Message-ID: <address@hidden>
Content-Type: text/plain; charset=us-ascii

Hi,

I added this to my rc.conf and commands.py files

It only works on MacOSX, but I find it usefull.

This part goes into rc.conf:

map P preview %f

And this part goes into command.py:


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

    Opens the specified file in MacOSX Preview.app
    """

    def execute(self):
        theFile = self.fm.thisfile.path
        theCommand = "open -f -a /Applications/Preview.app/ " + "'" + theFile + "' &"  # this only works on MacOSX
        call(theCommand, shell=True)


Mike



------------------------------

Message: 2
Date: Mon, 20 Apr 2015 12:52:45 -0400
From: Michael Longval <address@hidden>
To: address@hidden
Subject: [Ranger-users] Page command
Message-ID: <address@hidden>
Content-Type: text/plain; charset=us-ascii

Hi,

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
HOMEBREW.


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()


Hope it's usefull,

Mike



------------------------------

Message: 3
Date: Mon, 20 Apr 2015 19:27:57 +0200
From: Wojciech 'vifon' Siewierski <address@hidden>
To: address@hidden
Subject: Re: [Ranger-users] Page command
Message-ID: <address@hidden>
Content-Type: text/plain; charset="utf-8"

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

> Hi,
>
> 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
> HOMEBREW.
>
>
> 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()
>
>
> Hope it's usefull,
>
> Mike
>
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nongnu.org/archive/html/ranger-users/attachments/20150420/0d7bae46/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.nongnu.org/archive/html/ranger-users/attachments/20150420/0d7bae46/attachment.pgp>

------------------------------

Message: 4
Date: Mon, 20 Apr 2015 19:44:19 +0200
From: hut <address@hidden>
To: address@hidden
Subject: Re: [Ranger-users] Page command
Message-ID: <address@hidden>
Content-Type: text/plain; charset=us-ascii

> 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



------------------------------

Message: 5
Date: Mon, 20 Apr 2015 15:20:52 -0700
From: Gary Johnson <address@hidden>
To: address@hidden
Subject: [Ranger-users] Ranger 1.7.0: Interaction between :filter and
        :linemode
Message-ID: <address@hidden>
Content-Type: text/plain; charset=us-ascii

I'm seeing an interaction between the :filter and :linemode commands
that I think is a bug.

As a concrete example, use ranger to navigate to the source
directory for ranger-1.7.0 and to the doc directory.  Execute the
following:

    :filter ranger
    :linemode fileinfo
    :filter .1

I would expect all the files whose names contain ".1" to be
displayed with the fileinfo linemode.  Instead I see this:

    ranger.1             troff or preprocessor input, ASCII text
    rifle.1                                               7.46 K

If I remove the filter, I see this:

    config                                                      5
    tools                                                       3
    colorschemes.txt                                       3.18 K
    howto-publish-a-release.txt                             959 B
    ranger.pod                          Pascal source, ASCII text
    ranger.1              troff or preprocessor input, ASCII text
    rifle.pod                                              2.95 K
    rifle.1                                                7.46 K
    screenshot.png                                         54.3 K

So it appears that executing :linemode affects only the files
displayed at the time the command is executed rather than affecting
the display of all the files in that directory until the linemode is
changed.

I'm running ranger-1.7.0 from ranger-stable.tar.gz downloaded 13
April.  My OS is Fedora 17 Linux.

Regards,
Gary




------------------------------

_______________________________________________
Ranger-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/ranger-users


End of Ranger-users Digest, Vol 51, Issue 17
********************************************

reply via email to

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