[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Ranger-users] Fine grained color control for text files
From: |
Emanuel Guével |
Subject: |
Re: [Ranger-users] Fine grained color control for text files |
Date: |
Tue, 16 Apr 2013 13:34:08 +0200 |
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.
Regards,
Emanuel