From 99081814671c28f30540e81af7ae73096ba4b9e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Fri, 22 Jan 2016 08:59:58 +0100 Subject: Add shellify --- shellify | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 shellify (limited to 'shellify') diff --git a/shellify b/shellify new file mode 100755 index 0000000..430178d --- /dev/null +++ b/shellify @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# Runs a special shell prepending a given command + +import sys +import os +import readline +import itertools + +prefix = ' '.join (sys.argv[1:]) +readline.parse_and_bind ('TAB: complete') +for n in itertools.count (start=1): + try: + line = input ('\x1b[1m%s %d>\x1b[0m ' % (prefix, n)) + if line == '': + continue + + readline.add_history (line) + os.system (prefix + ' ' + line) + except (EOFError, KeyboardInterrupt) as err: + print ('') + break + except Exception as err: + print ('%s\n' % err) + -- cgit v1.2.3