diff options
-rw-r--r-- | doc/ranger.1 | 14 | ||||
-rw-r--r-- | doc/ranger.pod | 9 | ||||
-rw-r--r-- | doc/rifle.1 | 4 | ||||
-rwxr-xr-x | ranger/config/commands.py | 7 | ||||
-rw-r--r-- | ranger/config/rc.conf | 4 | ||||
-rw-r--r-- | ranger/container/bookmarks.py | 17 | ||||
-rw-r--r-- | ranger/container/settings.py | 13 | ||||
-rw-r--r-- | ranger/core/fm.py | 6 | ||||
-rw-r--r-- | ranger/core/main.py | 6 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 6 |
10 files changed, 65 insertions, 21 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1 index 61bc31a3..f96c7f20 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.0b5" "09/17/2017" "ranger manual" +.TH RANGER 1 "ranger-1.9.0b5" "10/01/2017" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -421,8 +421,8 @@ By default, all the flags are off unless specified otherwise in the An uppercase flag negates the effect: \*(L"ffcccFsf\*(R" is equivalent to \*(L"cs\*(R". .PP The terminal program name for the \*(L"t\*(R" flag is taken from the environment -variable \f(CW$TERMCMD\fR. If it doesn't exist, it tries to extract it from \f(CW$TERM\fR and -uses \*(L"xterm\*(R" as a fallback if that fails. +variable \f(CW$TERMCMD\fR. If it doesn't exist, it tries to extract it from \f(CW$TERM\fR, +uses \*(L"x\-terminal-emulator\*(R" as a fallback, and then \*(L"xterm\*(R" if that fails. .PP Examples: \f(CW\*(C`:open_with c\*(C'\fR will open the file that you currently point at, even if you have selected other files. \f(CW\*(C`:shell \-w df\*(C'\fR will run \*(L"df\*(R" and wait for @@ -595,7 +595,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 @@ -847,6 +847,10 @@ to disable this feature. Which script should handle generating previews? If the file doesn't exist, or use_preview_script is off, ranger will handle previews itself by just printing the content. +.IP "save_backtick_bookmark [bool]" 4 +.IX Item "save_backtick_bookmark [bool]" +Save the \f(CW\*(C`\`\*(C'\fR bookmark to disk. This bookmark is used to switch to the last +directory by typing \f(CW\*(C`\`\`\*(C'\fR. .IP "save_console_history [bool]" 4 .IX Item "save_console_history [bool]" Should the console history be saved on exit? If disabled, the console history diff --git a/doc/ranger.pod b/doc/ranger.pod index 5d72ba1c..310ab1fd 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -321,8 +321,8 @@ F<rifle.conf> configuration file. You can specify as many flags as you want. An uppercase flag negates the effect: "ffcccFsf" is equivalent to "cs". The terminal program name for the "t" flag is taken from the environment -variable $TERMCMD. If it doesn't exist, it tries to extract it from $TERM and -uses "xterm" as a fallback if that fails. +variable $TERMCMD. If it doesn't exist, it tries to extract it from $TERM, +uses "x-terminal-emulator" as a fallback, and then "xterm" if that fails. Examples: C<:open_with c> will open the file that you currently point at, even if you have selected other files. C<:shell -w df> will run "df" and wait for @@ -848,6 +848,11 @@ Which script should handle generating previews? If the file doesn't exist, or use_preview_script is off, ranger will handle previews itself by just printing the content. +=item save_backtick_bookmark [bool] + +Save the C<`> bookmark to disk. This bookmark is used to switch to the last +directory by typing C<``>. + =item save_console_history [bool] Should the console history be saved on exit? If disabled, the console history diff --git a/doc/rifle.1 b/doc/rifle.1 index 4d112c6f..4d501df0 100644 --- a/doc/rifle.1 +++ b/doc/rifle.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 "RIFLE 1" -.TH RIFLE 1 "rifle-1.9.0b5" "09/17/2017" "rifle manual" +.TH RIFLE 1 "rifle-1.9.0b5" "10/01/2017" "rifle manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l diff --git a/ranger/config/commands.py b/ranger/config/commands.py index be0bbe3e..de3170bb 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1159,7 +1159,7 @@ class help_(Command): self.fm.ui.console.ask( "View [m]an page, [k]ey bindings, [c]ommands or [s]ettings? (press q to abort)", callback, - list("mkcsq") + [chr(27)] + list("mqkcs") ) @@ -1361,7 +1361,10 @@ class scout(Command): if self.OPEN_ON_ENTER in flags or \ (self.AUTO_OPEN in flags and count == 1): - self.fm.move(right=1) + if pattern == '..': + self.fm.cd(pattern) + else: + self.fm.move(right=1) if self.KEEP_OPEN in flags and thisdir != self.fm.thisdir: # reopen the console: diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index b4163083..9459a3d3 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -167,6 +167,10 @@ set padding_right true # When false, bookmarks are saved when ranger is exited. set autosave_bookmarks true +# Save the "`" bookmark to disk. This can be used to switch to the last +# directory by typing "``". +set save_backtick_bookmark true + # You can display the "real" cumulative size of directories by using the # command :get_cumulative_size or typing "dc". The size is expensive to # calculate and will not be updated automatically. You can choose diff --git a/ranger/container/bookmarks.py b/ranger/container/bookmarks.py index cba07367..36b06404 100644 --- a/ranger/container/bookmarks.py +++ b/ranger/container/bookmarks.py @@ -28,7 +28,8 @@ class Bookmarks(FileManagerAware): autosave = True load_pattern = re.compile(r"^[\d\w']:.") - def __init__(self, bookmarkfile, bookmarktype=str, autosave=False): + def __init__(self, bookmarkfile, bookmarktype=str, autosave=False, + nonpersistent_bookmarks=()): """Initializes Bookmarks. <bookmarkfile> specifies the path to the file where @@ -39,6 +40,7 @@ class Bookmarks(FileManagerAware): self.original_dict = {} self.path = bookmarkfile self.bookmarktype = bookmarktype + self.nonpersistent_bookmarks = set(nonpersistent_bookmarks) def load(self): """Load the bookmarks from path/bookmarks""" @@ -174,7 +176,8 @@ class Bookmarks(FileManagerAware): self.fm.notify('Bookmarks error: {0}'.format(str(ex)), bad=True) return for key, value in self.dct.items(): - if isinstance(key, str) and key in ALLOWED_KEYS: + if isinstance(key, str) and key in ALLOWED_KEYS \ + and key not in self.nonpersistent_bookmarks: fobj.write("{0}:{1}\n".format(str(key), str(value))) fobj.close() @@ -189,6 +192,16 @@ class Bookmarks(FileManagerAware): self._update_mtime() + def enable_saving_backtick_bookmark(self, boolean): + """ + Adds or removes the ' from the list of nonpersitent bookmarks + """ + if boolean: + if "'" in self.nonpersistent_bookmarks: + self.nonpersistent_bookmarks.remove("'") # enable + else: + self.nonpersistent_bookmarks.add("'") # disable + def _load_dict(self): if self.path is None: return {} diff --git a/ranger/container/settings.py b/ranger/container/settings.py index a0e1ab10..bb902f9d 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -30,6 +30,7 @@ ALLOWED_SETTINGS = { 'cd_bookmarks': bool, 'cd_tab_case': str, 'cd_tab_smart': bool, + 'clear_filters_on_dir_change': bool, 'collapse_preview': bool, 'colorscheme': str, 'column_ratios': (tuple, list), @@ -44,6 +45,7 @@ ALLOWED_SETTINGS = { 'freeze_files': bool, 'global_inode_type_filter': str, 'hidden_filter': str, + 'hostname_in_titlebar': bool, 'idle_delay': int, 'line_numbers': str, 'max_console_history_size': (int, type(None)), @@ -59,35 +61,34 @@ ALLOWED_SETTINGS = { 'preview_images_method': str, 'preview_max_size': int, 'preview_script': (str, type(None)), + 'save_backtick_bookmark': bool, 'save_console_history': bool, + 'save_tabs_on_exit': bool, 'scroll_offset': int, 'shorten_title': int, 'show_cursor': bool, # TODO: not working? - 'show_selection_in_titlebar': bool, 'show_hidden_bookmarks': bool, 'show_hidden': bool, + 'show_selection_in_titlebar': bool, 'sort_case_insensitive': bool, 'sort_directories_first': bool, 'sort_reverse': bool, - 'sort_unicode': bool, 'sort': str, + 'sort_unicode': bool, 'status_bar_on_top': bool, - 'hostname_in_titlebar': bool, 'tilde_in_titlebar': bool, 'unicode_ellipsis': bool, 'update_title': bool, 'update_tmux_title': bool, 'use_preview_script': bool, - 'viewmode': str, 'vcs_aware': bool, 'vcs_backend_bzr': str, 'vcs_backend_git': str, 'vcs_backend_hg': str, 'vcs_backend_svn': str, + 'viewmode': str, 'wrap_scroll': bool, 'xterm_alt_key': bool, - 'clear_filters_on_dir_change': bool, - 'save_tabs_on_exit': bool, } ALLOWED_VALUES = { diff --git a/ranger/core/fm.py b/ranger/core/fm.py index 76aa7876..591edecc 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -124,6 +124,8 @@ class FM(Actions, # pylint: disable=too-many-instance-attributes bookmarktype=Directory, autosave=self.settings.autosave_bookmarks) self.bookmarks.load() + self.bookmarks.enable_saving_backtick_bookmark( + self.settings.save_backtick_bookmark) self.ui.setup_curses() self.ui.initialize() @@ -190,6 +192,10 @@ class FM(Actions, # pylint: disable=too-many-instance-attributes 'setopt.metadata_deep_search', lambda signal: setattr(signal.fm.metadata, 'deep_search', signal.value) ) + self.settings.signal_bind( + 'setopt.save_backtick_bookmark', + lambda signal: signal.fm.bookmarks.enable_saving_backtick_bookmark(signal.value) + ) def destroy(self): debug = ranger.args.debug diff --git a/ranger/core/main.py b/ranger/core/main.py index 3f4f068a..0148e2b5 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -396,9 +396,11 @@ def load_settings( # pylint: disable=too-many-locals,too-many-branches,too-many custom_conf = fm.confpath('rc.conf') default_conf = fm.relpath('config', 'rc.conf') - if os.environ.get('RANGER_LOAD_DEFAULT_RC', 'TRUE').upper() != 'FALSE': + 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): fm.source(default_conf) - if os.access(custom_conf, os.R_OK): + if custom_conf_is_readable: fm.source(custom_conf) else: diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 75559954..b3272cbc 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -17,6 +17,10 @@ from . import Widget from .pager import Pager +def hook_before_drawing(fsobject, color_list): + return fsobject, color_list + + class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes main_column = False display_infostring = False @@ -387,6 +391,8 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes display_data = [] drawn.display_data[key] = display_data + drawn, this_color = hook_before_drawing(drawn, this_color) + predisplay = predisplay_left + predisplay_right for txt, color in predisplay: attr = self.settings.colorscheme.get_attr(*(this_color + color)) |