Last active
February 10, 2022 01:39
-
-
Save shollingsworth/55642e0877ff0cfec8288b2eaa8457b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/env python3 | |
| # -*- coding: utf-8 -*- | |
| """breakout a bash command into lines.""" | |
| import select | |
| import sys | |
| from textwrap import indent | |
| def main(): | |
| """Run main function.""" | |
| if select.select([sys.stdin], [], [], 0.0)[0]: | |
| content = sys.stdin.read() | |
| else: | |
| raise SystemExit("No STDIN detected!") | |
| lines = content.splitlines() | |
| sep = " " | |
| for line in lines: | |
| spl = line.split() | |
| beg = spl.pop(0) | |
| out = " \\\n".join(spl) | |
| print(f"{beg} \\\n{indent(out, prefix=sep)}") | |
| print() | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment