aboutsummaryrefslogtreecommitdiff
path: root/shellify
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-01-22 08:59:58 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2016-01-26 21:56:09 +0100
commit99081814671c28f30540e81af7ae73096ba4b9e0 (patch)
treef7afb47f69236672392793546c8a08a96e07a9d6 /shellify
parent8146e336d7057d2064ed43e6684a11f601c84f47 (diff)
downloaddesktop-tools-99081814671c28f30540e81af7ae73096ba4b9e0.tar.gz
desktop-tools-99081814671c28f30540e81af7ae73096ba4b9e0.tar.xz
desktop-tools-99081814671c28f30540e81af7ae73096ba4b9e0.zip
Add shellify
Diffstat (limited to 'shellify')
-rwxr-xr-xshellify24
1 files changed, 24 insertions, 0 deletions
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)
+