diff options
author | hut <hut@lavabit.com> | 2010-01-18 16:42:48 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-01-18 16:42:48 +0100 |
commit | 89ce1b0101c8cea1163af0b360f991a2bd37d57b (patch) | |
tree | 2c6ef2878a0f5e69e81eb2ac54c44b14a3cf6407 /ranger | |
parent | 7b04e5073c30c8547baea9f7995bc3ac9913b952 (diff) | |
download | ranger-89ce1b0101c8cea1163af0b360f991a2bd37d57b.tar.gz |
options: allow to specify how to recognize "hidden files"
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/defaults/options.py | 4 | ||||
-rw-r--r-- | ranger/fsobject/directory.py | 16 | ||||
-rw-r--r-- | ranger/shared/settings.py | 1 |
3 files changed, 18 insertions, 3 deletions
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py index f8eb2b53..236f57a8 100644 --- a/ranger/defaults/options.py +++ b/ranger/defaults/options.py @@ -14,6 +14,7 @@ from ranger.defaults import apps, keys from ranger import colorschemes +import re colorscheme = colorschemes.default @@ -29,3 +30,6 @@ directories_first = True show_hidden = False collapse_preview = True autosave_bookmarks = True + +hidden_filter = re.compile( \ + r'^\.|~$|\.(:?pyc|pyo|bak|swp)$') diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py index 5f038ca2..6dc3ae39 100644 --- a/ranger/fsobject/directory.py +++ b/ranger/fsobject/directory.py @@ -54,6 +54,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware): old_reverse = None old_sort = None old_filter = None + old_hidden_filter = None sort_dict = { 'basename': sort_by_basename, @@ -78,6 +79,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware): self.old_directories_first = self.settings.directories_first self.old_sort = self.settings.sort self.old_filter = self.filter + self.old_hidden_filter = self.settings.hidden_filter self.old_reverse = self.settings.reverse def get_list(self): @@ -145,8 +147,14 @@ class Directory(FileSystemObject, Accumulator, SettingsAware): yield filenames = [] for fname in listdir(self.path): - if not self.settings.show_hidden and fname[0] == '.': - continue + if not self.settings.show_hidden: + hfilter = self.settings.hidden_filter + if hfilter: + if isinstance(hfilter, str) and hfilter in fname: + continue + if hasattr(hfilter, 'search') and \ + hfilter.search(fname): + continue if isinstance(self.filter, str) and self.filter \ and self.filter not in fname: continue @@ -342,8 +350,10 @@ class Directory(FileSystemObject, Accumulator, SettingsAware): if self.load_content_once(*a, **k): return True if self.old_show_hidden != self.settings.show_hidden or \ - self.old_filter != self.filter: + self.old_filter != self.filter or \ + self.old_hidden_filter != self.settings.hidden_filter: self.old_filter = self.filter + self.old_hidden_filter = self.settings.hidden_filter self.old_show_hidden = self.settings.show_hidden self.load_content(*a, **k) return True diff --git a/ranger/shared/settings.py b/ranger/shared/settings.py index 705f8986..552154cd 100644 --- a/ranger/shared/settings.py +++ b/ranger/shared/settings.py @@ -17,6 +17,7 @@ show_hidden scroll_offset directories_first sort reverse preview_files max_history_size colorscheme collapse_preview +hidden_filter max_dirsize_for_autopreview autosave_bookmarks apps keys """.split() |