From 2bc70964e804cd1782b9f51e40a7fa987531c05a Mon Sep 17 00:00:00 2001 From: Bart Trojanowski Date: Wed, 22 Nov 2023 20:31:13 +0000 Subject: [PATCH] show basename in source: split line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit before this change I would get a split with... `────────────────────────── source:/server/externa[...].cpp+130 ────` which does not tell me anything about what file I am in. now I get something like this... `─────────────── source:/server/externa[...]SendReceive.hpp+110 ────` --- gef.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gef.py b/gef.py index 5c187451f..24f2cdce2 100644 --- a/gef.py +++ b/gef.py @@ -7663,8 +7663,11 @@ def context_source(self) -> None: nb_line = self["nb_lines_code"] fn = symtab.filename - if len(fn) > 20: - fn = f"{fn[:15]}[...]{os.path.splitext(fn)[1]}" + if len(fn) > 30: + base = os.path.basename(fn) + if len(base) > 20: + base = f"{base[-10:]}" + fn = f"{fn[:15]}[...]{base}" title = f"source:{fn}+{line_num + 1}" cur_line_color = gef.config["theme.source_current_line"] self.context_title(title)