diff --git a/britney.py b/britney.py index 71cdc54..292dab3 100755 --- a/britney.py +++ b/britney.py @@ -2505,6 +2505,9 @@ class Britney: readline.parse_and_bind('tab: complete') readline.set_completer(Completer(self).completer) + # Package names can contain "-" and we use "/" in our presentation of them as well, + # so ensure readline does not split on these characters. + readline.set_completer_delims(readline.get_completer_delims().replace('-', '').replace('/', '')) while True: # read the command from the command line diff --git a/completer.py b/completer.py index be86744..ea09f6a 100644 --- a/completer.py +++ b/completer.py @@ -45,11 +45,15 @@ class Completer: self.matches = [x for x in self.cmds if x.startswith(text)] else: # complete pkg/[arch/]version + prefix = '' + if len(text) > 0 and text[0] == '-': + text = text[1:] + prefix = '-' start = bisect.bisect_left(self.packages, text) while start < len(self.packages): if not self.packages[start].startswith(text): break - self.matches.append(self.packages[start]) + self.matches.append(prefix + self.packages[start]) start += 1 if len(self.matches) > state: