From 6549b810ae108325fd1bf2634e10884c55413bc8 Mon Sep 17 00:00:00 2001 From: GermainZ Date: Sun, 14 Oct 2018 16:28:27 +0200 Subject: Add size_in_bytes setting to show all sizes in bytes --- doc/ranger.1 | 37 ++++++++++++++++++++----------------- doc/ranger.pod | 4 ++++ ranger/config/rc.conf | 3 +++ ranger/container/settings.py | 1 + ranger/ext/human_readable.py | 5 +++++ 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 0cb65d80..b7d70ae1 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) +.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -54,16 +54,20 @@ .\" Avoid warning from groff about undefined register 'F'. .de IX .. -.if !\nF .nr F 0 -.if \nF>0 \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. -. if !\nF==2 \{\ -. nr % 0 -. nr F 2 +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} . \} .\} +.rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -129,11 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -<<<<<<< HEAD -.TH RANGER 1 "ranger-1.9.2" "2018-10-08" "ranger manual" -======= -.TH RANGER 1 "ranger-1.9.2" "10/07/2018" "ranger manual" ->>>>>>> LeLobster-stborderw3mfix +.TH RANGER 1 "ranger-1.9.2" "10/14/2018" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -173,7 +173,7 @@ plugins, sample configuration files and some programs for integrating ranger with other software. They are usually installed to \&\fI/usr/share/doc/ranger/examples\fR. .PP -The man page of \fIrifle\fR\|(1) describes the functions of the file opener +The man page of \fBrifle\fR\|(1) describes the functions of the file opener .PP The section \fI\s-1LINKS\s0\fR of this man page contains further resources. .SH "POSITIONAL ARGUMENTS" @@ -342,7 +342,7 @@ To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR t \fIkitty\fR .IX Subsection "kitty" .PP -This only works on Kitty. It requires \s-1PIL \s0(or pillow) to work. +This only works on Kitty. It requires \s-1PIL\s0 (or pillow) to work. Allows remote image previews, for example in an ssh session. .PP To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR to kitty. @@ -628,7 +628,7 @@ Toggle the mark-status of all files .IP "V" 14 .IX Item "V" Starts the visual mode, which selects all files between the starting point and -the cursor until you press \s-1ESC. \s0 To unselect files in the same way, use \*(L"uV\*(R". +the cursor until you press \s-1ESC.\s0 To unselect files in the same way, use \*(L"uV\*(R". .IP "/" 14 Search for files in the current directory. .IP ":" 14 @@ -893,6 +893,9 @@ Otherwise the submaps are replaced with \*(L"...\*(R". .IP "hostname_in_titlebar [bool]" 4 .IX Item "hostname_in_titlebar [bool]" Show hostname in titlebar? +.IP "size_in_bytes [bool]" 4 +.IX Item "size_in_bytes [bool]" +Print file sizes in bytes instead of the default human-readable format. .IP "idle_delay [integer]" 4 .IX Item "idle_delay [integer]" The delay that ranger idly waits for user input, in milliseconds, with a @@ -1661,7 +1664,7 @@ copy, run: .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fIrifle\fR\|(1) +\&\fBrifle\fR\|(1) .SH "BUGS" .IX Header "BUGS" Report bugs here: diff --git a/doc/ranger.pod b/doc/ranger.pod index c68e7246..f822df39 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -908,6 +908,10 @@ Otherwise the submaps are replaced with "...". Show hostname in titlebar? +=item size_in_bytes [bool] + +Print file sizes in bytes instead of the default human-readable format. + =item idle_delay [integer] The delay that ranger idly waits for user input, in milliseconds, with a diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index b69e3949..6867ce4a 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -293,6 +293,9 @@ set global_inode_type_filter # should be 'false' during start-up, but you can toggle it by pressing F. set freeze_files false +# Print file sizes in bytes instead of the default human-readable format. +set size_in_bytes false + # =================================================================== # == Local Options # =================================================================== diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 405aaa48..22562c10 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -49,6 +49,7 @@ ALLOWED_SETTINGS = { 'hidden_filter': str, 'hint_collapse_threshold': int, 'hostname_in_titlebar': bool, + 'size_in_bytes': bool, 'idle_delay': int, 'iterm2_font_width': int, 'iterm2_font_height': int, diff --git a/ranger/ext/human_readable.py b/ranger/ext/human_readable.py index f365e594..385e56f4 100644 --- a/ranger/ext/human_readable.py +++ b/ranger/ext/human_readable.py @@ -3,6 +3,8 @@ from __future__ import (absolute_import, division, print_function) +from ranger.core.shared import SettingsAware + def human_readable(byte, separator=' '): # pylint: disable=too-many-return-statements """Convert a large number of bytes to an easily readable format. @@ -19,6 +21,9 @@ def human_readable(byte, separator=' '): # pylint: disable=too-many-return-stat if byte is None: return '' + if SettingsAware.settings.size_in_bytes: + return format(byte, 'n') # 'n' = locale-aware separator. + # I know this can be written much shorter, but this long version # performs much better than what I had before. If you attempt to # shorten this code, take performance into consideration. -- cgit 1.4.1-2-gfad0