Skip to content

Instantly share code, notes, and snippets.

@slode
Last active September 16, 2016 08:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slode/b62a56acf283cd574b20839b3f483cca to your computer and use it in GitHub Desktop.
Save slode/b62a56acf283cd574b20839b3f483cca to your computer and use it in GitHub Desktop.
def print_cmd(command, line_length=80, indent=" "):
import sys, textwrap
lines = textwrap.wrap(
command,
width=line_length,
subsequent_indent=" \\\n" + indent,
break_long_words=False,
break_on_hyphens=False)
for line in lines:
sys.stdout.write(line)
sys.stdout.write("\n")
@slode
Copy link
Author

slode commented Sep 9, 2016

Python script to pretty print long command line calls. Will terminate lines with the \ character and indent all lines except the first.

@cslarsen
Copy link

cslarsen commented Sep 16, 2016

+1

Also, the benefit is, of course, that you can copy and paste the output into your own shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment