From 8f1b074595ed38d41fec5b734052230f896940d9 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 20 Apr 2015 18:44:58 +0200 Subject: [PATCH] Show commandline being executed with :spawn. Closes #616. --- CHANGELOG.asciidoc | 1 + doc/help/commands.asciidoc | 3 ++- qutebrowser/browser/commands.py | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index e467898a1..950679b90 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -26,6 +26,7 @@ Changed ~~~~~~~ - `QUTE_HTML` and `QUTE_TEXT` for userscripts now don't store the contents directly, and instead contain a filename. +- `:spawn` now shows the command being executed in the statusbar, use `-q`/`--quiet` for the old behavior. https://github.com/The-Compiler/qutebrowser/releases/tag/v0.2.1[v0.2.1] ----------------------------------------------------------------------- diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 344db3e55..d6340b35a 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -510,7 +510,7 @@ Preset the statusbar to some text. [[spawn]] === spawn -Syntax: +:spawn [*--userscript*] 'args' ['args' ...]+ +Syntax: +:spawn [*--userscript*] [*--quiet*] 'args' ['args' ...]+ Spawn a command in a shell. @@ -521,6 +521,7 @@ Note the {url} variable which gets replaced by the current URL might be useful h ==== optional arguments * +*-u*+, +*--userscript*+: Run the command as an userscript. +* +*-q*+, +*--quiet*+: Don't print the commandline being executed. [[stop]] === stop diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 1addbd8f7..b1ec93658 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -21,6 +21,7 @@ import re import os +import shlex import subprocess import posixpath import functools @@ -823,7 +824,8 @@ class CommandDispatcher: tabbed_browser.setUpdatesEnabled(True) @cmdutils.register(instance='command-dispatcher', scope='window') - def spawn(self, userscript=False, *args): + def spawn(self, win_id: {'special': 'win_id'}, userscript=False, + quiet=False, *args): """Spawn a command in a shell. Note the {url} variable which gets replaced by the current URL might be @@ -836,10 +838,14 @@ class CommandDispatcher: Args: userscript: Run the command as an userscript. + quiet: Don't print the commandline being executed. *args: The commandline to execute. """ log.procs.debug("Executing: {}, userscript={}".format( args, userscript)) + if not quiet: + fake_cmdline = ' '.join(shlex.quote(arg) for arg in args) + message.info(win_id, 'Executing: ' + fake_cmdline) if userscript: cmd = args[0] args = [] if not args else args[1:]