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 6891ddc45b2cac79fdf51546b35167fe9fa0baa0 Mon Sep 17 00:00:00 2001 From: Adrià Farrés <14farresa@gmail.com> Date: Sun, 18 Mar 2018 02:39:27 +0100 Subject: Add delay after opening (quickly_executed) a file This is analogous to 6cae0ed but with files, not directories. --- ranger/config/commands.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index a3837d8e..97c42d74 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1393,6 +1393,8 @@ class scout(Command): self.fm.cd(pattern) else: self.fm.move(right=1) + if self.quickly_executed: + self.fm.block_input(0.5) if self.KEEP_OPEN in flags and thisdir != self.fm.thisdir: # reopen the console: -- cgit 1.4.1-2-gfad0 From f3d8c57b1fa24f0fa8b4c3d2e5f96bf6a2f9778e Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Wed, 28 Mar 2018 18:26:07 +0200 Subject: rc.conf: Use smartcase in :find and :filter --- ranger/config/rc.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index fe00c7c0..afe9ea42 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -274,8 +274,8 @@ alias qall quitall alias qall! quitall! alias setl setlocal -alias filter scout -prt -alias find scout -aeit +alias filter scout -prts +alias find scout -aets alias mark scout -mr alias unmark scout -Mr alias search scout -rs -- cgit 1.4.1-2-gfad0 From 4df9d0ec75d89eab0386f3dfabe5894c7d71657f Mon Sep 17 00:00:00 2001 From: Roman Pearah Date: Thu, 29 Mar 2018 18:33:22 -0400 Subject: Fix typo for pdf in rifle.conf Fixes #1128 --- ranger/config/rifle.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf index e2653a76..66e6a5cd 100644 --- a/ranger/config/rifle.conf +++ b/ranger/config/rifle.conf @@ -151,7 +151,7 @@ ext pdf, has atril, X, flag f = atril -- "$@" ext pdf, has okular, X, flag f = okular -- "$@" ext pdf, has epdfview, X, flag f = epdfview -- "$@" ext pdf, has qpdfview, X, flag f = qpdfview "$@" -ext pdf, has open, X, flat f = open "$@" +ext pdf, has open, X, flag f = open "$@" ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER" -- cgit 1.4.1-2-gfad0 From 703a9a20a640ee53080c9b3c405ae55f652b70e5 Mon Sep 17 00:00:00 2001 From: Chuancong Gao Date: Tue, 27 Mar 2018 14:45:39 -0700 Subject: Update VCS symbols --- ranger/colorschemes/default.py | 2 ++ ranger/gui/widgets/__init__.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py index c88cdc7c..350c8359 100644 --- a/ranger/colorschemes/default.py +++ b/ranger/colorschemes/default.py @@ -138,6 +138,8 @@ class Default(ColorScheme): attr &= ~bold if context.vcsconflict: fg = magenta + elif context.vcsuntracked: + fg = cyan elif context.vcschanged: fg = red elif context.vcsunknown: diff --git a/ranger/gui/widgets/__init__.py b/ranger/gui/widgets/__init__.py index 36292103..c8f1262b 100644 --- a/ranger/gui/widgets/__init__.py +++ b/ranger/gui/widgets/__init__.py @@ -12,11 +12,11 @@ class Widget(Displayable): 'conflict': ( 'X', ['vcsconflict']), 'untracked': ( - '+', ['vcschanged']), + '?', ['vcsuntracked']), 'deleted': ( '-', ['vcschanged']), 'changed': ( - '*', ['vcschanged']), + '+', ['vcschanged']), 'staged': ( '*', ['vcsstaged']), 'ignored': ( @@ -26,7 +26,7 @@ class Widget(Displayable): 'none': ( ' ', []), 'unknown': ( - '?', ['vcsunknown']), + '!', ['vcsunknown']), } vcsremotestatus_symb = { @@ -41,7 +41,7 @@ class Widget(Displayable): 'none': ( '⌂', ['vcsnone']), 'unknown': ( - '?', ['vcsunknown']), + '!', ['vcsunknown']), } ellipsis = {False: '~', True: '…'} -- cgit 1.4.1-2-gfad0 From 2288a40b45ccdc57d287648c96c5bbe378b95a6d Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 31 Mar 2018 16:01:59 +0200 Subject: ranger can select files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because `ranger somefile` used to invoke rifle but that moved to its own command `ranger somefile` seemed defunct. People expected ranger to select the file and were baffled when it crashed. Now the documentation using the verbiage "path" is no longer confusing/a lie because it just works™ (until it breaks). Fixes #930 --- ranger/core/tab.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ranger/core/tab.py b/ranger/core/tab.py index 1d5e69d4..7bb45d75 100644 --- a/ranger/core/tab.py +++ b/ranger/core/tab.py @@ -4,7 +4,7 @@ from __future__ import (absolute_import, division, print_function) import os -from os.path import abspath, normpath, join, expanduser, isdir +from os.path import abspath, normpath, join, expanduser, isdir, dirname import sys from ranger.container import settings @@ -123,9 +123,11 @@ class Tab(FileManagerAware, SettingsAware): # pylint: disable=too-many-instance # get the absolute path path = normpath(join(self.path, expanduser(path))) + selectfile = None if not isdir(path): - return False + selectfile = path + path = dirname(path) new_thisdir = self.fm.get_directory(path) try: @@ -155,6 +157,8 @@ class Tab(FileManagerAware, SettingsAware): # pylint: disable=too-many-instance self.thisdir.sort_directories_first = self.fm.settings.sort_directories_first self.thisdir.sort_reverse = self.fm.settings.sort_reverse self.thisdir.sort_if_outdated() + if selectfile: + self.thisdir.move_to_obj(selectfile) if previous and previous.path != path: self.thisfile = self.thisdir.pointed_obj else: -- cgit 1.4.1-2-gfad0 From 4d9d271d458aa65a69a897ab26a64771fd63f056 Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 31 Mar 2018 16:43:07 +0200 Subject: Added positional arguments section to manpage The optional positional argument "path" wasn't documented, changed the argument to "path ..." because you can provide more than one and documented what happens. Added a sentence to the `--selectfile` item pointing out it's superceded by the positional arguments. --- doc/ranger.1 | 17 ++++++++++++----- doc/ranger.pod | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index f362d263..7f307490 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.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.1" "05.03.2018" "ranger manual" +.TH RANGER 1 "ranger-1.9.1" "2018-03-31" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -145,7 +145,7 @@ ranger \- visual file manager [\fB\-\-choosedir\fR=\fItarget\fR] [\fB\-\-selectfile\fR=\fIfilepath\fR] [\fB\-\-show\-only\-dirs\fR] [\fB\-\-list\-unused\-keys\fR] [\fB\-\-list\-tagged\-files\fR=\fItag\fR] -[\fB\-\-profile\fR] [\fB\-\-cmd\fR=\fIcommand\fR] [\fIpath\fR] +[\fB\-\-profile\fR] [\fB\-\-cmd\fR=\fIcommand\fR] [\fIpath ...\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" ranger is a console file manager with \s-1VI\s0 key bindings. @@ -172,6 +172,12 @@ with other software. They are usually installed to The man page of \fIrifle\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" +.IX Header "POSITIONAL ARGUMENTS" +.IP "\fIpath ...\fR" 14 +.IX Item "path ..." +Each path will be opened in a tab and if the path is a file it will be selected. +Omitting this is equivalent to providing the current directory. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-d\fR, \fB\-\-debug\fR" 14 @@ -225,7 +231,8 @@ Allows you to pick a directory with ranger. When you exit ranger, it will write the last visited directory into \fItargetfile\fR. .IP "\fB\-\-selectfile\fR=\fItargetfile\fR" 14 .IX Item "--selectfile=targetfile" -Open ranger with \fItargetfile\fR selected. +Open ranger with \fItargetfile\fR selected. This is a legacy option, superseded by +the behavior for the \s-1POSITIONAL ARGUMENTS.\s0 .IP "\fB\-\-show\-only\-dirs\fR" 14 .IX Item "--show-only-dirs" Display only the directories. May be used in conjunction with @@ -599,7 +606,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 diff --git a/doc/ranger.pod b/doc/ranger.pod index 8599a1a6..470eaa7e 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -14,7 +14,7 @@ B [B<--version>] [B<--help>] [B<--debug>] [B<--clean>] [B<--choosedir>=I] [B<--selectfile>=I] [B<--show-only-dirs>] [B<--list-unused-keys>] [B<--list-tagged-files>=I] -[B<--profile>] [B<--cmd>=I] [I] +[B<--profile>] [B<--cmd>=I] [I] @@ -53,6 +53,18 @@ The section I of this man page contains further resources. +=head1 POSITIONAL ARGUMENTS + +=over 14 + +=item I + +Each path will be opened in a tab and if the path is a file it will be selected. +Omitting this is equivalent to providing the current directory. + + + + =head1 OPTIONS =over 14 @@ -117,7 +129,8 @@ write the last visited directory into I. =item B<--selectfile>=I -Open ranger with I selected. +Open ranger with I selected. This is a legacy option, superseded by +the behavior for the POSITIONAL ARGUMENTS. =item B<--show-only-dirs> -- cgit 1.4.1-2-gfad0 From dd10c159a9029e9401c55e2eab3e0a43ad097293 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 1 Apr 2018 11:26:21 +0200 Subject: Add docker support --- Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..acf2201a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +# Usage instructions: +# 1. "docker build -t ranger/ranger:latest ranger ." +# 2. "docker run -it ranger/ranger ranger" + +FROM debian + +RUN apt-get update +RUN apt-get install -y ranger -- cgit 1.4.1-2-gfad0 From b9e95cab9e166fbab3d452e91ed899c856af859e Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 1 Apr 2018 11:36:36 +0200 Subject: Fix documentation for docker integration --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index acf2201a..801725b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Usage instructions: -# 1. "docker build -t ranger/ranger:latest ranger ." +# 1. "docker build -t ranger/ranger:latest ." # 2. "docker run -it ranger/ranger ranger" FROM debian -- cgit 1.4.1-2-gfad0 From 47cec22449621c531f6ac042cc14e6309289d747 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 1 Apr 2018 13:02:01 +0200 Subject: Dockerfile: Avoid creating unnecessary layers --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 801725b0..ecb2be6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,5 +4,4 @@ FROM debian -RUN apt-get update -RUN apt-get install -y ranger +RUN apt-get update && apt-get install -y ranger -- cgit 1.4.1-2-gfad0 From a938392ddb43169712dda6809f3b55e396c46dfb Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 1 Apr 2018 13:21:17 +0200 Subject: Apply patch from debian package: 0004-fix-type-in-manpage.patch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: Fix typo in manpage Author: Mateusz Łukasik --- doc/ranger.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index f362d263..745f1032 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -702,7 +702,7 @@ in ranger. .IP "automatically_count_files [bool]" 4 .IX Item "automatically_count_files [bool]" Should ranger count and display the number of files in each directory -as soon as it's visible? This gets slow with remote file sytems. Turning it +as soon as it's visible? This gets slow with remote file systems. Turning it off will still allow you to see the number of files after entering the directory. .IP "autosave_bookmarks [bool]" 4 -- cgit 1.4.1-2-gfad0 From e09e2648752d24361e94d9bba66c5a1049fd2fb5 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 1 Apr 2018 14:46:39 +0200 Subject: Add docker entrypoint --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ecb2be6f..36ad0a95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ # Usage instructions: # 1. "docker build -t ranger/ranger:latest ." -# 2. "docker run -it ranger/ranger ranger" +# 2. "docker run -it ranger/ranger" FROM debian RUN apt-get update && apt-get install -y ranger +ENTRYPOINT ["ranger"] -- cgit 1.4.1-2-gfad0 From 00366b27e12023d31dc445660df05000cc47a114 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 1 Apr 2018 23:32:00 +0200 Subject: examples: Add plugin_avfs.py, a simple AVFS integration http://avf.sourceforge.net/ --- examples/plugin_avfs.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/plugin_avfs.py diff --git a/examples/plugin_avfs.py b/examples/plugin_avfs.py new file mode 100644 index 00000000..6910533c --- /dev/null +++ b/examples/plugin_avfs.py @@ -0,0 +1,31 @@ +# Tested with ranger 1.9.1 +# +# A very simple and possibly buggy support for AVFS +# (http://avf.sourceforge.net/), that allows ranger to handle +# archives. +# +# Run `:avfs' to browse the selected archive. + +from __future__ import (absolute_import, division, print_function) + +from ranger.api.commands import Command +import os +import os.path + +class avfs(Command): + avfs_root = os.path.join(os.environ["HOME"], ".avfs") + avfs_suffix = "#" + + def execute(self): + if os.path.isdir(self.avfs_root): + archive_directory = "".join([ + self.avfs_root, + self.fm.thisfile.path, + self.avfs_suffix, + ]) + if os.path.isdir(archive_directory): + self.fm.cd(archive_directory) + else: + self.fm.notify("This file cannot be handled by avfs.", bad=True) + else: + self.fm.notify("Install `avfs' and run `mountavfs' first.", bad=True) -- cgit 1.4.1-2-gfad0 From 8a9ede42a95b703daa35364aca32b672cfb680f7 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 1 Apr 2018 23:56:01 +0200 Subject: Fix pylint --- examples/plugin_avfs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/plugin_avfs.py b/examples/plugin_avfs.py index 6910533c..07968a03 100644 --- a/examples/plugin_avfs.py +++ b/examples/plugin_avfs.py @@ -8,11 +8,13 @@ from __future__ import (absolute_import, division, print_function) -from ranger.api.commands import Command import os import os.path -class avfs(Command): +from ranger.api.commands import Command + + +class avfs(Command): # pylint: disable=invalid-name avfs_root = os.path.join(os.environ["HOME"], ".avfs") avfs_suffix = "#" -- cgit 1.4.1-2-gfad0 From 98a176469faa51a678f5ac703e0e11c251425fdd Mon Sep 17 00:00:00 2001 From: toonn Date: Mon, 2 Apr 2018 22:40:54 +0200 Subject: Add a TODO on deprecating --selectfile --- ranger/core/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ranger/core/main.py b/ranger/core/main.py index 4adea918..2ae4d16b 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -89,6 +89,7 @@ def main( SettingsAware.settings_set(Settings()) + # TODO: deprecate --selectfile if args.selectfile: args.selectfile = os.path.abspath(args.selectfile) args.paths.insert(0, os.path.dirname(args.selectfile)) -- cgit 1.4.1-2-gfad0 From 3c430ba0f1b3fe2e17225788866f37bcd1f85c3b Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 3 Apr 2018 14:10:35 +0200 Subject: Document change in :cd behavior Added a sentence about the file selecting behavior of `:cd` to the docstring and the manpage. Added missing `=back` to POSITIONAL ARGUMENTS section in the manpage. --- doc/ranger.1 | 12 ++++++------ doc/ranger.pod | 10 ++++++---- ranger/config/commands.py | 3 ++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 7f307490..bd6116d1 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.1" "2018-03-31" "ranger manual" +.TH RANGER 1 "ranger-1.9.1" "2018-04-03" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -996,7 +996,7 @@ ranger. For your convenience, this is a list of the \*(L"public\*(R" commands i .Vb 10 \& alias [newcommand] [oldcommand] \& bulkrename -\& cd [directory] +\& cd [path] \& chain command1[; command2[; command3...]] \& chmod octal_number \& cmap key command @@ -1072,10 +1072,10 @@ renaming according to the changes you did in the file. .Sp This shell script is opened in an editor for you to review. After you close it, it will be executed. -.IP "cd [\fIdirectory\fR]" 2 -.IX Item "cd [directory]" -The cd command changes the directory. The command \f(CW\*(C`:cd \-\*(C'\fR is equivalent to -typing ``. +.IP "cd [\fIpath\fR]" 2 +.IX Item "cd [path]" +The cd command changes the directory. If path is a file, selects that file. +The command \f(CW\*(C`:cd \-\*(C'\fR is equivalent to typing ``. .IP "chain \fIcommand1\fR[; \fIcommand2\fR[; \fIcommand3\fR...]]" 2 .IX Item "chain command1[; command2[; command3...]]" Combines multiple commands into one, separated by semicolons. diff --git a/doc/ranger.pod b/doc/ranger.pod index 470eaa7e..4b0e90b1 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -62,6 +62,8 @@ The section I of this man page contains further resources. Each path will be opened in a tab and if the path is a file it will be selected. Omitting this is equivalent to providing the current directory. +=back + @@ -1033,7 +1035,7 @@ ranger. For your convenience, this is a list of the "public" commands including alias [newcommand] [oldcommand] bulkrename - cd [directory] + cd [path] chain command1[; command2[; command3...]] chmod octal_number cmap key command @@ -1113,10 +1115,10 @@ renaming according to the changes you did in the file. This shell script is opened in an editor for you to review. After you close it, it will be executed. -=item cd [I] +=item cd [I] -The cd command changes the directory. The command C<:cd -> is equivalent to -typing ``. +The cd command changes the directory. If path is a file, selects that file. +The command C<:cd -> is equivalent to typing ``. =item chain I[; I[; I...]] diff --git a/ranger/config/commands.py b/ranger/config/commands.py index a3837d8e..2f1480b9 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -120,9 +120,10 @@ class echo(Command): class cd(Command): - """:cd [-r] + """:cd [-r] The cd command changes the directory. + If the path is a file, selects that file. The command 'cd -' is equivalent to typing ``. Using the option "-r" will get you to the real path. """ -- cgit 1.4.1-2-gfad0 From e79d929b7e48f4cc2a1ddcf0b942a46c21b56c13 Mon Sep 17 00:00:00 2001 From: mxovd Date: Fri, 13 Apr 2018 21:57:00 +0900 Subject: Enter directory before executing command arguments --- ranger/core/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ranger/core/main.py b/ranger/core/main.py index 4adea918..32734442 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -182,6 +182,7 @@ def main( fm.select_file(args.selectfile) if args.cmd: + fm.enter_dir(fm.thistab.path) for command in args.cmd: fm.execute_console(command) -- cgit 1.4.1-2-gfad0 From 107b72e74cf740489c8eae7464b9ee24dcaeed6e Mon Sep 17 00:00:00 2001 From: toonn Date: Mon, 16 Apr 2018 12:38:01 +0200 Subject: Add support for mutool pdf previews in scope.sh --- README.md | 2 +- doc/ranger.1 | 10 +++++----- doc/ranger.pod | 2 +- ranger/data/scope.sh | 1 + 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ef644ae6..df17f731 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Optional, for enhanced file previews (with `scope.sh`): * `highlight` or `pygmentize` for syntax highlighting of code * `atool`, `bsdtar` and/or `unrar` for previews of archives * `lynx`, `w3m` or `elinks` for previews of html pages -* `pdftotext` for pdf previews +* `pdftotext` or `mutool` for pdf previews * `transmission-show` for viewing bit-torrent information * `mediainfo` or `exiftool` for viewing information about media files * `odt2txt` for OpenDocument text files (`odt`, `ods`, `odp` and `sxw`) diff --git a/doc/ranger.1 b/doc/ranger.1 index 745f1032..71310541 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.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.1" "05.03.2018" "ranger manual" +.TH RANGER 1 "ranger-1.9.1" "2018-04-16" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -270,7 +270,7 @@ scripts by setting the option \f(CW\*(C`use_preview_script\*(C'\fR and \f(CW\*(C This default script is \fI~/.config/ranger/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. +\&\fIpdftotext\fR or \fImutool\fR for PDFs and \fImediainfo\fR for video and audio files. .PP Install these programs (just the ones you need) and scope.sh will automatically use them. @@ -599,7 +599,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 @@ -702,7 +702,7 @@ in ranger. .IP "automatically_count_files [bool]" 4 .IX Item "automatically_count_files [bool]" Should ranger count and display the number of files in each directory -as soon as it's visible? This gets slow with remote file systems. Turning it +as soon as it's visible? This gets slow with remote file sytems. Turning it off will still allow you to see the number of files after entering the directory. .IP "autosave_bookmarks [bool]" 4 diff --git a/doc/ranger.pod b/doc/ranger.pod index 8599a1a6..41bafdd3 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -177,7 +177,7 @@ scripts by setting the option C and C to true This default script is F<~/.config/ranger/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. +I or I for PDFs and I for video and audio files. Install these programs (just the ones you need) and scope.sh will automatically use them. diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 540a910e..f7a0f589 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -61,6 +61,7 @@ handle_extension() { pdf) # Preview as text conversion pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - && exit 5 + mutool draw -F txt -i -- "${FILE_PATH}" 1-10 && exit 5 exiftool "${FILE_PATH}" && exit 5 exit 1;; -- cgit 1.4.1-2-gfad0 From 83d0e61abfb80c609c5686be5fcf0b7208571d82 Mon Sep 17 00:00:00 2001 From: toonn Date: Mon, 16 Apr 2018 12:39:38 +0200 Subject: Add a pass through fmt to pdf previews. This reformats the previews to fit the preview column width making previews more readable in most cases. --- ranger/data/scope.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index f7a0f589..25251533 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -60,8 +60,8 @@ handle_extension() { # PDF pdf) # Preview as text conversion - pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - && exit 5 - mutool draw -F txt -i -- "${FILE_PATH}" 1-10 && exit 5 + pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | fmt -w ${PV_WIDTH} && exit 5 + mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | fmt -w ${PV_WIDTH} && exit 5 exiftool "${FILE_PATH}" && exit 5 exit 1;; -- cgit 1.4.1-2-gfad0 From f6af1ebad94b902d61f73b00978272018e2ef438 Mon Sep 17 00:00:00 2001 From: toonn Date: Mon, 16 Apr 2018 14:13:49 +0200 Subject: Refix typo "sytem" --- doc/ranger.1 | 2 +- doc/ranger.pod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 71310541..238aafd5 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -702,7 +702,7 @@ in ranger. .IP "automatically_count_files [bool]" 4 .IX Item "automatically_count_files [bool]" Should ranger count and display the number of files in each directory -as soon as it's visible? This gets slow with remote file sytems. Turning it +as soon as it's visible? This gets slow with remote file systems. Turning it off will still allow you to see the number of files after entering the directory. .IP "autosave_bookmarks [bool]" 4 diff --git a/doc/ranger.pod b/doc/ranger.pod index 41bafdd3..0a34209a 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -678,7 +678,7 @@ in ranger. =item automatically_count_files [bool] Should ranger count and display the number of files in each directory -as soon as it's visible? This gets slow with remote file sytems. Turning it +as soon as it's visible? This gets slow with remote file systems. Turning it off will still allow you to see the number of files after entering the directory. -- cgit 1.4.1-2-gfad0 From ae7668078374a6ef30d3a45b29746d7315223761 Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 19 Apr 2018 09:04:04 +0200 Subject: Save all the tabs, including the active tab. Remove the check preventing the active tab from being saved. Fixes #883 --- ranger/core/fm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/core/fm.py b/ranger/core/fm.py index c55a3922..d85dd48c 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -424,5 +424,5 @@ class FM(Actions, # pylint: disable=too-many-instance-attributes if not ranger.args.clean and self.settings.save_tabs_on_exit and len(self.tabs) > 1: with open(self.datapath('tabs'), 'a') as fobj: # Don't save active tab since launching ranger changes the active tab - fobj.write('\0'.join(v.path for t, v in self.tabs.items() - if t != self.current_tab) + '\0\0') + fobj.write('\0'.join(v.path for t, v in self.tabs.items()) + + '\0\0') -- cgit 1.4.1-2-gfad0 From ec825cb15005673b9f9092547dbc42bc35ae60bf Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 19 Apr 2018 12:51:58 +0200 Subject: Lift the limit on tabs for :tab_new --- ranger/core/actions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 6bbb35aa..a3aad746 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1186,10 +1186,10 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m def tab_new(self, path=None, narg=None): if narg: return self.tab_open(narg, path) - for i in range(1, 10): - if i not in self.tabs: - return self.tab_open(i, path) - return None + i = 1 + while i in self.tabs: + i += 1 + return self.tab_open(i, path) def tab_switch(self, path, create_directory=False): """Switches to tab of given path, opening a new tab as necessary. -- cgit 1.4.1-2-gfad0 From a11c723d0ebc4152d0878a79df25c2282e70c6c5 Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 19 Apr 2018 12:52:47 +0200 Subject: Remove the implicit assumption tabs are numbers. Only get_tab_list() implicitly assumed that tab keys are numbers, or at least homogeneous. This assumption has now been removed by using a simple ordering class that orders numbers as expected but anything else lexically. --- ranger/core/actions.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index a3aad746..3e488159 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1237,7 +1237,18 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m def get_tab_list(self): assert self.tabs, "There must be at least 1 tab at all times" - return sorted(self.tabs) + + class NaturalOrder(object): # pylint: disable=too-few-public-methods + def __init__(self, obj): + self.obj = obj + + def __lt__(self, other): + try: + return self.obj < other.obj + except TypeError: + return str(self.obj) < str(other.obj) + + return sorted(self.tabs, key=NaturalOrder) # -------------------------- # -- Overview of internals -- cgit 1.4.1-2-gfad0 From b1d93d5cfc8338a429d7af0b685199c0b0315854 Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 21 Apr 2018 19:17:46 +0200 Subject: MISSION CRITICAL update to adhere to pep8 Pep8 was changed to recommend breaking lines *before* rather than after binary operators. This patch makes everything right with the universe. Fixes #1145 --- ranger/container/directory.py | 5 +++-- ranger/core/main.py | 4 ++-- ranger/ext/direction.py | 4 ++-- ranger/ext/img_display.py | 16 ++++++++-------- ranger/gui/widgets/browsercolumn.py | 4 ++-- ranger/gui/widgets/view_base.py | 4 ++-- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ranger/container/directory.py b/ranger/container/directory.py index 18b1687c..e281e6c9 100644 --- a/ranger/container/directory.py +++ b/ranger/container/directory.py @@ -338,8 +338,9 @@ class Directory( # pylint: disable=too-many-instance-attributes,too-many-public dirlist = [ os.path.join("/", dirpath, d) for d in dirnames - if self.flat == -1 or - (dirpath.count(os.path.sep) - mypath.count(os.path.sep)) <= self.flat + if self.flat == -1 + or (dirpath.count(os.path.sep) + - mypath.count(os.path.sep)) <= self.flat ] filelist += dirlist filelist += [os.path.join("/", dirpath, f) for f in filenames] diff --git a/ranger/core/main.py b/ranger/core/main.py index 4adea918..9a7a554d 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -397,8 +397,8 @@ def load_settings( # pylint: disable=too-many-locals,too-many-branches,too-many 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): + if (os.environ.get('RANGER_LOAD_DEFAULT_RC', 'TRUE').upper() != 'FALSE' + or not custom_conf_is_readable): fm.source(default_conf) if custom_conf_is_readable: fm.source(custom_conf) diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py index 7df45556..33ebb604 100644 --- a/ranger/ext/direction.py +++ b/ranger/ext/direction.py @@ -97,8 +97,8 @@ class Direction(dict): return self.get('cycle') in (True, 'true', 'on', 'yes') def one_indexed(self): - return ('one_indexed' in self and - self.get('one_indexed') in (True, 'true', 'on', 'yes')) + return ('one_indexed' in self + and self.get('one_indexed') in (True, 'true', 'on', 'yes')) def multiply(self, n): for key in ('up', 'right', 'down', 'left'): diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 67941e27..78d71cb2 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -434,20 +434,20 @@ class URXVTImageDisplayer(ImageDisplayer, FileManagerAware): pct_width, pct_height = self._get_sizes() sys.stdout.write( - self.display_protocol + - path + - ";{pct_width}x{pct_height}+{pct_x}+{pct_y}:op=keep-aspect".format( + self.display_protocol + + path + + ";{pct_width}x{pct_height}+{pct_x}+{pct_y}:op=keep-aspect".format( pct_width=pct_width, pct_height=pct_height, pct_x=pct_x, pct_y=pct_y - ) + - self.close_protocol + ) + + self.close_protocol ) sys.stdout.flush() def clear(self, start_x, start_y, width, height): sys.stdout.write( - self.display_protocol + - ";100x100+1000+1000" + - self.close_protocol + self.display_protocol + + ";100x100+1000+1000" + + self.close_protocol ) sys.stdout.flush() diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index b3272cbc..cf322409 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -318,8 +318,8 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes text = current_linemode.filetitle(drawn, metadata) - if drawn.marked and (self.main_column or - self.settings.display_tags_in_all_columns): + if drawn.marked and (self.main_column + or self.settings.display_tags_in_all_columns): text = " " + text # Computing predisplay data. predisplay contains a list of lists diff --git a/ranger/gui/widgets/view_base.py b/ranger/gui/widgets/view_base.py index 80061004..4493443e 100644 --- a/ranger/gui/widgets/view_base.py +++ b/ranger/gui/widgets/view_base.py @@ -72,8 +72,8 @@ class ViewBase(Widget, DisplayableContainer): # pylint: disable=too-many-instan sorted_bookmarks = sorted( ( item for item in self.fm.bookmarks - if self.fm.settings.show_hidden_bookmarks or - '/.' not in item[1].path + if self.fm.settings.show_hidden_bookmarks + or '/.' not in item[1].path ), key=lambda t: t[0].lower(), ) -- cgit 1.4.1-2-gfad0 From 4e99ab88a506dff9c8ec86e2a2b43373559a1c70 Mon Sep 17 00:00:00 2001 From: hektr <31568062+hektr@users.noreply.github.com> Date: Tue, 24 Apr 2018 14:01:40 +0300 Subject: gwenview has been added as image viewer Gwenview is standart image viewer on kde desktop, so it would be nice to have this program in default ranger associations. It's not console program, but it's faster comparing with gimp. --- ranger/config/rifle.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf index 66e6a5cd..f0b8841d 100644 --- a/ranger/config/rifle.conf +++ b/ranger/config/rifle.conf @@ -183,6 +183,7 @@ mime ^image, has eog, X, flag f = eog -- "$@" mime ^image, has eom, X, flag f = eom -- "$@" mime ^image, has nomacs, X, flag f = nomacs -- "$@" mime ^image, has geeqie, X, flag f = geeqie -- "$@" +mime ^image, has gwenview X, flag f = gwenview -- "$@" mime ^image, has gimp, X, flag f = gimp -- "$@" ext xcf, X, flag f = gimp -- "$@" -- cgit 1.4.1-2-gfad0 From 892db3a0a6f3bc4d805ef09d2fa7ca529f12c12c Mon Sep 17 00:00:00 2001 From: hektr <31568062+hektr@users.noreply.github.com> Date: Tue, 24 Apr 2018 14:03:25 +0300 Subject: mistype --- ranger/config/rifle.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf index f0b8841d..b1a9bb71 100644 --- a/ranger/config/rifle.conf +++ b/ranger/config/rifle.conf @@ -183,7 +183,7 @@ mime ^image, has eog, X, flag f = eog -- "$@" mime ^image, has eom, X, flag f = eom -- "$@" mime ^image, has nomacs, X, flag f = nomacs -- "$@" mime ^image, has geeqie, X, flag f = geeqie -- "$@" -mime ^image, has gwenview X, flag f = gwenview -- "$@" +mime ^image, has gwenview, X, flag f = gwenview -- "$@" mime ^image, has gimp, X, flag f = gimp -- "$@" ext xcf, X, flag f = gimp -- "$@" -- cgit 1.4.1-2-gfad0 From edd4f71863840f07e0e7df5c641f2a168f605573 Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 24 Apr 2018 16:09:34 +0200 Subject: Fix mapping is variously interpreted as ^H or ^?, by copying the mapping to both and it should work either case. Fixes #1083 --- ranger/config/rc.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index afe9ea42..9095de3d 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -507,6 +507,8 @@ map zc set collapse_preview! map zd set sort_directories_first! map zh set show_hidden! map set show_hidden! +copymap +copymap map zI set flushinput! map zi set preview_images! map zm set mouse_enabled! -- 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 From 0370e98e0df4286b8c87a2b4c0d0c35f83dad3e8 Mon Sep 17 00:00:00 2001 From: toonn Date: Mon, 14 May 2018 11:27:26 +0200 Subject: Add ignore for `W503` to `.flake8` to follow new pep8 --- .flake8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index f5072c08..b77e4e6c 100644 --- a/.flake8 +++ b/.flake8 @@ -1,3 +1,3 @@ [flake8] max-line-length = 99 -ignore = E221 +ignore = E221,W503 -- cgit 1.4.1-2-gfad0 From 5fcaeafa4001584211c83c5a28dc3b4bd15bdb1f Mon Sep 17 00:00:00 2001 From: Rodrigo Stuchi Date: Mon, 14 May 2018 23:03:44 -0300 Subject: Yank name without extension yw map to yank a filename without extension closes #1162 removed unnecessary semicolon --- ranger/config/commands.py | 8 +++++++- ranger/config/rc.conf | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 8d444dd6..63331c8c 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1725,6 +1725,7 @@ class yank(Command): modes = { '': 'basename', + 'name_no_ext': 'splitext', 'name': 'basename', 'dir': 'dirname', 'path': 'path', @@ -1757,7 +1758,12 @@ class yank(Command): clipboard_commands = clipboards() - selection = self.get_selection_attr(self.modes[self.arg(1)]) + mode = self.modes[self.arg(1)] + if mode == "splitext": + selection = [os.path.splitext(self.get_selection_attr('basename')[0])[0]] + else: + selection = self.get_selection_attr(mode) + new_clipboard_contents = "\n".join(selection) for command in clipboard_commands: process = subprocess.Popen(command, universal_newlines=True, diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 342c22d9..f80f699b 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -413,6 +413,7 @@ map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh map yp yank path map yd yank dir map yn yank name +map yw yank name_no_ext # Filesystem Operations map = chmod -- cgit 1.4.1-2-gfad0 From 81bd1f8a2cf8f072227162922a64a0b6c6b2d932 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 15 May 2018 22:56:13 +0200 Subject: rc.conf: rename `yank name_no_ext` command to `yank name_without_extension` --- ranger/config/commands.py | 2 +- ranger/config/rc.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 63331c8c..dc987051 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1725,7 +1725,7 @@ class yank(Command): modes = { '': 'basename', - 'name_no_ext': 'splitext', + 'name_without_extension': 'splitext', 'name': 'basename', 'dir': 'dirname', 'path': 'path', diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index f80f699b..3725c400 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -413,7 +413,7 @@ map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh map yp yank path map yd yank dir map yn yank name -map yw yank name_no_ext +map yw yank name_without_extension # Filesystem Operations map = chmod -- cgit 1.4.1-2-gfad0 From 8a8ad05bb64e595fe8ac0196e850445ea704f269 Mon Sep 17 00:00:00 2001 From: Rodrigo Stuchi Date: Tue, 15 May 2018 18:53:57 -0300 Subject: Fixed yank name without extension in multiple files changed map `yw` to `y.` ref.: #1174 --- ranger/config/commands.py | 3 ++- ranger/config/rc.conf | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index a2492369..bf03069f 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1762,7 +1762,8 @@ class yank(Command): mode = self.modes[self.arg(1)] if mode == "splitext": - selection = [os.path.splitext(self.get_selection_attr('basename')[0])[0]] + selection = [os.path.splitext(item)[0] for item in + self.get_selection_attr('basename')] else: selection = self.get_selection_attr(mode) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 3725c400..6b0802bb 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -413,7 +413,7 @@ map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh map yp yank path map yd yank dir map yn yank name -map yw yank name_without_extension +map y. yank name_without_extension # Filesystem Operations map = chmod -- cgit 1.4.1-2-gfad0 From 6eae1e1480df9d66e7d851b332ce636a7d95af11 Mon Sep 17 00:00:00 2001 From: Chuancong Gao Date: Tue, 15 May 2018 15:06:15 -0700 Subject: Fix bug for "Improve VCS symbols" #1123 --- ranger/gui/context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/gui/context.py b/ranger/gui/context.py index d8d1957c..96849686 100644 --- a/ranger/gui/context.py +++ b/ranger/gui/context.py @@ -23,7 +23,7 @@ CONTEXT_KEYS = [ 'keybuffer', 'infostring', 'vcsfile', 'vcsremote', 'vcsinfo', 'vcscommit', 'vcsdate', - 'vcsconflict', 'vcschanged', 'vcsunknown', 'vcsignored', + 'vcsconflict', 'vcschanged', 'vcsunknown', 'vcsignored', 'vcsuntracked', 'vcsstaged', 'vcssync', 'vcsnone', 'vcsbehind', 'vcsahead', 'vcsdiverged' ] -- cgit 1.4.1-2-gfad0 From 591c7ce7c2d406e9e7de506c9ee49f8b6468539e Mon Sep 17 00:00:00 2001 From: Rodrigo Stuchi Date: Tue, 15 May 2018 21:51:20 -0300 Subject: remove unnecessary if statement, uses lazy_property --- ranger/config/commands.py | 8 ++------ ranger/container/fsobject.py | 6 +++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index bf03069f..7f5fc764 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1727,7 +1727,7 @@ class yank(Command): modes = { '': 'basename', - 'name_without_extension': 'splitext', + 'name_without_extension': 'basename_without_extension', 'name': 'basename', 'dir': 'dirname', 'path': 'path', @@ -1761,11 +1761,7 @@ class yank(Command): clipboard_commands = clipboards() mode = self.modes[self.arg(1)] - if mode == "splitext": - selection = [os.path.splitext(item)[0] for item in - self.get_selection_attr('basename')] - else: - selection = self.get_selection_attr(mode) + selection = self.get_selection_attr(mode) new_clipboard_contents = "\n".join(selection) for command in clipboard_commands: diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py index 0c9f70f6..37151ecf 100644 --- a/ranger/container/fsobject.py +++ b/ranger/container/fsobject.py @@ -6,7 +6,7 @@ from __future__ import (absolute_import, division, print_function) import re from grp import getgrgid from os import lstat, stat -from os.path import abspath, basename, dirname, realpath, relpath +from os.path import abspath, basename, dirname, realpath, relpath, splitext from pwd import getpwuid from time import time @@ -170,6 +170,10 @@ class FileSystemObject( # pylint: disable=too-many-instance-attributes,too-many basename_list += [(string, 0)] return basename_list + @lazy_property + def basename_without_extension(self): + return splitext(self.basename)[0] + @lazy_property def safe_basename(self): return self.basename.translate(_SAFE_STRING_TABLE) -- cgit 1.4.1-2-gfad0 From 11549e2c0c73a8a0bb543801af4e134b3e076095 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 16 May 2018 11:57:15 +0200 Subject: Revert "ranger can select files" Due to this commit, pressing `` on a file does nothing. Normally it should open the file. Until this is fixed, I'll remove this commit to restore this basic functionality. Unfortunately, the revert makes ranger crash when run like `ranger `, but this is a much less frequent use case, so the revert is still warranted. This reverts commit 2288a40b45ccdc57d287648c96c5bbe378b95a6d. --- ranger/core/tab.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ranger/core/tab.py b/ranger/core/tab.py index 7bb45d75..1d5e69d4 100644 --- a/ranger/core/tab.py +++ b/ranger/core/tab.py @@ -4,7 +4,7 @@ from __future__ import (absolute_import, division, print_function) import os -from os.path import abspath, normpath, join, expanduser, isdir, dirname +from os.path import abspath, normpath, join, expanduser, isdir import sys from ranger.container import settings @@ -123,11 +123,9 @@ class Tab(FileManagerAware, SettingsAware): # pylint: disable=too-many-instance # get the absolute path path = normpath(join(self.path, expanduser(path))) - selectfile = None if not isdir(path): - selectfile = path - path = dirname(path) + return False new_thisdir = self.fm.get_directory(path) try: @@ -157,8 +155,6 @@ class Tab(FileManagerAware, SettingsAware): # pylint: disable=too-many-instance self.thisdir.sort_directories_first = self.fm.settings.sort_directories_first self.thisdir.sort_reverse = self.fm.settings.sort_reverse self.thisdir.sort_if_outdated() - if selectfile: - self.thisdir.move_to_obj(selectfile) if previous and previous.path != path: self.thisfile = self.thisdir.pointed_obj else: -- cgit 1.4.1-2-gfad0