summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2015-04-09 16:26:46 +0200
committerhut <hut@lepus.uberspace.de>2015-04-09 16:26:46 +0200
commit92ee32581a8841c4a843ad1d644818a0c20a1f1a (patch)
tree7a25dfbc4eca23cbd8fe37e7aeded333fe7185d1
parent453a282ed0d599174cc8f45ed13c54b1be1ea4f6 (diff)
parent1b5c7bd54ac76a3e62a28762402b4db2df5d9e2a (diff)
downloadranger-92ee32581a8841c4a843ad1d644818a0c20a1f1a.tar.gz
Merge branch 'linemode_api' of git://github.com/Vifon/ranger
-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
5 files changed, 24 insertions, 3 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