diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 15f68e8c4..7adb0f1ee 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -369,15 +369,18 @@ def draw(self): self.win.touchwin() DisplayableContainer.draw(self) if self._draw_title and self.settings.update_title: - cwd = self.fm.thisdir.path - if self.settings.tilde_in_titlebar \ - and (cwd == self.fm.home_path - or cwd.startswith(self.fm.home_path + "/")): - cwd = '~' + cwd[len(self.fm.home_path):] - if self.settings.shorten_title: - split = cwd.rsplit(os.sep, self.settings.shorten_title) - if os.sep in split[0]: - cwd = os.sep.join(split[1:]) + if self.fm.thisdir: + cwd = self.fm.thisdir.path + if self.settings.tilde_in_titlebar \ + and (cwd == self.fm.home_path + or cwd.startswith(self.fm.home_path + "/")): + cwd = '~' + cwd[len(self.fm.home_path):] + if self.settings.shorten_title: + split = cwd.rsplit(os.sep, self.settings.shorten_title) + if os.sep in split[0]: + cwd = os.sep.join(split[1:]) + else: + cwd = "not accessible" try: fixed_cwd = cwd.encode('utf-8', 'surrogateescape'). \ decode('utf-8', 'replace')