qutebrowser/qutebrowser

New config: More powerful :config- commands

Open

#2,794 创建于 2017年7月6日

在 GitHub 查看
 (12 评论) (2 反应) (0 负责人)Python (9,161 star) (1,014 fork)batch import
component: configgood first issuepriority: 1 - middle

描述

Split off from https://github.com/qutebrowser/qutebrowser/issues/499#issuecomment-306508021 with some minor changes (adding :config-unset and :config-source, removing :conf-replace, see @lamarpavel's answer to the original comment):


What I haven't really talked about above is how the commands will look to edit some more complex setting types (like lists or dictionaries) from qutebrowser.

Things which used to be a section (like searchengines) will now be a dictionary, and the bindings will be too. There are also various things like hints -> prev/next-regexes which will actually be stored as list.

My current idea how to handle this is to add a few new :config-* commands, with :set being an alias to :config-set because :set is just a common thing to have.

Setting

  • :config-set (aka :set) will take a JSON syntax to set the elements, and override any previous settings. Examples:
    • :set custom-headers '{"X-Answer": "42"}'

Resetting a setting

  • :config-unset (or :config-reset) will be needed for various reasons:

  • To reset something which was customized via :set and now is in autoconfig.yml back to the default (i.e. removing it from the autoconfig.yml)

  • With per-domain settings: To unset a per-domain setting (and go back to either the global customized value, or the default).

  • Maybe as :config-unset --temp or so to unset all temporarily set options.

Adding

  • :config-add adds a new element to a dictionary or list. Maybe with a --replace switch needed to override existing values.

Examples:

  • :config-add custom-headers X-Answer 42
  • :config-add searchengines wiki https://en.wikipedia.org/wiki/{}
  • :config-add next-regexes weiter

Removing

  • :config-remove removes an element by key (dicts) or value (lists).

Examples:

  • :config-remove custom-headers X-Answer
  • :config-remove searchengines wiki
  • :config-remove next-regexes weiter

Replacing

  • :config-replace searches an element as per above, and replaces the value.

Examples:

  • :config-replace custom-headers X-Answer 23
  • :config-replace searchengines wiki https://de.wikipedia.org/wiki/{}
  • :config-replace next-regexes weiter [Ww]eiter

Toggling

  • :config-list-toggle either adds to or removes from a list. This can be useful for user stylesheets. Maybe better as part of :config-replace though?

Examples:

  • :config-list-toggle content.user_stylesheets ~/.../darkmode.css

Source

  • :config-source reloads the config (see #54). It can take a filename to load that file instead. It should maybe support both autoconfig.yml and config.py like files.

Examples:

  • :config-source (reload autoconfig.yml and config.py)
  • :config-source ~/.config/qutebrowser/night.py (could be used to set a user CSS and recolor the UI; like a theme)

Editing

  • :config-edit to open the config.py file in the configured editor.

--

Thoughts? Any other modifications which should be supported?

贡献者指南

New config: More powerful :config- commands · qutebrowser/qutebrowser#2794 | Good First Issue