diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 4135a89e4..f94dfa4eb 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -48,6 +48,8 @@ Added * `colors -> downloads.bg.system` - New command `:download-retry` to retry a failed download. - New command `:download-clear` which replaces `:download-remove --all`. +- `:set-cmd-text` has a new `--append` argument to append to the current + statusbar text. Changed ~~~~~~~ diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index f47bdabd3..98081479d 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -571,7 +571,7 @@ If the option name ends with '?', the value of the option is shown instead. If t [[set-cmd-text]] === set-cmd-text -Syntax: +:set-cmd-text [*--space*] 'text'+ +Syntax: +:set-cmd-text [*--space*] [*--append*] 'text'+ Preset the statusbar to some text. @@ -580,6 +580,7 @@ Preset the statusbar to some text. ==== optional arguments * +*-s*+, +*--space*+: If given, a space is added to the end. +* +*-a*+, +*--append*+: If given, the text is appended to the current text. ==== note * This command does not split arguments after the last argument and handles quotes literally. diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py index 1d8105c2f..0a06aed79 100644 --- a/qutebrowser/mainwindow/statusbar/command.py +++ b/qutebrowser/mainwindow/statusbar/command.py @@ -92,7 +92,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): @cmdutils.register(instance='status-command', name='set-cmd-text', scope='window', maxsplit=0) - def set_cmd_text_command(self, text, space=False): + def set_cmd_text_command(self, text, space=False, append=False): """Preset the statusbar to some text. // @@ -103,6 +103,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): Args: text: The commandline to set. space: If given, a space is added to the end. + append: If given, the text is appended to the current text. """ tabbed_browser = objreg.get('tabbed-browser', scope='window', window=self._win_id) @@ -122,8 +123,14 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): # I'm not sure what's the best thing to do here # https://github.com/The-Compiler/qutebrowser/issues/123 text = text.replace('{url}', url) + if space: text += ' ' + if append: + if not self.text(): + raise cmdexc.CommandError("No current text!") + text = self.text() + text + if not text or text[0] not in modeparsers.STARTCHARS: raise cmdexc.CommandError( "Invalid command text '{}'.".format(text))