summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xranger/config/commands.py14
-rw-r--r--ranger/container/directory.py23
-rw-r--r--ranger/container/settings.py1
-rw-r--r--ranger/core/main.py3
4 files changed, 27 insertions, 14 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 4cedc4e1..c2ecb3af 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -1480,22 +1480,12 @@ class filter_inode_type(Command):
         f display files
         l display links
     """
-    # pylint: disable=bad-whitespace
-    FILTER_DIRS  = 'd'
-    FILTER_FILES = 'f'
-    FILTER_LINKS = 'l'
-    # pylint: enable=bad-whitespace
 
     def execute(self):
         if not self.arg(1):
-            self.fm.thisdir.inode_type_filter = None
+            self.fm.thisdir.inode_type_filter = ""
         else:
-            self.fm.thisdir.inode_type_filter = lambda file: (
-                True if (
-                    (self.FILTER_DIRS in self.arg(1) and file.is_directory) or
-                    (self.FILTER_FILES in self.arg(1) and file.is_file and not file.is_link) or
-                    (self.FILTER_LINKS in self.arg(1) and file.is_link)
-                ) else False)
+            self.fm.thisdir.inode_type_filter = self.arg(1)
         self.fm.thisdir.refilter()
 
 
diff --git a/ranger/container/directory.py b/ranger/container/directory.py
index 168a46c7..958c6f28 100644
--- a/ranger/container/directory.py
+++ b/ranger/container/directory.py
@@ -95,6 +95,11 @@ def mtimelevel(path, level):
 
 class Directory(  # pylint: disable=too-many-instance-attributes,too-many-public-methods
         FileSystemObject, Accumulator, Loadable):
+
+    FILTER_DIRS = 'd'
+    FILTER_FILES = 'f'
+    FILTER_LINKS = 'l'
+
     is_directory = True
     enterable = False
     load_generator = None
@@ -252,11 +257,25 @@ class Directory(  # pylint: disable=too-many-instance-attributes,too-many-public
                         return False
                 return True
             filters.append(hidden_filter_func)
+        if self.settings.global_inode_type_filter or self.inode_type_filter:
+            def hidden_inode_filter_func(obj):
+                # Use local inode_type_filter is present, global otherwise
+                if self.inode_type_filter:
+                    inode_filter = self.inode_type_filter
+                else:
+                    inode_filter = self.settings.global_inode_type_filter
+                # Apply filter
+                if self.FILTER_DIRS in inode_filter and obj.is_directory:
+                    return True
+                elif self.FILTER_FILES in inode_filter and obj.is_file and not obj.is_link:
+                    return True
+                elif self.FILTER_LINKS in inode_filter and obj.is_link:
+                    return True
+                return False
+            filters.append(hidden_inode_filter_func)
         if self.filter:
             filter_search = self.filter.search
             filters.append(lambda fobj: filter_search(fobj.basename))
-        if self.inode_type_filter:
-            filters.append(self.inode_type_filter)
         if self.temporary_filter:
             temporary_filter_search = self.temporary_filter.search
             filters.append(lambda fobj: temporary_filter_search(fobj.basename))
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 70e299c7..00563772 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -41,6 +41,7 @@ ALLOWED_SETTINGS = {
     'draw_borders': bool,
     'draw_progress_bar_in_status_bar': bool,
     'flushinput': bool,
+    'global_inode_type_filter': str,
     'hidden_filter': str,
     'idle_delay': int,
     'line_numbers': str,
diff --git a/ranger/core/main.py b/ranger/core/main.py
index 38513970..f2434ec6 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -119,6 +119,9 @@ def main(
         FileManagerAware.fm_set(fm)
         load_settings(fm, args.clean)
 
+        if args.choosedir:
+            SettingsAware.settings.global_inode_type_filter = 'd'
+
         if args.list_unused_keys:
             from ranger.ext.keybinding_parser import (special_keys,
                                                       reversed_special_keys)