summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2014-08-26 22:43:28 +0200
committerhut <hut@lepus.uberspace.de>2014-08-26 22:58:57 +0200
commit207cafb045e8288b0f91df1528b9edb2a2c31971 (patch)
treeeb43936b88311e98c796a023f2c6aaa5117598aa
parentdc4216a55e80361177675118944a69514618f6c9 (diff)
downloadranger-207cafb045e8288b0f91df1528b9edb2a2c31971.tar.gz
container.directory: implemented random sorting
-rw-r--r--doc/ranger.18
-rw-r--r--doc/ranger.pod4
-rw-r--r--doc/rifle.12
-rw-r--r--ranger/config/rc.conf3
-rw-r--r--ranger/container/directory.py2
5 files changed, 11 insertions, 8 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 8130ed67..ed94b064 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.6.1" "08/22/2014" "ranger manual"
+.TH RANGER 1 "ranger-1.6.1" "08/26/2014" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -732,10 +732,10 @@ Sort directories first?
 .IP "sort_reverse [bool] <or>" 4
 .IX Item "sort_reverse [bool] <or>"
 Reverse the order of files?
-.IP "sort [string] <oa>, <ob>, <oc>, <om>, <on>, <ot>, <os>" 4
-.IX Item "sort [string] <oa>, <ob>, <oc>, <om>, <on>, <ot>, <os>"
+.IP "sort [string] <oa>, <ob>, <oc>, <om>, <on>, <ot>, <os>, <oz>" 4
+.IX Item "sort [string] <oa>, <ob>, <oc>, <om>, <on>, <ot>, <os>, <oz>"
 Which sorting mechanism should be used?  Choose one of \fBatime\fR, \fBbasename\fR,
-\&\fBctime\fR, \fBmtime\fR, \fBnatural\fR, \fBtype\fR, \fBsize\fR
+\&\fBctime\fR, \fBmtime\fR, \fBnatural\fR, \fBtype\fR, \fBsize\fR, \fBrandom\fR
 .Sp
 Note: You can reverse the order by typing an uppercase second letter in the key
 combination, e.g. \*(L"oN\*(R" to sort from Z to A.
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 5ad58bca..7662d26a 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -736,10 +736,10 @@ Sort directories first?
 
 Reverse the order of files?
 
-=item sort [string] <oa>, <ob>, <oc>, <om>, <on>, <ot>, <os>
+=item sort [string] <oa>, <ob>, <oc>, <om>, <on>, <ot>, <os>, <oz>
 
 Which sorting mechanism should be used?  Choose one of B<atime>, B<basename>,
-B<ctime>, B<mtime>, B<natural>, B<type>, B<size>
+B<ctime>, B<mtime>, B<natural>, B<type>, B<size>, B<random>
 
 Note: You can reverse the order by typing an uppercase second letter in the key
 combination, e.g. "oN" to sort from Z to A.
diff --git a/doc/rifle.1 b/doc/rifle.1
index 9f97c970..999d56d6 100644
--- a/doc/rifle.1
+++ b/doc/rifle.1
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RIFLE 1"
-.TH RIFLE 1 "rifle-1.6.1" "08/22/2014" "rifle manual"
+.TH RIFLE 1 "rifle-1.6.1" "08/26/2014" "rifle manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 5b274657..b2cc9307 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -147,7 +147,7 @@ set autoupdate_cumulative_size false
 # Turning this on makes sense for screen readers:
 set show_cursor false
 
-# One of: size, basename, mtime, type
+# One of: size, natural, basename, atime, ctime, mtime, type, random
 set sort natural
 
 # Additional sorting options
@@ -373,6 +373,7 @@ map <a-9>     tab_open 9
 
 # Sorting
 map or toggle_option sort_reverse
+map oz set sort=random
 map os chain set sort=size;      set sort_reverse=False
 map ob chain set sort=basename;  set sort_reverse=False
 map on chain set sort=natural;   set sort_reverse=False
diff --git a/ranger/container/directory.py b/ranger/container/directory.py
index 07b2192d..de69c467 100644
--- a/ranger/container/directory.py
+++ b/ranger/container/directory.py
@@ -2,6 +2,7 @@
 # This software is distributed under the terms of the GNU GPL version 3.
 
 import os.path
+import random
 import re
 
 from os import stat as os_stat, lstat as os_lstat
@@ -81,6 +82,7 @@ class Directory(FileSystemObject, Accumulator, Loadable):
         'mtime': lambda path: -(path.stat and path.stat.st_mtime or 1),
         'ctime': lambda path: -(path.stat and path.stat.st_ctime or 1),
         'atime': lambda path: -(path.stat and path.stat.st_atime or 1),
+        'random': lambda path: random.random(),
         'type': lambda path: path.mimetype or '',
     }