aboutsummaryrefslogtreecommitdiff
path: root/shellify
blob: 42e8505819b75919085a248bd80e1b63db7aa5c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/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 != '': os.system (prefix + ' ' + line)
	except (EOFError, KeyboardInterrupt) as err:
		print ('')
		break
	except Exception as err:
		print ('%s\n' % err)