Show commandline being executed with :spawn.

Closes #616.
This commit is contained in:
Florian Bruhin 2015-04-20 18:44:58 +02:00
parent 94d49b4801
commit 8f1b074595
3 changed files with 10 additions and 2 deletions

View File

@ -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]
-----------------------------------------------------------------------

View File

@ -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

View File

@ -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:]