Last active
November 17, 2020 01:19
-
-
Save devilholk/b176b9c62c83636eb7552b3629e0b067 to your computer and use it in GitHub Desktop.
Example for bashcomp.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys, os | |
#Usage: https://gist.github.com/devilholk/d1dcbb194086c84915c718d9ccafd95a | |
def combine_args(args): | |
result = list() | |
for a in args: | |
if result and result[-1].endswith('\\'): | |
result[-1] = result[-1][:-1] + ' ' + a | |
else: | |
result.append(a) | |
return result | |
#Get args | |
comp_line = combine_args(sys.argv[1:]) | |
#Print debug info on remote terminal | |
from efforting.tech.remote_terminal import partial_update_remote_terminal | |
sys.stderr = partial_update_remote_terminal('localhost', 8885, f'Auxillary terminal for `{__file__}´', auto_clear=True) | |
print('ARGS', sys.argv, file=sys.stderr) | |
print('comp_line', comp_line, file=sys.stderr) | |
#Uggly test case - not a complete example | |
if comp_line == 'my_command show alias'.split(): | |
print('compgen -a;') | |
elif comp_line == 'my_command show'.split(): | |
print('echo alias;') | |
print('echo stuff;') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment