about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2015-03-30 18:54:57 +0200
committerWojciech Siewierski <wojciech.siewierski@onet.pl>2015-03-30 18:54:57 +0200
commit1b5c7bd54ac76a3e62a28762402b4db2df5d9e2a (patch)
tree52de70d2ed959b7576556d9e9ed3ea6bc38dad28 /ranger
parent83bb5b85c2fff3ca3fc9f36ee74f38e8550cfe0d (diff)
downloadranger-1b5c7bd54ac76a3e62a28762402b4db2df5d9e2a.tar.gz
new linemode with the information from file(1)
Diffstat (limited to 'ranger')
-rw-r--r--ranger/config/rc.conf1
-rw-r--r--ranger/container/fsobject.py2
-rw-r--r--ranger/core/linemode.py15
3 files changed, 17 insertions, 1 deletions
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