summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.18
-rw-r--r--doc/ranger.pod1
-rw-r--r--ranger/config/rc.conf1
-rw-r--r--ranger/container/fsobject.py2
-rw-r--r--ranger/core/linemode.py15
-rw-r--r--ranger/gui/context.py2
-rw-r--r--ranger/gui/widgets/statusbar.py9
7 files changed, 33 insertions, 5 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 3ba4fe4e..8a1e00c1 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.6.1" "03/03/2015" "ranger manual"
+.TH RANGER 1 "ranger-1.6.1" "30/03/15" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -1006,13 +1006,17 @@ Looks for a string in all marked files or directories.
 .IX Item "linemode linemodename"
 Sets the linemode of all files in the current directory.  The linemode may be:
 .Sp
-.Vb 5
+.Vb 6
 \& "filename": display each line as "<basename>...<size>"
+\& "fileinfo": display each line as "<basename>...<file(1) output>"
 \& "permissions": display each line as "<permissions> <owner> <group> <basename>"
 \& "metatitle": display metadata from .metadata.json files if
 \&     available, fall back to the "filename" linemode if no
 \&     metadata was found.  See :meta command.
 .Ve
+.Sp
+The custom linemodes may be added by subclassing the \fILinemodeBase\fR class.
+See the \fIranger.core.linemode\fR module for some examples.
 .IP "load_copy_buffer" 2
 .IX Item "load_copy_buffer"
 Load the copy buffer from \fI~/.config/ranger/copy_buffer\fR.  This can be used to
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 336a886c..a6204403 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -1046,6 +1046,7 @@ Looks for a string in all marked files or directories.
 Sets the linemode of all files in the current directory.  The linemode may be:
 
  "filename": display each line as "<basename>...<size>"
+ "fileinfo": display each line as "<basename>...<file(1) output>"
  "permissions": display each line as "<permissions> <owner> <group> <basename>"
  "metatitle": display metadata from .metadata.json files if
      available, fall back to the "filename" linemode if no
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index ca67c389..62dd030f 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -251,6 +251,7 @@ map cd console cd
 
 # Change the line mode
 map Mf linemode filename
+map Mi linemode fileinfo
 map Mp linemode permissions
 map Mt linemode metatitle
 
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py
index 131e2304..1bf08e20 100644
--- a/ranger/container/fsobject.py
+++ b/ranger/container/fsobject.py
@@ -86,7 +86,7 @@ class FileSystemObject(FileManagerAware, SettingsAware):
     _linemode = DEFAULT_LINEMODE
     linemode_dict = dict(
         (linemode.name, linemode()) for linemode in
-        [DefaultLinemode, TitleLinemode, PermissionsLinemode]
+        [DefaultLinemode, TitleLinemode, PermissionsLinemode, FileInfoLinemode]
     )
 
     def __init__(self, path, preload=None, path_is_abs=False, basename_is_rel_to=None):
diff --git a/ranger/core/linemode.py b/ranger/core/linemode.py
index 7993af82..529c6b93 100644
--- a/ranger/core/linemode.py
+++ b/ranger/core/linemode.py
@@ -84,3 +84,18 @@ class PermissionsLinemode(LinemodeBase):
 
     def infostring(self, file, metadata):
         return ""
+
+
+class FileInfoLinemode(LinemodeBase):
+    name = "fileinfo"
+
+    def filetitle(self, file, metadata):
+        return file.relative_path
+
+    def infostring(self, file, metadata):
+        if not file.is_directory:
+            from subprocess import check_output
+            fileinfo = check_output(["file", "-bL", file.path]).strip()
+            return fileinfo
+        else:
+            raise NotImplementedError
diff --git a/ranger/gui/context.py b/ranger/gui/context.py
index 2ad27434..e5aef06c 100644
--- a/ranger/gui/context.py
+++ b/ranger/gui/context.py
@@ -11,7 +11,7 @@ CONTEXT_KEYS = ['reset', 'error', 'badinfo',
         'good', 'bad',
         'space', 'permissions', 'owner', 'group', 'mtime', 'nlink',
         'scroll', 'all', 'bot', 'top', 'percentage', 'filter',
-        'marked', 'tagged', 'tag_marker', 'cut', 'copied',
+        'flat', 'marked', 'tagged', 'tag_marker', 'cut', 'copied',
         'help_markup', # COMPAT
         'seperator', 'key', 'special', 'border', # COMPAT
         'title', 'text', 'highlight', 'bars', 'quotes', 'tab', 'loaded',
diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py
index 9ff331a0..f5824d99 100644
--- a/ranger/gui/widgets/statusbar.py
+++ b/ranger/gui/widgets/statusbar.py
@@ -242,8 +242,15 @@ class StatusBar(Widget):
         max_pos = len(target) - self.column.hei
         base = 'scroll'
 
+        right.add(" ", "space")
+
+        if self.fm.thisdir.flat:
+            right.add("flat=", base, 'flat')
+            right.add(str(self.fm.thisdir.flat), base, 'flat')
+            right.add(", ", "space")
+
         if self.fm.thisdir.filter:
-            right.add(" f=`", base, 'filter')
+            right.add("f=`", base, 'filter')
             right.add(self.fm.thisdir.filter.pattern, base, 'filter')
             right.add("', ", "space")