about summary refs log tree commit diff stats
path: root/examples/plugin_file_filter.py
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2015-04-13 12:49:49 +0200
committerhut <hut@lepus.uberspace.de>2015-04-13 12:49:49 +0200
commitc0f2fc72eccb4127fba5f48ce4b422487d6ec752 (patch)
tree025f72dde6f7a7e5cdca82637da4e5dcef0ddd62 /examples/plugin_file_filter.py
parenta9bbdc440c2ea33ccc4470e00949ffa16ce2300e (diff)
downloadranger-c0f2fc72eccb4127fba5f48ce4b422487d6ec752.tar.gz
moved "doc/examples" to "examples" for more visibility
Diffstat (limited to 'examples/plugin_file_filter.py')
-rw-r--r--examples/plugin_file_filter.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/plugin_file_filter.py b/examples/plugin_file_filter.py
new file mode 100644
index 00000000..b9bea1f3
--- /dev/null
+++ b/examples/plugin_file_filter.py
@@ -0,0 +1,21 @@
+# Compatible since ranger 1.6.1, git commit c82a8a76989c
+#
+# This plugin hides the directories "/boot", "/sbin", "/proc" and "/sys" unless
+# the "show_hidden" option is activated.
+
+# Save the original filter function
+import ranger.container.directory
+old_accept_file = ranger.container.directory.accept_file
+
+HIDE_FILES = ("/boot", "/sbin", "/proc", "/sys")
+
+# Define a new one
+def custom_accept_file(file, filters):
+    if not file.fm.settings.show_hidden and file.path in HIDE_FILES:
+        return False
+    else:
+        return old_accept_file(file, filters)
+
+# Overwrite the old function
+import ranger.container.directory
+ranger.container.directory.accept_file = custom_accept_file