ranger-users
[Top][All Lists]
Advanced

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

Re: [Ranger-users] ranger 1.6.0 on the horizon


From: Joshua Landau
Subject: Re: [Ranger-users] ranger 1.6.0 on the horizon
Date: Wed, 13 Feb 2013 19:34:29 +0000

On 13 February 2013 03:23, Roman Z. <address@hidden> wrote:
> - option to show output of shell commands in some window, like bottom
> window (hsplit, for instance).

I usually use ":shell -w <command>" or ":shell <command>;read" for this
task.  You can also use the shortcut key "#" to get a console with
":shell -p ", then just type your command and press enter.

You might also like a shortcut that runs :shell -w true, which'll let you quickly preview previous output.
 
> *>>If you like it, I can make this the default behaviour.*
> That would be awesome. I don't really need to see files that are not
> covered with my search command.

I made that the default behavior now.  If you type ":filter foo bar",
the view is filtered as you type.

I made a command a long time ago I use daily, which is an extension of this idea. Seriously, try it out:

class narrow(Command):
    """
    :narrow <string>

    Displays only the files which contain <string> in their basename.
    Unlike :filter, this updates in real-time and, when executed, executes the selection and removes the filter.
    """

    def execute(self):
        self.fm.set_filter("")
        self.fm.reload_cwd()
        self.fm.move(right=1)

    def cancel(self):
        self.fm.set_filter("")
        self.fm.reload_cwd()

    def quick(self):
        self.fm.set_filter(self.rest(1))
        self.fm.reload_cwd()

    def tab(self):
        if self.fm.env.cwd.files[-1] is not self.fm.env.cf:
            self.fm.move(down=1)
        else:
            self.fm.move(to=0)

The idea is you filter, and then RETURN/ESC. It'll clear the filter immediately and run the selected file/abort (respectively).
 
> >>*It lacks libcolumbus support though.*
> Its not really important to support full library. Skipping letters is. I
> suggest implementation via regex. Its trivial and you can choose between
> several options:
>
> If I type "npd"
>
> 1. Insert .* between each letter.  ".*n.*p.*d.*"
> 2. Insert .* between each letter and use ^ before first. "^n.*p.*d.*" .
> Little more natural
> 3. Insert .* between each letter except first and the last: "n.*p.*d". This
> way I could type ^npd$ for instance if I want to. Sounds like the best
> option.
>
> All 3 were implemented in QuickSearch eXtended for Total Commander on my
> suggestion several years ago and I can't live without it.
>
> This would be really great to have in another mode so that one doesn't have
> to type f all the time (with option for automatic open on single match, I
> find it confusing now when it opens on its own, although I am trying to
> adapt). This option makes one browse over file system extremely fast, it
> feel like you are writing a poem. You can get anywhere as fast as you think.

I implemented option 3 now. It's no separate mode, just a command, but
you can do much with commands in ranger ^^.  I called it :scout.  There
is no default key binding for it yet, you can create one by adding this
to your rc.conf:

"map F console scout "
(Without quotes. Note the trailing whitespace)

It allows you to move to the parent directory by typing "." and moving
to any other directory by typing part of its name.  It's not complete
yet but I'd like your input. :)

Again, (to advertise my own stuff ;P) try this. It's an extension of narrow (above) in that it chains automatically (+ more). I use this loads 'cause it's just so goddamn fast:

class travel(Command):
    """
    :travel <string>

    Displays only the files which contain <string> in their basename.
    Unlike :filter, this updates in real-time and, when executed, executes the selection, removes the filter and starts another :travel command.
    """

    special = False

    def execute(self):
        self.fm.set_filter("")
        self.fm.reload_cwd()

        if self.special:
            self.fm.cd(self.special)
            if self.special != "..":
                self.fm.block_input(0.5)
            self.special = False
        else:
            self.fm.move(right=1)

        self.fm.open_console('travel ')

    def cancel(self):
        self.fm.set_filter("")
        self.fm.reload_cwd()

    def quick(self):
        arg = self.rest(1)
        self.fm.set_filter(arg)
        self.fm.reload_cwd()

        if arg == ".":
            return
        if arg == "..":
            self.special = ".."
            return self.execute()

        filtered_files = [d for d in self.fm.env.cwd.files if d.basename.count(arg)]
        if len(filtered_files)==1:
            self.special = filtered_files[0].basename
            return self.execute()

    def tab(self):
        if self.fm.env.cwd.files[-1] is not self.fm.env.cf:
            self.fm.move(down=1)
        else:
            self.fm.move(to=0)

It has an added bonus of supporting ".." to move back a directory AND it automatically travels into directories. I've never needed the skip letter thing above, but now Roman Z's given his :scout implementation it shouldn't be hard and it sounds really interesting.

reply via email to

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