diff --git a/examples/shell.py b/examples/shell.py index bd03339..1136cfd 100755 --- a/examples/shell.py +++ b/examples/shell.py @@ -9,6 +9,10 @@ parser.add_argument('-c', action='store', help='Command to execute.', default='') +parser.add_argument('--insert', + action='store_true', + help='Type output into current tab?', + default=False) @userscript @@ -17,8 +21,13 @@ def shell_command(request): if not args.c: request.send_text("Please specify a command: {} -c'uname -a' ".format(request.script_name)) return - r = subprocess.check_output(args=args.c.split(' ')) - request.send_text(r) + r = subprocess.check_output(args=args.c, shell=True) + text = str(r, 'utf-8').strip() + if args.insert: + request.send_command('insert-text {}'.format(text)) + # request.send_text(text) + else: + request.send_text(text) if __name__ == '__main__': diff --git a/src/qutescript/installer.py b/src/qutescript/installer.py index 3853e39..e8cd831 100644 --- a/src/qutescript/installer.py +++ b/src/qutescript/installer.py @@ -6,13 +6,23 @@ import stat REVIEW_TEMPLATE = """\ Qutebrowser userscript {name!r} was installed at: - {userscripts_path!r} -You can try it out by running the command: - +Try it out by running the command: :spawn --userscript {name} +Bind the command to a keystroke with: + :bind KEYS spawn --userscript {name} OPTIONAL-ARGUMENTS + + examples: + - :bind kk spawn --userscript debug --kaboom + Use this by typing "kk" in normal mode, not fun :P + + - :bind ,dt spawn --userscript shell -c"date" --insert + Inserts current date in active tab. + +Warning: Enclose your provided arguments and options in quotes and +always test your command passed to `shell -c""` in the shell. """ LOADER_TEMPLATE = """\