diff --git a/qutebrowser/commands/utils.py b/qutebrowser/commands/utils.py index 5f6225847..f174b05e6 100644 --- a/qutebrowser/commands/utils.py +++ b/qutebrowser/commands/utils.py @@ -148,11 +148,12 @@ class CommandParser(QObject): self._cmd = None self._args = [] - def _parse(self, text): + def _parse(self, text, aliases=True): """Split the commandline text into command and arguments. Args: text: Text to parse. + aliases: Whether to handle aliases. Raise: NoSuchCommandError if a command wasn't found. @@ -162,6 +163,13 @@ class CommandParser(QObject): if not parts: raise NoSuchCommandError("No command given") cmdstr = parts[0] + if aliases: + try: + alias = config.config.get('aliases', cmdstr) + except config.NoOptionError: + pass + else: + return self._parse(alias, aliases=False) try: cmd = cmd_dict[cmdstr] except KeyError: diff --git a/qutebrowser/qutebrowser.conf b/qutebrowser/qutebrowser.conf index faf330b32..fc900987c 100644 --- a/qutebrowser/qutebrowser.conf +++ b/qutebrowser/qutebrowser.conf @@ -121,6 +121,11 @@ PP = tabpaste sel @Ctrl-D@ = scroll_page 0 0.5 @Ctrl-U@ = scroll_page 0 -0.5 +[aliases] +# Here you can add aliases for commands. By default, no aliases are defined. +# Example which adds a new command :qtb to open qutebrowsers website: +# qtb = open http://www.qutebrowser.org/ + [colors] # Colors used in the UI. A value can be in one of the following format: # - #RGB/#RRGGBB/#RRRGGGBBB/#RRRRGGGGBBBB