summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/defaults/options.py4
-rw-r--r--ranger/fsobject/directory.py16
-rw-r--r--ranger/shared/settings.py1
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()
;id=1265d9cff8ea2ceaaa3a0202ddbd8681357bc043'>1265d9c ^
cab3771 ^
a729179 ^
1265d9c ^
cab3771 ^

1c41b63 ^
cab3771 ^
80e891a ^
1c41b63 ^

cab3771 ^
8492a21 ^

b60999c ^
8492a21 ^


b76deea ^
648ca98 ^
24dfc47 ^
8492a21 ^
0911cd5 ^
1c41b63 ^
cab3771 ^
8492a21 ^
cab3771 ^

607ece8 ^
1228448 ^


cab3771 ^
b76deea ^


cab3771 ^





1170893 ^



cab3771 ^



80e891a ^
c286d3d ^

cab3771 ^
8492a21 ^
b60999c ^

8492a21 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84