From a5767f170319c0b7043c4e09c9e35331f15dcd29 Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 30 Jan 2018 15:05:43 +0100 Subject: Guard tmux title changes Changing the tmux window title to "ranger" was not guarded for the presence of the tmux executable, this tripped up at least one user with an `rc.conf` that still `set update_tmux_title true`. While the behavior is *not-a-bug*, I expect most people'd rather have the setting enabled by default since "python" is a less useful window title. Fix #1042 --- examples/rc_emacs.conf | 2 +- ranger/config/rc.conf | 2 +- ranger/gui/ui.py | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf index 26074a42..8924d1d6 100644 --- a/examples/rc_emacs.conf +++ b/examples/rc_emacs.conf @@ -129,7 +129,7 @@ set display_tags_in_all_columns true set update_title false # Set the title to "ranger" in the tmux program? -set update_tmux_title false +set update_tmux_title true # Shorten the title if it gets long? The number defines how many # directories are displayed at once, 0 turns off this feature. diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 38e6f11e..39240b06 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -144,7 +144,7 @@ set display_tags_in_all_columns true set update_title false # Set the title to "ranger" in the tmux program? -set update_tmux_title false +set update_tmux_title true # Shorten the title if it gets long? The number defines how many # directories are displayed at once, 0 turns off this feature. diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 990db0ad..4446cb29 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -9,6 +9,7 @@ import threading import curses from subprocess import CalledProcessError +from ranger.ext.get_executables import get_executables from ranger.ext.keybinding_parser import KeyBuffer, KeyMaps, ALT_KEY from ranger.ext.lazy_property import lazy_property from ranger.ext.signals import Signal @@ -113,7 +114,7 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method self._draw_title = curses.tigetflag('hs') # has_status_line # Save tmux setting `automatic-rename` - if self.settings.update_tmux_title: + if self.settings.update_tmux_title and 'tmux' in get_executables(): try: self._tmux_automatic_rename = check_output( ['tmux', 'show-window-options', '-v', 'automatic-rename']).strip() @@ -123,7 +124,7 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method self.update_size() self.is_on = True - if self.settings.update_tmux_title: + if self.settings.update_tmux_title and 'tmux' in get_executables(): sys.stdout.write("\033kranger\033\\") sys.stdout.flush() @@ -172,7 +173,7 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method DisplayableContainer.destroy(self) # Restore tmux setting `automatic-rename` - if self.settings.update_tmux_title: + if self.settings.update_tmux_title and 'tmux' in get_executables(): if self._tmux_automatic_rename: try: check_output(['tmux', 'set-window-option', -- cgit 1.4.1-2-gfad0 From f65e74eb9828969c01fff68f0a808931bc4399bb Mon Sep 17 00:00:00 2001 From: toonn Date: Wed, 31 Jan 2018 22:55:45 +0100 Subject: Update bindings for media directories Because of `udisks2` `/run/media/$USER` is becoming a common directory for automounting, this adds a keybinding to go there (using the first available letter in the path). Similarly the binding for `/media` now points to `/media/$USER`, because for example ubuntu adopted this new location. I believe the `$USER` parts have to do with security, giving only the user that mounted a filesystem access to it. --- ranger/config/rc.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 38e6f11e..5eaeae89 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -384,7 +384,8 @@ map gl cd -r . map gL cd -r %f map go cd /opt map gv cd /var -map gm cd /media +map gm eval fm.cd('/media/' + os.getenv('USER')) +map gi eval fm.cd('/run/media/' + os.getenv('USER')) map gM cd /mnt map gs cd /srv map gt cd /tmp -- cgit 1.4.1-2-gfad0 From b8a2311bd72f39d2adf4bc0c365c3c22e0ec3897 Mon Sep 17 00:00:00 2001 From: toonn Date: Wed, 31 Jan 2018 23:30:51 +0100 Subject: Only try changing the tmux title if inside tmux Check whether we're running in `tmux` by checking the existence of `$TMUX` and only if so set the window title. --- ranger/gui/ui.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 4446cb29..4f76dfab 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -9,7 +9,6 @@ import threading import curses from subprocess import CalledProcessError -from ranger.ext.get_executables import get_executables from ranger.ext.keybinding_parser import KeyBuffer, KeyMaps, ALT_KEY from ranger.ext.lazy_property import lazy_property from ranger.ext.signals import Signal @@ -114,7 +113,7 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method self._draw_title = curses.tigetflag('hs') # has_status_line # Save tmux setting `automatic-rename` - if self.settings.update_tmux_title and 'tmux' in get_executables(): + if self.settings.update_tmux_title and 'TMUX' in os.environ: try: self._tmux_automatic_rename = check_output( ['tmux', 'show-window-options', '-v', 'automatic-rename']).strip() @@ -124,7 +123,7 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method self.update_size() self.is_on = True - if self.settings.update_tmux_title and 'tmux' in get_executables(): + if self.settings.update_tmux_title and 'TMUX' in os.environ: sys.stdout.write("\033kranger\033\\") sys.stdout.flush() @@ -173,7 +172,7 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method DisplayableContainer.destroy(self) # Restore tmux setting `automatic-rename` - if self.settings.update_tmux_title and 'tmux' in get_executables(): + if self.settings.update_tmux_title and 'TMUX' in os.environ: if self._tmux_automatic_rename: try: check_output(['tmux', 'set-window-option', -- cgit 1.4.1-2-gfad0 From d9ee9ae96ffe441b4a25c398102d22383d2dc424 Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 23 Jan 2018 00:06:16 +0100 Subject: Load system-wide configuration files. Both rc.conf and commands.py are now additionally loaded from `/etc/ranger` if they exist. Fix #869 --- ranger/core/main.py | 56 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/ranger/core/main.py b/ranger/core/main.py index a96b24a1..443b279c 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -339,23 +339,50 @@ def load_settings( # pylint: disable=too-many-locals,too-many-branches,too-many fm.commands.load_commands_from_module(commands_default) if not clean: + system_confdir = os.path.join(os.sep, 'etc', 'ranger') + if os.path.exists(system_confdir): + sys.path.append(system_confdir) allow_access_to_confdir(ranger.args.confdir, True) # Load custom commands - custom_comm_path = fm.confpath('commands.py') - if os.path.exists(custom_comm_path): + def import_file(name, path): # From https://stackoverflow.com/a/67692 + # pragma pylint: disable=no-name-in-module,import-error,no-member + if sys.version_info >= (3, 5): + import importlib.util as util + spec = util.spec_from_file_location(name, path) + module = util.module_from_spec(spec) + spec.loader.exec_module(module) + elif (3, 3) <= sys.version_info < (3, 5): + from importlib.machinery import SourceFileLoader + module = SourceFileLoader(name, path).load_module() + else: + import imp + module = imp.load_source(name, path) + # pragma pylint: enable=no-name-in-module,import-error,no-member + return module + + def load_custom_commands(*paths): old_bytecode_setting = sys.dont_write_bytecode sys.dont_write_bytecode = True - try: - import commands as commands_custom - fm.commands.load_commands_from_module(commands_custom) - except ImportError as ex: - LOG.debug("Failed to import custom commands from '%s'", custom_comm_path) - LOG.exception(ex) - else: - LOG.debug("Loaded custom commands from '%s'", custom_comm_path) + for custom_comm_path in paths: + if os.path.exists(custom_comm_path): + try: + commands_custom = import_file('commands', + custom_comm_path) + fm.commands.load_commands_from_module(commands_custom) + except ImportError as ex: + LOG.debug("Failed to import custom commands from '%s'", + custom_comm_path) + LOG.exception(ex) + else: + LOG.debug("Loaded custom commands from '%s'", + custom_comm_path) sys.dont_write_bytecode = old_bytecode_setting + system_comm_path = os.path.join(system_confdir, 'commands.py') + custom_comm_path = fm.confpath('commands.py') + load_custom_commands(system_comm_path, custom_comm_path) + # XXX Load plugins (experimental) plugindir = fm.confpath('plugins') try: @@ -394,12 +421,17 @@ def load_settings( # pylint: disable=too-many-locals,too-many-branches,too-many allow_access_to_confdir(ranger.args.confdir, False) # Load rc.conf custom_conf = fm.confpath('rc.conf') + system_conf = os.path.join(system_confdir, 'rc.conf') default_conf = fm.relpath('config', 'rc.conf') custom_conf_is_readable = os.access(custom_conf, os.R_OK) - if (os.environ.get('RANGER_LOAD_DEFAULT_RC', 'TRUE').upper() != 'FALSE' or - not custom_conf_is_readable): + system_conf_is_readable = os.access(system_conf, os.R_OK) + if (os.environ.get('RANGER_LOAD_DEFAULT_RC', 'TRUE').upper() != + 'FALSE' or + not (custom_conf_is_readable or system_conf_is_readable)): fm.source(default_conf) + if system_conf_is_readable: + fm.source(system_conf) if custom_conf_is_readable: fm.source(custom_conf) -- cgit 1.4.1-2-gfad0 From 15df157ea45e925335716c6929846e0f05aee30b Mon Sep 17 00:00:00 2001 From: toonn Date: Wed, 24 Jan 2018 13:16:56 +0100 Subject: Update commands.py comments with the new system-wide location --- ranger/config/commands.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index a3837d8e..a7fe68b4 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -3,8 +3,9 @@ # This configuration file is licensed under the same terms as ranger. # =================================================================== # -# NOTE: If you copied this file to ~/.config/ranger/commands_full.py, -# then it will NOT be loaded by ranger, and only serve as a reference. +# NOTE: If you copied this file to /etc/ranger/commands_full.py or +# ~/.config/ranger/commands_full.py, then it will NOT be loaded by ranger, +# and only serve as a reference. # # =================================================================== # This file contains ranger's commands. @@ -13,9 +14,14 @@ # Note that additional commands are automatically generated from the methods # of the class ranger.core.actions.Actions. # -# You can customize commands in the file ~/.config/ranger/commands.py. -# It has the same syntax as this file. In fact, you can just copy this -# file there with `ranger --copy-config=commands' and make your modifications. +# You can customize commands in the files /etc/ranger/commands.py (system-wide) +# and ~/.config/ranger/commands.py (per user). +# They have the same syntax as this file. In fact, you can just copy this +# file to ~/.config/ranger/commands_full.py with +# `ranger --copy-config=commands_full' and make your modifications, don't +# forget to rename it to commands.py. You can also use +# `ranger --copy-config=commands' to copy a short sample commands.py that +# has everything you need to get started. # But make sure you update your configs when you update ranger. # # =================================================================== -- cgit 1.4.1-2-gfad0 From 836c422dfea619e9581bf0dd2ee285e54ca53155 Mon Sep 17 00:00:00 2001 From: toonn Date: Wed, 24 Jan 2018 13:21:20 +0100 Subject: Update comments in rc.conf with system-wide location --- ranger/config/rc.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 676090fb..46c56eb3 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -1,7 +1,8 @@ # =================================================================== # This file contains the default startup commands for ranger. -# To change them, it is recommended to create the file -# ~/.config/ranger/rc.conf and add your custom commands there. +# To change them, it is recommended to create either /etc/ranger/rc.conf +# (system-wide) or ~/.config/ranger/rc.conf (per user) and add your custom +# commands there. # # If you copy this whole file there, you may want to set the environment # variable RANGER_LOAD_DEFAULT_RC to FALSE to avoid loading it twice. -- cgit 1.4.1-2-gfad0 From c921a418d1241170b78c3a4bdc4fd6a5083432fd Mon Sep 17 00:00:00 2001 From: Christian Zangl Date: Mon, 5 Feb 2018 22:25:02 +0100 Subject: fix automatically_count_files false --- ranger/ext/human_readable.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ranger/ext/human_readable.py b/ranger/ext/human_readable.py index df74eabf..f365e594 100644 --- a/ranger/ext/human_readable.py +++ b/ranger/ext/human_readable.py @@ -15,6 +15,10 @@ def human_readable(byte, separator=' '): # pylint: disable=too-many-return-stat '1023 M' """ + # handle automatically_count_files false + if byte is None: + return '' + # 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 From 7324552d9f89e18046bf4d511317a940105287e2 Mon Sep 17 00:00:00 2001 From: tau3 Date: Thu, 15 Feb 2018 20:11:00 +0400 Subject: Fixed start path resolving in case of absent working directory --- .gitignore | 2 ++ ranger/core/main.py | 23 +++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 88c75b90..3d946b72 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ /ranger_fm.egg-info /stuff/* + +.idea \ No newline at end of file diff --git a/ranger/core/main.py b/ranger/core/main.py index 4adea918..5f5af332 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -93,10 +93,7 @@ def main( args.selectfile = os.path.abspath(args.selectfile) args.paths.insert(0, os.path.dirname(args.selectfile)) - if args.paths: - paths = [p[7:] if p.startswith('file:///') else p for p in args.paths] - else: - paths = [os.environ.get('PWD', os.getcwd())] + paths = __get_paths(args) paths_inaccessible = [] for path in paths: try: @@ -235,6 +232,24 @@ https://github.com/ranger/ranger/issues return exit_code # pylint: disable=lost-exception +def __get_paths(args): + if args.paths: + prefix = 'file:///' + prefix_length = len(prefix) + paths = [path[prefix_length:] if path.startswith(prefix) else path for path in args.paths] + else: + start_directory = os.environ.get('PWD') + is_valid_start_directory = start_directory and os.path.exists(start_directory) + if not is_valid_start_directory: + start_directory = __get_home_directory() + paths = [start_directory] + return paths + + +def __get_home_directory(): + return os.path.expanduser('~') + + def xdg_path(env_var): path = os.environ.get(env_var) if path and os.path.isabs(path): -- cgit 1.4.1-2-gfad0 From 2c4322cac434f767ede180b9724f77e2a7845367 Mon Sep 17 00:00:00 2001 From: tau3 Date: Thu, 15 Feb 2018 21:11:47 +0400 Subject: Implemented unit test for recent fix --- .gitignore | 3 ++- ranger/core/main.py | 4 ++-- tests/ranger/core/__init__.py | 0 tests/ranger/core/test_main.py | 18 ++++++++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tests/ranger/core/__init__.py create mode 100644 tests/ranger/core/test_main.py diff --git a/.gitignore b/.gitignore index 3d946b72..73ca85e6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ /stuff/* -.idea \ No newline at end of file +.idea +.pytest_cache diff --git a/ranger/core/main.py b/ranger/core/main.py index 5f5af332..595ebfae 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -93,7 +93,7 @@ def main( args.selectfile = os.path.abspath(args.selectfile) args.paths.insert(0, os.path.dirname(args.selectfile)) - paths = __get_paths(args) + paths = get_paths(args) paths_inaccessible = [] for path in paths: try: @@ -232,7 +232,7 @@ https://github.com/ranger/ranger/issues return exit_code # pylint: disable=lost-exception -def __get_paths(args): +def get_paths(args): if args.paths: prefix = 'file:///' prefix_length = len(prefix) diff --git a/tests/ranger/core/__init__.py b/tests/ranger/core/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/ranger/core/test_main.py b/tests/ranger/core/test_main.py new file mode 100644 index 00000000..d992b8a7 --- /dev/null +++ b/tests/ranger/core/test_main.py @@ -0,0 +1,18 @@ +import collections +import os + +from ranger.core import main + + +def test_get_paths(): + args_tuple = collections.namedtuple('args', 'paths') + args = args_tuple(paths=None) + + paths = main.get_paths(args) + + for path in paths: + assert os.path.exists(path) + + +if __name__ == '__main__': + test_get_paths() -- cgit 1.4.1-2-gfad0 From ed4eb4bf282354886e52ae6fa92bf68078edfef6 Mon Sep 17 00:00:00 2001 From: Stephane Fontaine Date: Sat, 24 Feb 2018 21:10:35 +0400 Subject: Add new option to disable display of free disk space in statusbar Fixes #1087 Useful on high-latency filesystems as it avoid calls to statvfs system call which costs: (number of redraw) * latency. --- doc/ranger.1 | 3 +++ doc/ranger.pod | 4 ++++ examples/rc_emacs.conf | 3 +++ ranger/config/rc.conf | 3 +++ ranger/container/settings.py | 1 + ranger/gui/widgets/statusbar.py | 15 ++++++++------- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index fca30604..9ec79cfd 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -766,6 +766,9 @@ Display the file size in the main column? Display the file size in the status bar? .IP "display_tags_in_all_columns [bool]" 4 .IX Item "display_tags_in_all_columns [bool]" +Display the free disk space in the status bar? +.IP "display_free_space_in_status_bar [bool]" 4 +.IX Item "display_free_space_in_status_bar [bool]" Display tags in all columns? .IP "draw_borders [bool]" 4 .IX Item "draw_borders [bool]" diff --git a/doc/ranger.pod b/doc/ranger.pod index 523d8d9d..04598bd2 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -752,6 +752,10 @@ Display the file size in the main column? Display the file size in the status bar? +=item display_free_space_in_status_bar [bool] + +Display the free disk space in the status bar? + =item display_tags_in_all_columns [bool] Display tags in all columns? diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf index 26074a42..4743f8a3 100644 --- a/examples/rc_emacs.conf +++ b/examples/rc_emacs.conf @@ -122,6 +122,9 @@ set mouse_enabled true set display_size_in_main_column true set display_size_in_status_bar true +# Display the free disk space in the status bar? +set display_free_space_in_status_bar true + # Display files tags in all columns or only in main column? set display_tags_in_all_columns true diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 676090fb..51d18ff2 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -137,6 +137,9 @@ set mouse_enabled true set display_size_in_main_column true set display_size_in_status_bar true +# Display the free disk space in the status bar? +set display_free_space_in_status_bar true + # Display files tags in all columns or only in main column? set display_tags_in_all_columns true diff --git a/ranger/container/settings.py b/ranger/container/settings.py index d0b094d0..e87b6e48 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -38,6 +38,7 @@ ALLOWED_SETTINGS = { 'dirname_in_tabs': bool, 'display_size_in_main_column': bool, 'display_size_in_status_bar': bool, + "display_free_space_in_status_bar": bool, 'display_tags_in_all_columns': bool, 'draw_borders': bool, 'draw_progress_bar_in_status_bar': bool, diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py index 266d48ca..3457955e 100644 --- a/ranger/gui/widgets/statusbar.py +++ b/ranger/gui/widgets/statusbar.py @@ -275,13 +275,14 @@ class StatusBar(Widget): # pylint: disable=too-many-instance-attributes right.add("/" + str(len(target.marked_items))) else: right.add(human_readable(target.disk_usage, separator='') + " sum") - try: - free = get_free_space(target.mount_path) - except OSError: - pass - else: - right.add(", ", "space") - right.add(human_readable(free, separator='') + " free") + if self.settings.display_free_space_in_status_bar: + try: + free = get_free_space(target.mount_path) + except OSError: + pass + else: + right.add(", ", "space") + right.add(human_readable(free, separator='') + " free") right.add(" ", "space") if target.marked_items: -- cgit 1.4.1-2-gfad0 From 3db6e6af38c45e01605d2f143281b59f6efc79db Mon Sep 17 00:00:00 2001 From: Michael Ilsaas Date: Fri, 27 Apr 2018 22:13:51 +0200 Subject: ext.rifle: Additional Check for mime type with mimetype command --- ranger/ext/rifle.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index 70215039..69a561a8 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -261,6 +261,11 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes process = Popen(["file", "--mime-type", "-Lb", fname], stdout=PIPE, stderr=PIPE) mimetype, _ = process.communicate() self._mimetype = mimetype.decode(ENCODING).strip() + if self._mimetype == 'application/octet-stream': + process = Popen(["mimetype", "--output-format", "%m", fname], + stdout=PIPE, stderr=PIPE) + mimetype, _ = process.communicate() + self._mimetype = mimetype.decode(ENCODING).strip() return self._mimetype def _build_command(self, files, action, flags): -- cgit 1.4.1-2-gfad0 From 1f4d1a3dbbfd2d116d8685fe38be3a3ce91cd34a Mon Sep 17 00:00:00 2001 From: Michael Ilsaas Date: Sat, 28 Apr 2018 09:32:18 +0200 Subject: Handle not installed mimetypes command --- ranger/ext/rifle.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index 69a561a8..1bc7e3b6 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -262,10 +262,13 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes mimetype, _ = process.communicate() self._mimetype = mimetype.decode(ENCODING).strip() if self._mimetype == 'application/octet-stream': - process = Popen(["mimetype", "--output-format", "%m", fname], - stdout=PIPE, stderr=PIPE) - mimetype, _ = process.communicate() - self._mimetype = mimetype.decode(ENCODING).strip() + try: + process = Popen(["mimetype", "--output-format", "%m", fname], + stdout=PIPE, stderr=PIPE) + mimetype, _ = process.communicate() + self._mimetype = mimetype.decode(ENCODING).strip() + except: + pass return self._mimetype def _build_command(self, files, action, flags): -- cgit 1.4.1-2-gfad0 From 9f60ca76603e820b1e2f26f91880ca05ec0d75f4 Mon Sep 17 00:00:00 2001 From: Michael Ilsaas Date: Sat, 28 Apr 2018 12:01:38 +0200 Subject: Fixed bare exception, added OSError --- ranger/ext/rifle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index 1bc7e3b6..672b0597 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -267,7 +267,7 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes stdout=PIPE, stderr=PIPE) mimetype, _ = process.communicate() self._mimetype = mimetype.decode(ENCODING).strip() - except: + except OSError: pass return self._mimetype -- cgit 1.4.1-2-gfad0 From c0e9230f2434e897c4983ec1d2ceb0b5594ae5b5 Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 8 May 2018 10:35:23 +0200 Subject: Fix a longstanding typo in config/__init__.py --- ranger/config/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/config/__init__.py b/ranger/config/__init__.py index 71df3cb3..0facbdf8 100644 --- a/ranger/config/__init__.py +++ b/ranger/config/__init__.py @@ -1 +1 @@ -"""Default options and configration files""" +"""Default options and configuration files""" -- cgit 1.4.1-2-gfad0 From 5ddfc6477643ffd3690d430f2f04d2b340d5e6a3 Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 8 May 2018 12:15:43 +0200 Subject: Document system-wide configuration files. --- doc/ranger.1 | 9 ++++++--- doc/ranger.pod | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index ab47de61..352b6a27 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.0" "2018-01-28" "ranger manual" +.TH RANGER 1 "ranger-1.9.0" "2018-05-08" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -267,7 +267,7 @@ typing \fI"\fR. By default, only text files are previewed, but you can enable external preview scripts by setting the option \f(CW\*(C`use_preview_script\*(C'\fR and \f(CW\*(C`preview_files\*(C'\fR to true. .PP -This default script is \fI~/.config/ranger/scope.sh\fR. It contains more +This default script is \fI\f(CI%rangerdir\fI/data/scope.sh\fR. It contains more documentation and calls to the programs \fIlynx\fR and \fIelinks\fR for html, \&\fIhighlight\fR for text/code, \fIimg2txt\fR for images, \fIatool\fR for archives, \&\fIpdftotext\fR for PDFs and \fImediainfo\fR for video and audio files. @@ -463,7 +463,7 @@ sample plugins in the \fI/usr/share/doc/ranger/examples/\fR directory, including hello-world plugin that describes this procedure. .SH "KEY BINDINGS" .IX Header "KEY BINDINGS" -Key bindings are defined in the file \fIranger/config/rc.conf\fR. Check this +Key bindings are defined in the file \fI\f(CI%rangerdir\fI/config/rc.conf\fR. Check this file for a list of all key bindings. You can copy it to your local configuration directory with the \-\-copy\-config=rc option. .PP @@ -1421,6 +1421,9 @@ being bound despite the corresponding line being removed from the user's copy of the configuration file. This behavior may be disabled with an environment variable (see also: \fB\s-1ENVIRONMENT\s0\fR). Note: All other configuration files only read from one source; i.e. default \s-1OR\s0 user, not both. +\&\fIrc.conf\fR and \fIcommands.py\fR are additionally read from \fI/etc/ranger\fR if they +exist for system-wide configuration, user configuration overrides system +configuration which overrides the default configuration. .PP When starting ranger with the \fB\-\-clean\fR option, it will not access or create any of these files. diff --git a/doc/ranger.pod b/doc/ranger.pod index ee869393..69adc78e 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -174,7 +174,7 @@ typing I<">. By default, only text files are previewed, but you can enable external preview scripts by setting the option C and C to true. -This default script is F<~/.config/ranger/scope.sh>. It contains more +This default script is F<%rangerdir/data/scope.sh>. It contains more documentation and calls to the programs I and I for html, I for text/code, I for images, I for archives, I for PDFs and I for video and audio files. @@ -364,7 +364,7 @@ hello-world plugin that describes this procedure. =head1 KEY BINDINGS -Key bindings are defined in the file F. Check this +Key bindings are defined in the file F<%rangerdir/config/rc.conf>. Check this file for a list of all key bindings. You can copy it to your local configuration directory with the --copy-config=rc option. @@ -1507,6 +1507,9 @@ being bound despite the corresponding line being removed from the user's copy of the configuration file. This behavior may be disabled with an environment variable (see also: B). Note: All other configuration files only read from one source; i.e. default OR user, not both. +F and F are additionally read from F if they +exist for system-wide configuration, user configuration overrides system +configuration which overrides the default configuration. When starting ranger with the B<--clean> option, it will not access or create any of these files. -- cgit 1.4.1-2-gfad0 From ff3040d91f3add73a0f4b5f938409eaa05364ab2 Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 8 May 2018 13:38:10 +0200 Subject: Revert gm mapping to /media The `/media/$USER` locations aren't finalized yet so we're holding off on that change. --- ranger/config/rc.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 5eaeae89..ae4c26f8 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -384,7 +384,7 @@ map gl cd -r . map gL cd -r %f map go cd /opt map gv cd /var -map gm eval fm.cd('/media/' + os.getenv('USER')) +map gm cd /media map gi eval fm.cd('/run/media/' + os.getenv('USER')) map gM cd /mnt map gs cd /srv -- cgit 1.4.1-2-gfad0 From bed6df84d4513bee939bc4ec7c3e3684c62b53b8 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 13 May 2018 21:37:16 +0200 Subject: rc.conf: document `freeze_files` setting --- ranger/config/rc.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 00dc02f8..56f1381a 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -257,6 +257,10 @@ set wrap_scroll false # directories, files and symlinks respectively. set global_inode_type_filter +# This setting allows to freeze the list of files to save I/O bandwidth. It +# should be 'false' during start-up, but you can toggle it by pressing F. +set freeze_files false + # =================================================================== # == Local Options # =================================================================== -- cgit 1.4.1-2-gfad0