diff options
author | hut <hut@lavabit.com> | 2010-04-13 12:19:10 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-13 12:38:36 +0200 |
commit | 59698d9d1529646719b108ad6b8596e1383d533b (patch) | |
tree | 1da8707d6fcd5717b6119e7714aa274499636e4c | |
parent | fab4dc542e9f2b0ee55a97046915894c9e5ae37b (diff) | |
download | ranger-59698d9d1529646719b108ad6b8596e1383d533b.tar.gz |
Abbreviate HOME with ~ in the titlebar
-rw-r--r-- | ranger/defaults/options.py | 3 | ||||
-rw-r--r-- | ranger/gui/bar.py | 4 | ||||
-rw-r--r-- | ranger/gui/widgets/titlebar.py | 15 | ||||
-rw-r--r-- | ranger/shared/settings.py | 1 |
4 files changed, 18 insertions, 5 deletions
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py index d96955b7..a9dd8bde 100644 --- a/ranger/defaults/options.py +++ b/ranger/defaults/options.py @@ -75,6 +75,9 @@ update_title = True # directories are displayed at once, False turns off this feature. shorten_title = 3 +# Abbreviate $HOME with ~ in the titlebar (first line) of ranger? +tilde_in_titlebar = True + # How many directory-changes or console-commands should be kept in history? max_history_size = 20 diff --git a/ranger/gui/bar.py b/ranger/gui/bar.py index c06a201e..0ef840a4 100644 --- a/ranger/gui/bar.py +++ b/ranger/gui/bar.py @@ -95,8 +95,10 @@ class BarSide(list): def add(self, string, *lst, **kw): cs = ColoredString(string, self.base_color_tag, *lst) + cs.__dict__.update(kw) if 'fixedsize' in kw: - cs.fixed = kw['fixedsize'] + kw['fixed'] = kw['fixedsize'] + del kw['fixedsize'] self.append(cs) def add_space(self, n=1): diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py index 62740e2d..ddcd03c3 100644 --- a/ranger/gui/widgets/titlebar.py +++ b/ranger/gui/widgets/titlebar.py @@ -84,7 +84,7 @@ class TitleBar(Widget): self.fm.enter_dir("/") else: try: - self.fm.env.enter_dir(self.env.pathway[(i-3)/2]) + self.fm.enter_dir(part.directory) except: pass return True @@ -109,15 +109,22 @@ class TitleBar(Widget): bar.add(self.env.username, 'hostname', clr, fixedsize=True) bar.add('@', 'hostname', clr, fixedsize=True) bar.add(self.env.hostname, 'hostname', clr, fixedsize=True) + bar.add(':', 'hostname', clr, fixedsize=True) - for path in self.env.pathway: + pathway = self.env.pathway + if self.settings.tilde_in_titlebar and \ + self.fm.env.cwd.path.startswith(self.env.home_path): + pathway = pathway[self.env.home_path.count('/')+1:] + bar.add('~/', 'directory', fixedsize=True) + + for path in pathway: if path.islink: clr = 'link' else: clr = 'directory' - bar.add(path.basename, clr) - bar.add('/', clr, fixedsize=True) + bar.add(path.basename, clr, directory=path) + bar.add('/', clr, fixedsize=True, directory=path) if self.env.cf is not None: bar.add(self.env.cf.basename, 'file', fixedsize=True) diff --git a/ranger/shared/settings.py b/ranger/shared/settings.py index c5544a47..692d06d2 100644 --- a/ranger/shared/settings.py +++ b/ranger/shared/settings.py @@ -34,6 +34,7 @@ ALLOWED_SETTINGS = { 'sort_directories_first': bool, 'update_title': bool, 'shorten_title': int, # Note: False is an instance of int + 'tilde_in_titlebar': bool, 'max_filesize_for_preview': (int, type(None)), 'max_history_size': (int, type(None)), 'scroll_offset': int, |