ranger-users
[Top][All Lists]
Advanced

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

Re: [Ranger-users] Fine grained color control for text files


From: Roman Z.
Subject: Re: [Ranger-users] Fine grained color control for text files
Date: Tue, 16 Apr 2013 13:55:00 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Apr 16, 2013 at 01:34:08PM +0200, Emanuel Guével wrote:
> Hello,
> 
> > A more elegant approach would be define tags for various directories and
> > set the hidden_filter per tag (though I don't know if this is possible).
> 
> Challenge accepted!
> Add this to you ~/.config/ranger/commads.py:
> ---
> class settaglocal(Command):
>     """:settaglocal tag=<character> <option name>=<python expression>
> 
>     Set option for each directory having this tag.
>     """
>     TAG_RE = re.compile(r'^\s*tag=(.)\s*$')
>     def execute(self):
>         from os.path import isdir
>         match = self.TAG_RE.match(self.arg(1))
>         if match:
>             wantedtag = match.group(1)
>             self.shift()
>         else:
>             self.fm.notify('No tag specified!', bad=True)
> 
>         name, value, _ = self.parse_setting_line()
>         for path,tag in self.fm.tags.tags.items():
>             if tag == wantedtag and isdir(path):
>                 self.fm.set_option_from_string(name, value, localpath=path)
>                 self.fm.notify(path)
> ---
> 
> Then, use the new command to set your option:
> settaglocal tag=* hidden_filter ^(stuff)$
> 
> Note: the command need to be re-run in order to set options in
> directories freshly tagged. Also, options will remain if the tag is
> removed; running the command again will not change that.

I like this idea :) I think im gonna add a command later which
automatically updates the local options as soon as you set the tag,
without having to rerun the command

Roman




reply via email to

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