Skip to content

Instantly share code, notes, and snippets.

@richardkiss
Created March 30, 2018 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardkiss/4fba0c6bd27eb39a9eb56074dd0f2ba4 to your computer and use it in GitHub Desktop.
Save richardkiss/4fba0c6bd27eb39a9eb56074dd0f2ba4 to your computer and use it in GitHub Desktop.
A "mirror-image" ls in python, as discussed at https://news.ycombinator.com/item?id=16716150
#!/usr/bin/env python
import subprocess
import sys
output = subprocess.check_output(["ls"] + sys.argv[1:])
lines = output.split("\n")
size = max(len(_) for _ in lines)
spaces = " " * size
for l in lines:
line = (l + spaces)[:size]
line = ''.join(list(reversed(line)))
print(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment