diff options
| author | Přemysl Janouch <p.janouch@gmail.com> | 2016-01-22 08:59:58 +0100 | 
|---|---|---|
| committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-01-26 21:56:09 +0100 | 
| commit | 99081814671c28f30540e81af7ae73096ba4b9e0 (patch) | |
| tree | f7afb47f69236672392793546c8a08a96e07a9d6 | |
| parent | 8146e336d7057d2064ed43e6684a11f601c84f47 (diff) | |
| download | desktop-tools-99081814671c28f30540e81af7ae73096ba4b9e0.tar.gz desktop-tools-99081814671c28f30540e81af7ae73096ba4b9e0.tar.xz desktop-tools-99081814671c28f30540e81af7ae73096ba4b9e0.zip | |
Add shellify
| -rw-r--r-- | CMakeLists.txt | 1 | ||||
| -rw-r--r-- | README.adoc | 2 | ||||
| -rwxr-xr-x | shellify | 24 | 
3 files changed, 27 insertions, 0 deletions
| diff --git a/CMakeLists.txt b/CMakeLists.txt index 75fdd8a..e37b106 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ install (FILES fancontrol-ng.conf.example  install (TARGETS dwmstatus brightness fancontrol-ng  	DESTINATION ${CMAKE_INSTALL_BINDIR}) +install (PROGRAMS shellify DESTINATION ${CMAKE_INSTALL_BINDIR})  install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})  # CPack diff --git a/README.adoc b/README.adoc index 26c99c1..10c28a5 100644 --- a/README.adoc +++ b/README.adoc @@ -12,6 +12,8 @@ to other people as well.   - 'fancontrol-ng' is a clone of fancontrol that can handle errors on resume     from suspend instead of setting fans to maximum speed and quitting;     in general it doesn't handle everything the original does + - 'shellify' is a simple script that sets up a shell for commands like vgdb +   and nmcli that are painfully lacking it  Don't expect them to work under any OS that isn't Linux. 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) + | 
