diff options
-rw-r--r-- | examples/rc_emacs.conf | 4 | ||||
-rw-r--r-- | ranger/config/rc.conf | 4 | ||||
-rw-r--r-- | ranger/container/settings.py | 17 |
3 files changed, 19 insertions, 6 deletions
diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf index 5fd32ee2..d3707a12 100644 --- a/examples/rc_emacs.conf +++ b/examples/rc_emacs.conf @@ -34,10 +34,10 @@ set show_hidden false # With "multiple", ranger will ask only if you delete multiple files at once. set confirm_on_delete multiple -# Which script is used to generate file previews? +# Use non-default path for file preview script? # ranger ships with scope.sh, a script that calls external programs (see # README.md for dependencies) to preview images, archives, etc. -set preview_script ~/.config/ranger/scope.sh +#set preview_script ~/.config/ranger/scope.sh # Use the external preview script or display simple plain text or image previews? set use_preview_script true diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 38d1b47d..9af5a953 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -40,10 +40,10 @@ set show_hidden false # With "multiple", ranger will ask only if you delete multiple files at once. set confirm_on_delete multiple -# Which script is used to generate file previews? +# Use non-default path for file preview script? # ranger ships with scope.sh, a script that calls external programs (see # README.md for dependencies) to preview images, archives, etc. -set preview_script ~/.config/ranger/scope.sh +#set preview_script ~/.config/ranger/scope.sh # Use the external preview script or display simple plain text or image previews? set use_preview_script true diff --git a/ranger/container/settings.py b/ranger/container/settings.py index b58165ca..70e299c7 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -7,6 +7,7 @@ import re import os.path from inspect import isfunction +import ranger from ranger.ext.signals import SignalDispatcher from ranger.core.shared import FileManagerAware from ranger.gui.colorscheme import _colorscheme_name_to_class @@ -169,6 +170,19 @@ class Settings(SignalDispatcher, FileManagerAware): self.signal_emit('setopt', **kws) self.signal_emit('setopt.' + name, **kws) + def _get_default(self, name): + if name == 'preview_script': + if ranger.args.clean: + value = self.fm.relpath('data/scope.sh') + else: + value = self.fm.confpath('scope.sh') + if not os.path.exists(value): + value = self.fm.relpath('data/scope.sh') + else: + value = DEFAULT_VALUES[self.types_of(name)[0]] + + return value + def get(self, name, path=None): assert name in ALLOWED_SETTINGS, "No such setting: {0}!".format(name) if path: @@ -193,8 +207,7 @@ class Settings(SignalDispatcher, FileManagerAware): return self._tagsettings[tag][name] if name not in self._settings: - type_ = self.types_of(name)[0] - value = DEFAULT_VALUES[type_] + value = self._get_default(name) self._raw_set(name, value) self.__setattr__(name, value) return self._settings[name] |