diff options
author | hut <hut@lavabit.com> | 2010-06-04 16:52:30 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-06-04 16:52:30 +0200 |
commit | dd7f4e5c27fc04cb2abb93e659c3ec1c4411a662 (patch) | |
tree | e6822b7d7d6e1e538ba9ed0094114a661b2d33da | |
parent | 43e0f44a4788f3251d5f2ad7c1bfeff014353aba (diff) | |
download | ranger-dd7f4e5c27fc04cb2abb93e659c3ec1c4411a662.tar.gz |
added preview_script option
-rw-r--r-- | ranger/api/options.py | 1 | ||||
-rw-r--r-- | ranger/defaults/options.py | 3 | ||||
-rw-r--r-- | ranger/fsobject/file.py | 15 | ||||
-rw-r--r-- | ranger/shared/settings.py | 1 |
4 files changed, 14 insertions, 6 deletions
diff --git a/ranger/api/options.py b/ranger/api/options.py index ee947b39..aee6150b 100644 --- a/ranger/api/options.py +++ b/ranger/api/options.py @@ -17,3 +17,4 @@ import re from re import compile as regexp from ranger.api import * from ranger.gui import color +from ranger import relpath, relpath_conf diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py index 23752d97..feb02a58 100644 --- a/ranger/defaults/options.py +++ b/ranger/defaults/options.py @@ -39,6 +39,9 @@ hidden_filter = regexp( r'^\.|\.(?:pyc|pyo|bak|swp)$|~$|lost\+found') show_hidden = False +# Which script is used to generate file previews? +preview_script = relpath('ext/preview.sh') # relative to rangers path + # Show dotfiles in the bookmark preview box? show_hidden_bookmarks = True diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py index 25902f57..cd5b37ff 100644 --- a/ranger/fsobject/file.py +++ b/ranger/fsobject/file.py @@ -92,10 +92,13 @@ class File(FileSystemObject): return True def get_preview_source(self): - try: - p = Popen([relpath('ext/preview.sh'), self.path], - stdout=PIPE, stderr=devnull) - if not p.poll(): + if self.fm.settings.preview_script: + try: + p = Popen([self.fm.settings.preview_script, self.path], + stdout=PIPE, stderr=devnull) + if p.poll(): # nonzero exit code + return None return p.stdout - except: - return open(self.path, 'r') + except: + pass + return open(self.path, 'r') diff --git a/ranger/shared/settings.py b/ranger/shared/settings.py index f5d8614f..24aea39c 100644 --- a/ranger/shared/settings.py +++ b/ranger/shared/settings.py @@ -41,6 +41,7 @@ ALLOWED_SETTINGS = { 'tilde_in_titlebar': bool, 'max_history_size': (int, type(None)), 'max_console_history_size': (int, type(None)), + 'preview_script': (str, type(None)), 'scroll_offset': int, 'preview_files': bool, 'preview_directories': bool, |