Skip to content

Instantly share code, notes, and snippets.

@gMan1990
Last active October 10, 2019 12:32
Show Gist options
  • Save gMan1990/59c9f7387184cc56d69c4d391ecbe1a0 to your computer and use it in GitHub Desktop.
Save gMan1990/59c9f7387184cc56d69c4d391ecbe1a0 to your computer and use it in GitHub Desktop.
sort by created: https://github.com/ogham/exa
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import subprocess
def cmp_creation(x, y):
xs = x.split("/")
ys = y.split("/")
if "darwin" == sys.platform:
argv = ["stat", "-f", "%B"]
else:
argv = ["stat", "-c", "%W"]
ix = int(subprocess.check_output(argv + ["/".join(xs[0:2])]))
iy = int(subprocess.check_output(argv + ["/".join(ys[0:2])]))
return ix - iy
for f in sorted(sys.argv[1:], cmp=cmp_creation):
print(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment