Add --insert option for shell userscript.

master
Harshad Sharma 7 years ago
parent d591f93551
commit 94d586317c

@ -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__':

@ -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 = """\

Loading…
Cancel
Save